|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fulcrum.jce.crypto.CryptoStreamFactoryImpl
public final class CryptoStreamFactoryImpl
Concrete factory for creating encrypting/decrypting streams. The implementation uses the JCA (Java Crypto Extension) supplied by SUN (using SunJCE 1.42). The implementation uses as PBEWithMD5AndDES for encryption which should be sufficent for most applications. The implementation also supplies a default password in the case that the programmer don't want to have additional hassles. It is easy to reengineer the password being used but much better than a hard-coded password in the application. The code uses parts from Markus Hahn's Blowfish library found at http://blowfishj.sourceforge.net/
Constructor Summary | |
---|---|
CryptoStreamFactoryImpl()
Constructor |
|
CryptoStreamFactoryImpl(byte[] salt,
int count)
Constructor |
Method Summary | |
---|---|
InputStream |
getInputStream(InputStream is)
Creates a decrypting input stream using the default password. |
InputStream |
getInputStream(InputStream is,
char[] password)
Creates an decrypting input stream using a given password. |
InputStream |
getInputStream(InputStream is,
String decryptionMode)
Creates input stream based on the decryption mode using the default password. |
InputStream |
getInputStream(InputStream is,
String decryptionMode,
char[] password)
Creates input stream based on the decryption mode using the given password. |
static CryptoStreamFactory |
getInstance()
Factory method to get a default instance |
OutputStream |
getOutputStream(OutputStream os)
Creates an encrypting output stream using the default password. |
OutputStream |
getOutputStream(OutputStream os,
char[] password)
Creates an encrypting output stream using the given password. |
InputStream |
getSmartInputStream(InputStream is)
Creates a smart decrypting input stream using the default password. |
InputStream |
getSmartInputStream(InputStream is,
char[] password)
Creates a smart decrypting input stream using a given password. |
static void |
setInstance(CryptoStreamFactory instance)
Set the default instance from an external application. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CryptoStreamFactoryImpl()
public CryptoStreamFactoryImpl(byte[] salt, int count)
salt
- the salt for the PBE algorithmcount
- the iteration for PBEParameterSpecMethod Detail |
---|
public static CryptoStreamFactory getInstance()
public static void setInstance(CryptoStreamFactory instance)
instance
- the new default instancepublic InputStream getInputStream(InputStream is, String decryptionMode) throws GeneralSecurityException, IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappeddecryptionMode
- the decryption mode (true|false|auto)
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream, String)
public InputStream getInputStream(InputStream is, String decryptionMode, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappeddecryptionMode
- the decryption mode (true|false|auto)password
- the password to be used
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream, String, char[])
public InputStream getInputStream(InputStream is) throws GeneralSecurityException, IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrapped
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream)
public InputStream getInputStream(InputStream is, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappedpassword
- the password to be used
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream,char[])
public InputStream getSmartInputStream(InputStream is) throws GeneralSecurityException, IOException
CryptoStreamFactory
getSmartInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrapped
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getSmartInputStream(java.io.InputStream)
public InputStream getSmartInputStream(InputStream is, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactory
getSmartInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappedpassword
- the password to be used
GeneralSecurityException
- creating the input stream failed
IOException
- creating the input stream failedCryptoStreamFactory.getSmartInputStream(java.io.InputStream,char[])
public OutputStream getOutputStream(OutputStream os) throws GeneralSecurityException, IOException
CryptoStreamFactory
getOutputStream
in interface CryptoStreamFactory
os
- the output stream to be wrapped
GeneralSecurityException
- creating the ouptut stream failed
IOException
- creating the ouptut stream failedCryptoStreamFactory.getOutputStream(java.io.OutputStream)
public OutputStream getOutputStream(OutputStream os, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactory
getOutputStream
in interface CryptoStreamFactory
os
- the output stream to be wrappedpassword
- the password to be used
GeneralSecurityException
- creating the ouptut stream failed
IOException
- creating the ouptut stream failedCryptoStreamFactory.getOutputStream(java.io.OutputStream, char[])
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |