Package org.alfresco.encryption
Class DecryptingInputStream
java.lang.Object
java.io.InputStream
org.alfresco.encryption.DecryptingInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An input stream that encrypts data produced by a
EncryptingOutputStream
. 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
ConstructorsConstructorDescriptionDecryptingInputStream
(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
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Constructor Details
-
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 Details
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-