Package org.bouncycastle.bcpg
Class ArmoredOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- org.bouncycastle.bcpg.ArmoredOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ArmoredOutputStream extends java.io.OutputStreamOutput 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 Modifier and Type Class Description static classArmoredOutputStream.Builder
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCHARSET_HDRstatic java.lang.StringCOMMENT_HDRstatic java.lang.StringDEFAULT_VERSIONstatic java.lang.StringHASH_HDRstatic java.lang.StringMESSAGE_ID_HDRstatic java.lang.StringVERSION_HDR
-
Constructor Summary
Constructors Constructor Description ArmoredOutputStream(java.io.OutputStream out)Constructs an armored output stream withdefault headers.ArmoredOutputStream(java.io.OutputStream out, java.util.Hashtable<java.lang.String,java.lang.String> headers)Constructs an armored output stream with default and custom headers.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddHeader(java.lang.String name, java.lang.String value)Deprecated.use appropriate methods inArmoredOutputStream.BuilderinsteadvoidbeginClearText(int hashAlgorithm)Start a clear text signed message - backwards compatibility.voidbeginClearText(int... hashAlgorithms)Start a clear text signed message.static ArmoredOutputStream.Builderbuilder()voidclearHeaders()Deprecated.use appropriate methods inArmoredOutputStream.Builderinstead.voidclose()Note: close() does not close the underlying stream.voidendClearText()voidflush()voidresetHeaders()Deprecated.useArmoredOutputStream.Builder.clearHeaders()instead.voidsetHeader(java.lang.String name, java.lang.String value)Deprecated.use appropriate methods inArmoredOutputStream.Builderinstead.voidwrite(int b)
-
-
-
Field Detail
-
VERSION_HDR
public static final java.lang.String VERSION_HDR
- See Also:
- Constant Field Values
-
COMMENT_HDR
public static final java.lang.String COMMENT_HDR
- See Also:
- Constant Field Values
-
MESSAGE_ID_HDR
public static final java.lang.String MESSAGE_ID_HDR
- See Also:
- Constant Field Values
-
HASH_HDR
public static final java.lang.String HASH_HDR
- See Also:
- Constant Field Values
-
CHARSET_HDR
public static final java.lang.String CHARSET_HDR
- See Also:
- Constant Field Values
-
DEFAULT_VERSION
public static final java.lang.String DEFAULT_VERSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ArmoredOutputStream
public ArmoredOutputStream(java.io.OutputStream out)
Constructs an armored output stream withdefault headers.- Parameters:
out- the OutputStream to wrap.
-
ArmoredOutputStream
public ArmoredOutputStream(java.io.OutputStream out, java.util.Hashtable<java.lang.String,java.lang.String> 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 thedefault headers.
-
-
Method Detail
-
setHeader
@Deprecated public void setHeader(java.lang.String name, java.lang.String value)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 public void clearHeaders()
Deprecated.use appropriate methods inArmoredOutputStream.Builderinstead.Remove all headers.
-
addHeader
@Deprecated public void addHeader(java.lang.String name, java.lang.String value)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 public void resetHeaders()
Deprecated.useArmoredOutputStream.Builder.clearHeaders()instead.Reset the headers to only contain a Version string (if one is present)
-
beginClearText
public void beginClearText(int hashAlgorithm) throws java.io.IOExceptionStart a clear text signed message - backwards compatibility.- Parameters:
hashAlgorithm- hash algorithm- Throws:
java.io.IOException
-
beginClearText
public void beginClearText(int... hashAlgorithms) throws java.io.IOExceptionStart a clear text signed message.- Parameters:
hashAlgorithms- hash algorithms- Throws:
java.io.IOException
-
endClearText
public void endClearText()
-
write
public void write(int b) throws java.io.IOException- Specified by:
writein classjava.io.OutputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptionNote: close() does not close the underlying stream. So it is possible to write multiple objects using armoring to a single stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException
-
builder
public static ArmoredOutputStream.Builder builder()
-
-