Package org.pgpainless.util
Class CRCingArmoredInputStreamWrapper
- java.lang.Object
-
- java.io.InputStream
-
- org.bouncycastle.bcpg.ArmoredInputStream
-
- org.pgpainless.util.CRCingArmoredInputStreamWrapper
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class CRCingArmoredInputStreamWrapper extends org.bouncycastle.bcpg.ArmoredInputStreamUtility class that causes read(bytes, offset, length) to properly throw exceptions caused by faulty CRC checksums. Furthermore, this class swallows exceptions from BC's ArmoredInputStream that are caused by missing CRC checksums.
-
-
Constructor Summary
Constructors Constructor Description CRCingArmoredInputStreamWrapper(org.bouncycastle.bcpg.ArmoredInputStream inputStream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()java.lang.StringgetArmorHeaderLine()java.lang.String[]getArmorHeaders()booleanisClearText()booleanisEndOfStream()voidmark(int readlimit)booleanmarkSupported()static java.io.InputStreampossiblyWrap(java.io.InputStream inputStream)intread()intread(byte[] b)intread(byte[] b, int off, int len)Reads up tolenbytes of data from the input stream into an array of bytes.voidreset()longskip(long n)
-
-
-
Method Detail
-
possiblyWrap
public static java.io.InputStream possiblyWrap(java.io.InputStream inputStream) throws java.io.IOException- Throws:
java.io.IOException
-
isClearText
public boolean isClearText()
- Overrides:
isClearTextin classorg.bouncycastle.bcpg.ArmoredInputStream
-
isEndOfStream
public boolean isEndOfStream()
- Overrides:
isEndOfStreamin classorg.bouncycastle.bcpg.ArmoredInputStream
-
getArmorHeaderLine
public java.lang.String getArmorHeaderLine()
- Overrides:
getArmorHeaderLinein classorg.bouncycastle.bcpg.ArmoredInputStream
-
getArmorHeaders
public java.lang.String[] getArmorHeaders()
- Overrides:
getArmorHeadersin classorg.bouncycastle.bcpg.ArmoredInputStream
-
read
public int read() throws java.io.IOException- Overrides:
readin classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
java.io.IOException
-
read
public int read(@Nonnull byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads up tolenbytes of data from the input stream into an array of bytes. An attempt is made to read as many aslenbytes, but a smaller number may be read. The number of bytes actually read is returned as an integer. The first byte read is stored into elementb[off], the next one intob[off+1], and so on. The number of bytes read is, at most, equal tolen. NOTE: We need to override the custom behavior of Java'sInputStream.read(byte[], int, int), as the upstream method silently swallowsIOExceptions. This would cause CRC checksum errors to go unnoticed.- Overrides:
readin classorg.bouncycastle.bcpg.ArmoredInputStream- Parameters:
b- byte arrayoff- offset at which we start writing data to the arraylen- number of bytes we write into the array- Returns:
- total number of bytes read into the buffer
- Throws:
java.io.IOException- if an exception happens AT ANY POINT- See Also:
- Related BC bug report
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.InputStream
-
reset
public void reset() throws java.io.IOException- Overrides:
resetin classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
-