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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs 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 TypeMethodDescriptionvoid
Deprecated.void
beginClearText
(int hashAlgorithm) Start a clear text signed message - backwards compatibility.void
beginClearText
(int... hashAlgorithms) Start a clear text signed message.static ArmoredOutputStream.Builder
builder()
void
Deprecated.use appropriate methods inArmoredOutputStream.Builder
instead.void
close()
Note: close() does not close the underlying stream.void
void
flush()
void
Deprecated.useArmoredOutputStream.Builder.clearHeaders()
instead.void
Deprecated.use appropriate methods inArmoredOutputStream.Builder
instead.void
write
(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.Builder
instead.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.Builder
instead.Remove all headers. -
addHeader
Deprecated.use appropriate methods inArmoredOutputStream.Builder
insteadSet 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:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
builder
-
ArmoredOutputStream.Builder
instead