Package org.pgpainless.util
Class CRCingArmoredInputStreamWrapper
java.lang.Object
java.io.InputStream
org.bouncycastle.bcpg.ArmoredInputStream
org.pgpainless.util.CRCingArmoredInputStreamWrapper
- All Implemented Interfaces:
Closeable,AutoCloseable
public class CRCingArmoredInputStreamWrapper
extends org.bouncycastle.bcpg.ArmoredInputStream
Utility 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
ConstructorsConstructorDescriptionCRCingArmoredInputStreamWrapper(org.bouncycastle.bcpg.ArmoredInputStream inputStream) -
Method Summary
Methods inherited from class org.bouncycastle.bcpg.ArmoredInputStream
setDetectMissingCRCMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
CRCingArmoredInputStreamWrapper
public CRCingArmoredInputStreamWrapper(org.bouncycastle.bcpg.ArmoredInputStream inputStream) throws IOException - Throws:
IOException
-
-
Method Details
-
isClearText
public boolean isClearText()- Overrides:
isClearTextin classorg.bouncycastle.bcpg.ArmoredInputStream
-
isEndOfStream
public boolean isEndOfStream()- Overrides:
isEndOfStreamin classorg.bouncycastle.bcpg.ArmoredInputStream
-
getArmorHeaderLine
- Overrides:
getArmorHeaderLinein classorg.bouncycastle.bcpg.ArmoredInputStream
-
getArmorHeaders
- Overrides:
getArmorHeadersin classorg.bouncycastle.bcpg.ArmoredInputStream
-
read
- Overrides:
readin classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
Reads 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:
IOException- if an exception happens AT ANY POINT- See Also:
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classorg.bouncycastle.bcpg.ArmoredInputStream- Throws:
IOException
-
mark
public void mark(int readlimit) - Overrides:
markin classInputStream
-
reset
- Overrides:
resetin classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-