Package org.bouncycastle.bcpg
Class ArmoredOutputStream
java.lang.Object
java.io.OutputStream
org.bouncycastle.bcpg.ArmoredOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
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.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an armored output stream withdefault headers.ArmoredOutputStream(OutputStream out, Hashtable<String, String> headers) Constructs an armored output stream with default and custom headers. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voidbeginClearText(int hashAlgorithm) Start a clear text signed message - backwards compatibility.voidbeginClearText(int... hashAlgorithms) Start a clear text signed message.static ArmoredOutputStream.Builderbuilder()voidDeprecated.use appropriate methods inArmoredOutputStream.Builderinstead.voidclose()Note: close() does not close the underlying stream.voidvoidflush()voidDeprecated.useArmoredOutputStream.Builder.clearHeaders()instead.voidDeprecated.use appropriate methods inArmoredOutputStream.Builderinstead.voidwrite(int b) Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
VERSION_HDR
- See Also:
-
COMMENT_HDR
- See Also:
-
MESSAGE_ID_HDR
- See Also:
-
HASH_HDR
- See Also:
-
CHARSET_HDR
- See Also:
-
DEFAULT_VERSION
- See Also:
-
-
Constructor Details
-
ArmoredOutputStream
Constructs an armored output stream withdefault headers.- Parameters:
out- the OutputStream to wrap.
-
ArmoredOutputStream
Constructs an armored output stream with default and custom headers.- Parameters:
out- the OutputStream to wrap.headers- additional headers that add to or override thedefault headers.
-
-
Method Details
-
setHeader
Deprecated.use appropriate methods inArmoredOutputStream.Builderinstead.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
Deprecated.use appropriate methods inArmoredOutputStream.Builderinstead.Remove all headers. -
addHeader
Deprecated.use appropriate methods inArmoredOutputStream.BuilderinsteadSet 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
Deprecated.useArmoredOutputStream.Builder.clearHeaders()instead.Reset the headers to only contain a Version string (if one is present) -
beginClearText
Start a clear text signed message - backwards compatibility.- Parameters:
hashAlgorithm- hash algorithm- Throws:
IOException
-
beginClearText
Start a clear text signed message.- Parameters:
hashAlgorithms- hash algorithms- Throws:
IOException
-
endClearText
public void endClearText() -
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
Note: close() does not close the underlying stream. So it is possible to write multiple objects using armoring to a single stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
builder
-
ArmoredOutputStream.Builderinstead