Package org.apache.tapestry5.internal.util

## Class MacOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.tapestry5.internal.util.MacOutputStream

- All Implemented Interfaces:
    `java.io.Closeable`, `java.io.Flushable`, `java.lang.AutoCloseable`

      public class MacOutputStream
      extends java.io.OutputStream

  An output stream that wraps around a `Mac` (message authentication code algorithm). This is currently used for symmetric (private) keys, but in theory could be used with assymetric (public/private) keys.
  Since:
    5.3.6

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MacOutputStream​(javax.crypto.Mac mac)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `java.lang.String` | `getResult()` | Should only be invoked once, immediately after this stream is closed; it generates the final MAC result, and returns it as a Base64 encoded string.
    `static MacOutputStream` | `streamFor​(java.security.Key key)` |
    `void` | `write​(byte[] b)` |
    `void` | `write​(byte[] b, int off, int len)` |
    `void` | `write​(int b)` |

    - ### Methods inherited from class java.io.OutputStream

      `close, flush, nullOutputStream`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MacOutputStream

          public MacOutputStream​(javax.crypto.Mac mac)

  - ### Method Detail

    - #### streamFor

          public static MacOutputStream streamFor​(java.security.Key key)
                                           throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getResult

          public java.lang.String getResult()

      Should only be invoked once, immediately after this stream is closed; it generates the final MAC result, and returns it as a Base64 encoded string.
      Returns:
        Base64 encoded MAC result

    - #### write

          public void write​(int b)
                     throws java.io.IOException

      Specified by:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### write

          public void write​(byte[] b)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### write

          public void write​(byte[] b,
                            int off,
                            int len)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`