Package org.alfresco.encryption
Class DecryptingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.alfresco.encryption.DecryptingInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class DecryptingInputStream extends java.io.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(java.io.InputStream wrapped, java.security.PrivateKey privKey)
Constructs a DecryptingInputStream using default symmetric encryption parameters.DecryptingInputStream(java.io.InputStream wrapped, java.security.PrivateKey privKey, java.lang.String algorithm, java.lang.String mode, java.lang.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)
-
-
-
Constructor Detail
-
DecryptingInputStream
public DecryptingInputStream(java.io.InputStream wrapped, java.security.PrivateKey privKey) throws java.io.IOException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.InvalidKeyException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.security.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:
java.io.IOException
- Signals that an I/O exception has occurred.java.security.NoSuchAlgorithmException
- the no such algorithm exceptionjavax.crypto.NoSuchPaddingException
- the no such padding exceptionjava.security.InvalidKeyException
- the invalid key exceptionjavax.crypto.IllegalBlockSizeException
- the illegal block size exceptionjavax.crypto.BadPaddingException
- the bad padding exceptionjava.security.InvalidAlgorithmParameterException
- the invalid algorithm parameter exceptionjava.security.NoSuchProviderException
- the no such provider exception
-
DecryptingInputStream
public DecryptingInputStream(java.io.InputStream wrapped, java.security.PrivateKey privKey, java.lang.String algorithm, java.lang.String mode, java.lang.String padding) throws java.io.IOException, java.security.NoSuchAlgorithmException, javax.crypto.NoSuchPaddingException, java.security.InvalidKeyException, javax.crypto.IllegalBlockSizeException, javax.crypto.BadPaddingException, java.security.InvalidAlgorithmParameterException, java.security.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:
java.io.IOException
- Signals that an I/O exception has occurred.java.security.NoSuchAlgorithmException
- the no such algorithm exceptionjavax.crypto.NoSuchPaddingException
- the no such padding exceptionjava.security.InvalidKeyException
- the invalid key exceptionjavax.crypto.IllegalBlockSizeException
- the illegal block size exceptionjavax.crypto.BadPaddingException
- the bad padding exceptionjava.security.InvalidAlgorithmParameterException
- the invalid algorithm parameter exceptionjava.security.NoSuchProviderException
- the no such provider exception
-
-
Method Detail
-
read
public int read() throws java.io.IOException
- Specified by:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException
- Overrides:
available
in classjava.io.InputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-