|
||||||||||
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 JCE (Java Crypto Extension) either supplied by SUN (using SunJCE 1.42) or an custom provider such as BouncyCastle or the newer Cryptix libraries. The implementation uses as PBEWithMD5AndTripleDES 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,
java.lang.String algorithm,
java.lang.String providerName)
Constructor |
Method Summary | |
---|---|
java.io.InputStream |
getInputStream(java.io.InputStream is)
Creates a decrypting input stream. |
java.io.InputStream |
getInputStream(java.io.InputStream is,
char[] password)
Creates an decrypting input stream |
static CryptoStreamFactory |
getInstance()
Factory method to get a default instance |
java.io.OutputStream |
getOutputStream(java.io.OutputStream os,
char[] password)
Creates an encrypting output stream |
java.io.InputStream |
getSmartInputStream(java.io.InputStream is)
Creates a smart decrypting input stream. |
java.io.InputStream |
getSmartInputStream(java.io.InputStream is,
char[] password)
Creates an decrypting input stream |
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, java.lang.String algorithm, java.lang.String providerName)
salt
- the salt for the PBE algorithmcount
- the iteration for PBEParameterSpecalgorithm
- the algorithm to be usedproviderName
- the name of the JCE provide to b usedMethod Detail |
---|
public static CryptoStreamFactory getInstance()
public static void setInstance(CryptoStreamFactory instance)
instance
- the new default instancepublic java.io.InputStream getInputStream(java.io.InputStream is) throws java.security.GeneralSecurityException, java.io.IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrapped
java.security.GeneralSecurityException
- creating the input stream failed
java.io.IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream)
public java.io.InputStream getInputStream(java.io.InputStream is, char[] password) throws java.security.GeneralSecurityException, java.io.IOException
CryptoStreamFactory
getInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappedpassword
- the password to be used
java.security.GeneralSecurityException
- creating the input stream failed
java.io.IOException
- creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream,char[])
public java.io.InputStream getSmartInputStream(java.io.InputStream is) throws java.security.GeneralSecurityException, java.io.IOException
CryptoStreamFactory
getSmartInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrapped
java.security.GeneralSecurityException
- creating the input stream failed
java.io.IOException
- creating the input stream failedCryptoStreamFactory.getSmartInputStream(java.io.InputStream)
public java.io.InputStream getSmartInputStream(java.io.InputStream is, char[] password) throws java.security.GeneralSecurityException, java.io.IOException
CryptoStreamFactory
getSmartInputStream
in interface CryptoStreamFactory
is
- the input stream to be wrappedpassword
- the password to be used
java.security.GeneralSecurityException
- creating the input stream failed
java.io.IOException
- creating the input stream failedCryptoStreamFactory.getSmartInputStream(java.io.InputStream,char[])
public java.io.OutputStream getOutputStream(java.io.OutputStream os, char[] password) throws java.security.GeneralSecurityException, java.io.IOException
CryptoStreamFactory
getOutputStream
in interface CryptoStreamFactory
os
- the output stream to be wrappedpassword
- the password to be used
java.security.GeneralSecurityException
- creating the ouptut stream failed
java.io.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 |