Package org.apache.fulcrum.jce.crypto
Class SmartDecryptingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.ByteArrayInputStream
-
- org.apache.fulcrum.jce.crypto.SmartDecryptingInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class SmartDecryptingInputStream extends ByteArrayInputStream
An input stream that determine if the originating input stream was encrypted or not. This magic only works for well-known file types though.- Author:
- Siegfried Goeschl
-
-
Field Summary
-
Fields inherited from class java.io.ByteArrayInputStream
buf, count, mark, pos
-
-
Constructor Summary
Constructors Constructor Description SmartDecryptingInputStream(CryptoStreamFactory cryptoStreamFactory, InputStream is)
ConstructorSmartDecryptingInputStream(CryptoStreamFactory cryptoStreamFactory, InputStream is, char[] password)
Constructor
-
Method Summary
Modifier and Type Method Description long
copy(InputStream is, OutputStream os)
Pumps the input stream to the output stream.-
Methods inherited from class java.io.ByteArrayInputStream
available, close, mark, markSupported, read, read, reset, skip
-
Methods inherited from class java.io.InputStream
read
-
-
-
-
Constructor Detail
-
SmartDecryptingInputStream
public SmartDecryptingInputStream(CryptoStreamFactory cryptoStreamFactory, InputStream is) throws IOException, GeneralSecurityException
Constructor- Parameters:
cryptoStreamFactory
- the CryptoStreamFactory for creating a cipher streamis
- the input stream to be decrypted- Throws:
IOException
- if file not foundGeneralSecurityException
- if security check fails
-
SmartDecryptingInputStream
public SmartDecryptingInputStream(CryptoStreamFactory cryptoStreamFactory, InputStream is, char[] password) throws IOException, GeneralSecurityException
Constructor- Parameters:
cryptoStreamFactory
- the CryptoStreamFactory for creating a cipher streamis
- the input stream to be decryptedpassword
- the password for decryption- Throws:
IOException
- if file not foundGeneralSecurityException
- if security check fails
-
-
Method Detail
-
copy
public long copy(InputStream is, OutputStream os) throws IOException
Pumps the input stream to the output stream.- Parameters:
is
- the source input streamos
- the target output stream- Returns:
- the number of bytes copied
- Throws:
IOException
- the copying failed
-
-