Class ArmoredOutputStream

  • All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

    public class ArmoredOutputStream
    extends OutputStream
    Output stream that writes data in ASCII Armored format.

    Note 1: close() needs to be called on an ArmoredOutputStream to write the final checksum. flush() will not do this as other classes assume it is always fine to call flush() - it is not though if the checksum gets output. Note 2: as multiple PGP blobs are often written to the same stream, close() does not close the underlying stream.

    • Constructor Detail

      • ArmoredOutputStream

        public ArmoredOutputStream​(OutputStream out)
        Constructs an armored output stream with default headers.
        Parameters:
        out - the OutputStream to wrap.
      • ArmoredOutputStream

        public ArmoredOutputStream​(OutputStream out,
                                   Hashtable headers)
        Constructs an armored output stream with default and custom headers.
        Parameters:
        out - the OutputStream to wrap.
        headers - additional headers that add to or override the default headers.
    • Method Detail

      • setHeader

        public void setHeader​(String name,
                              String value)
        Set an additional header entry. Any current value(s) under the same name will be replaced by the new one. A null value will clear the entry for name.
        Parameters:
        name - the name of the header entry.
        value - the value of the header entry.
      • clearHeaders

        public void clearHeaders()
        Remove all headers.
      • addHeader

        public void addHeader​(String name,
                              String value)
        Set an additional header entry. The current value(s) will continue to exist together with the new one. Adding a null value has no effect.
        Parameters:
        name - the name of the header entry.
        value - the value of the header entry.
      • resetHeaders

        public void resetHeaders()
        Reset the headers to only contain a Version string (if one is present)
      • beginClearText

        public void beginClearText​(int hashAlgorithm)
                            throws IOException
        Start a clear text signed message.
        Parameters:
        hashAlgorithm -
        Throws:
        IOException
      • endClearText

        public void endClearText()