Package org.alfresco.encryption
Class DecryptingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.alfresco.encryption.DecryptingInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class DecryptingInputStream extends InputStream
An input stream that encrypts data produced by aEncryptingOutputStream
. A lightweight yet secure hybrid encryption scheme is used. A random symmetric key is decrypted using the receiver's private key. The supplied data is then decrypted using the symmetric key and read on a streaming basis. When the end of the stream is reached or the stream is closed, a HMAC checksum of the entire stream contents is validated.
-
-
Constructor Summary
Constructors Constructor Description DecryptingInputStream(InputStream wrapped, PrivateKey privKey)
Constructs a DecryptingInputStream using default symmetric encryption parameters.DecryptingInputStream(InputStream wrapped, PrivateKey privKey, String algorithm, String mode, String padding)
Constructs a DecryptingInputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
available()
void
close()
int
read()
int
read(byte[] b)
int
read(byte[] b, int off, int len)
-
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
DecryptingInputStream
public DecryptingInputStream(InputStream wrapped, PrivateKey privKey) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchProviderException
Constructs a DecryptingInputStream using default symmetric encryption parameters.- Parameters:
wrapped
- the input stream to decryptprivKey
- the receiver's private key for decrypting the symmetric key- Throws:
IOException
- Signals that an I/O exception has occurred.NoSuchAlgorithmException
- the no such algorithm exceptionNoSuchPaddingException
- the no such padding exceptionInvalidKeyException
- the invalid key exceptionIllegalBlockSizeException
- the illegal block size exceptionBadPaddingException
- the bad padding exceptionInvalidAlgorithmParameterException
- the invalid algorithm parameter exceptionNoSuchProviderException
- the no such provider exception
-
DecryptingInputStream
public DecryptingInputStream(InputStream wrapped, PrivateKey privKey, String algorithm, String mode, String padding) throws IOException, NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException, InvalidAlgorithmParameterException, NoSuchProviderException
Constructs a DecryptingInputStream.- Parameters:
wrapped
- the input stream to decryptprivKey
- the receiver's private key for decrypting the symmetric keyalgorithm
- encryption algorithm (e.g. "AES")mode
- encryption mode (e.g. "CBC")padding
- padding scheme (e.g. "PKCS5PADDING")- Throws:
IOException
- Signals that an I/O exception has occurred.NoSuchAlgorithmException
- the no such algorithm exceptionNoSuchPaddingException
- the no such padding exceptionInvalidKeyException
- the invalid key exceptionIllegalBlockSizeException
- the illegal block size exceptionBadPaddingException
- the bad padding exceptionInvalidAlgorithmParameterException
- the invalid algorithm parameter exceptionNoSuchProviderException
- the no such provider exception
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classInputStream
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
-