Bouncy Castle Cryptography Library 1.85

org.bouncycastle.bcpg
Class ArmoredInputStream.Builder

java.lang.Object
  extended byorg.bouncycastle.bcpg.ArmoredInputStream.Builder
Enclosing class:
ArmoredInputStream

public static class ArmoredInputStream.Builder
extends java.lang.Object


Method Summary
 ArmoredInputStream.Builder addAllowedArmorHeader(java.lang.String header)
           
 ArmoredInputStream build(java.io.InputStream inputStream)
           
 ArmoredInputStream.Builder setDetectMissingCRC(boolean detectMissingCRC)
          Change how the stream should react if it encounters missing CRC checksum.
 ArmoredInputStream.Builder setIgnoreCRC(boolean ignoreCRC)
          Specifically ignore the CRC if in place (this will also avoid the cost of calculation).
 ArmoredInputStream.Builder setParseForHeaders(boolean hasHeaders)
          Enable or disable header parsing (default value true).
 ArmoredInputStream.Builder setRejectPrefixedDashesInCSFMessages(boolean rejectDashes)
          Configure how a cleartext-signed (CSF) message is handled when a payload line begins with a dash that is neither a "-----" armor header nor a "- " dash-escape.
 ArmoredInputStream.Builder setValidateClearsignedMessageHeaders(boolean validateHeaders)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setParseForHeaders

public ArmoredInputStream.Builder setParseForHeaders(boolean hasHeaders)
Enable or disable header parsing (default value true).

Parameters:
hasHeaders - true if headers should be expected, false otherwise.
Returns:
the current builder instance.

setValidateClearsignedMessageHeaders

public ArmoredInputStream.Builder setValidateClearsignedMessageHeaders(boolean validateHeaders)

setRejectPrefixedDashesInCSFMessages

public ArmoredInputStream.Builder setRejectPrefixedDashesInCSFMessages(boolean rejectDashes)
Configure how a cleartext-signed (CSF) message is handled when a payload line begins with a dash that is neither a "-----" armor header nor a "- " dash-escape. RFC 4880 7.1 requires every cleartext line beginning with a dash to be prefixed with "- " (dash, space), so a leading dash not followed by a space signals a malformed message. Historically the two leading characters were dropped unconditionally, so a signature over "payload" also verified against a tampered "-Xpayload" line.

Defaults to (reject with an ArmoredInputException). RFC-conformant messages - including everything written by ArmoredOutputStream - never trigger this. When set to the offending bytes are returned verbatim instead of being dropped, so a signature check over the recovered text fails rather than silently succeeding.

Parameters:
rejectDashes - true to reject malformed dash-prefixed CSF messages, false to surface their bytes verbatim.
Returns:
the current builder instance.

addAllowedArmorHeader

public ArmoredInputStream.Builder addAllowedArmorHeader(java.lang.String header)

setDetectMissingCRC

public ArmoredInputStream.Builder setDetectMissingCRC(boolean detectMissingCRC)
Change how the stream should react if it encounters missing CRC checksum. The default value is false (ignore missing CRC checksums). If the behavior is set to true, an IOException will be thrown if a missing CRC checksum is encountered.

Parameters:
detectMissingCRC - false if ignore missing CRC sums, true for exception

setIgnoreCRC

public ArmoredInputStream.Builder setIgnoreCRC(boolean ignoreCRC)
Specifically ignore the CRC if in place (this will also avoid the cost of calculation).

Parameters:
ignoreCRC - true if CRC should be ignored, false otherwise.
Returns:
the current builder instance.

build

public ArmoredInputStream build(java.io.InputStream inputStream)
                         throws java.io.IOException
Throws:
java.io.IOException

Bouncy Castle Cryptography Library 1.85