public abstract class CryptoStreamFactoryJ8Template extends Object implements CryptoStreamFactoryJ8
| Modifier and Type | Field and Description |
|---|---|
protected String |
algorithm
the algorithm to use
|
protected int |
count
the count parameter for the algorithm, not used for GCM
|
protected static Map<CryptoParametersJ8.TYPES,CryptoStreamFactoryJ8Template> |
instances
the default instances
|
protected String |
providerName
the name of the JCE provider
|
protected static String |
PROVIDERNAME
The JCE provider name known to work.
|
protected byte[] |
salt
the salt for the algorithm
|
protected static int |
SALT_SIZE |
| Constructor and Description |
|---|
CryptoStreamFactoryJ8Template() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract byte[] |
createCipher(InputStream is,
int mode,
char[] password)
Create a Cipher.
|
protected abstract Key |
createKey(char[] password,
byte[] salt)
Create a PBE key.
|
protected static byte[] |
generateSalt()
creates salt from
SecureRandom.getInstance(String) by default was algorithm SHA1PRNG
changed to SecureRandom.getInstanceStrong() and let the system decide, what PRNG to use for salt random. |
String |
getAlgorithm()
Info about used algorithm.
|
int |
getCount() |
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)
not used / implemented methods
|
InputStream |
getInputStream(InputStream is,
String decryptionMode,
char[] password)
Creates input stream based on the decryption mode
using the given password.
|
static CryptoStreamFactoryJ8 |
getInstance()
Factory method to get a default instance
creating instance of type
CryptoParametersJ8.DEFAULT_TYPE. |
static CryptoStreamFactoryJ8 |
getInstance(CryptoParametersJ8.TYPES type)
Factory method to get a default instance
|
static CryptoStreamFactoryJ8 |
getInstance(CryptoParametersJ8.TYPES type,
byte[] salt,
int count)
Factory method to get a default instance
|
OutputStream |
getOutputStream(InputStream is,
OutputStream os,
char[] password)
Creates an encrypting output stream using the given password.
|
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.
|
String |
getProviderName() |
byte[] |
getSalt() |
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.
|
CryptoParametersJ8.TYPES |
getType() |
static void |
resetInstances()
resets the default instances
|
void |
setAlgorithm(String algorithm) |
void |
setCount(int count) |
void |
setProviderName(String providerName) |
protected void |
setSalt(byte[] salt) |
void |
setType(CryptoParametersJ8.TYPES type) |
protected byte[] salt
protected int count
protected String providerName
protected String algorithm
protected static final String PROVIDERNAME
protected static final int SALT_SIZE
protected static final Map<CryptoParametersJ8.TYPES,CryptoStreamFactoryJ8Template> instances
public CryptoParametersJ8.TYPES getType()
public void setType(CryptoParametersJ8.TYPES type)
public static CryptoStreamFactoryJ8 getInstance()
CryptoParametersJ8.DEFAULT_TYPE.public static CryptoStreamFactoryJ8 getInstance(CryptoParametersJ8.TYPES type)
type - the @see CryptoParametersJ8.TYPES of the instance.public static CryptoStreamFactoryJ8 getInstance(CryptoParametersJ8.TYPES type, byte[] salt, int count)
type - the @see CryptoParametersJ8.TYPES of the instance.salt - provided saltcount - provided count, used only for CryptoParametersJ8.TYPES.PBE.public InputStream getSmartInputStream(InputStream is) throws GeneralSecurityException, IOException
CryptoStreamFactorygetSmartInputStream in interface CryptoStreamFactoryis - the input stream to be wrappedGeneralSecurityException - creating the input stream failedIOException - creating the input stream failedCryptoStreamFactory.getSmartInputStream(java.io.InputStream)public InputStream getInputStream(InputStream is, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactorygetInputStream in interface CryptoStreamFactoryis - the input stream to be wrappedpassword - the password to be usedGeneralSecurityException - creating the input stream failedIOException - creating the input stream failedCryptoStreamFactory.getInputStream(java.io.InputStream,char[])public OutputStream getOutputStream(InputStream is, OutputStream os, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactoryJ8getOutputStream in interface CryptoStreamFactoryJ8is - the input stream to be encodedos - the output stream to be wrappedpassword - the password to be usedGeneralSecurityException - creating the output stream failedIOException - creating the output stream failedCryptoStreamFactoryJ8.getOutputStream(InputStream, OutputStream, char[])public static void resetInstances()
public InputStream getInputStream(InputStream is, String decryptionMode) throws GeneralSecurityException, IOException
getInputStream in interface CryptoStreamFactoryis - the input stream to be wrappeddecryptionMode - the decryption mode (true|false|auto)GeneralSecurityException - creating the input stream failedIOException - creating the input stream failedpublic InputStream getInputStream(InputStream is, String decryptionMode, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactorygetInputStream in interface CryptoStreamFactoryis - the input stream to be wrappeddecryptionMode - the decryption mode (true|false|auto)password - the password to be usedGeneralSecurityException - creating the input stream failedIOException - creating the input stream failedpublic InputStream getInputStream(InputStream is) throws GeneralSecurityException, IOException
CryptoStreamFactorygetInputStream in interface CryptoStreamFactoryis - the input stream to be wrappedGeneralSecurityException - creating the input stream failedIOException - creating the input stream failedpublic InputStream getSmartInputStream(InputStream is, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactorygetSmartInputStream in interface CryptoStreamFactoryis - the input stream to be wrappedpassword - the password to be usedGeneralSecurityException - creating the input stream failedIOException - creating the input stream failedpublic OutputStream getOutputStream(OutputStream os) throws GeneralSecurityException, IOException
CryptoStreamFactorygetOutputStream in interface CryptoStreamFactoryos - the output stream to be wrappedGeneralSecurityException - creating the output stream failedIOException - creating the output stream failedpublic OutputStream getOutputStream(OutputStream os, char[] password) throws GeneralSecurityException, IOException
CryptoStreamFactorygetOutputStream in interface CryptoStreamFactoryos - the output stream to be wrappedpassword - the password to be usedGeneralSecurityException - creating the output stream failedIOException - creating the output stream failedprotected abstract Key createKey(char[] password, byte[] salt) throws GeneralSecurityException
password - the password to use.salt - if provided this is used, otherweise getSalt().GeneralSecurityException - creating the key failedprotected abstract byte[] createCipher(InputStream is, int mode, char[] password) throws GeneralSecurityException, IOException
is - the input streammode - the cipher modepassword - the passwordGeneralSecurityException - creating a cipher failedIOException - creating a cipher failedprotected static byte[] generateSalt()
throws GeneralSecurityException
SecureRandom.getInstance(String) by default was algorithm SHA1PRNG
changed to SecureRandom.getInstanceStrong() and let the system decide, what PRNG to use for salt random.
salt size is by default @link 16.GeneralSecurityException - if no algo could be found.public byte[] getSalt()
protected void setSalt(byte[] salt)
public int getCount()
public void setCount(int count)
public String getProviderName()
public void setProviderName(String providerName)
public String getAlgorithm()
CryptoStreamFactorygetAlgorithm in interface CryptoStreamFactorypublic void setAlgorithm(String algorithm)
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.