Package org.apache.commons.crypto.cipher
Class CryptoCipherFactory
- java.lang.Object
-
- org.apache.commons.crypto.cipher.CryptoCipherFactory
-
public class CryptoCipherFactory extends java.lang.Object
CreatesCryptoCipher
instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CryptoCipherFactory.CipherProvider
Defines the internal CryptoCipher implementations.
-
Field Summary
Fields Modifier and Type Field Description static int
AES_BLOCK_SIZE
For AES, the algorithm block is fixed size of 128 bits.private static java.lang.String
CLASSES_DEFAULT
The default value (OPENSSL,JCE) for crypto cipher.static java.lang.String
CLASSES_KEY
The configuration key of the CryptoCipher implementation class.static java.lang.String
JCE_PROVIDER_KEY
The configuration key of the provider class for JCE cipher.
-
Constructor Summary
Constructors Modifier Constructor Description private
CryptoCipherFactory()
The private Constructor ofCryptoCipherFactory
.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getCipherClassString(java.util.Properties props)
Gets the cipher class.static CryptoCipher
getCryptoCipher(java.lang.String transformation)
Gets a cipher for algorithm/mode/padding in config value commons.crypto.cipher.transformationstatic CryptoCipher
getCryptoCipher(java.lang.String transformation, java.util.Properties properties)
Gets a cipher instance for specified algorithm/mode/padding.
-
-
-
Field Detail
-
JCE_PROVIDER_KEY
public static final java.lang.String JCE_PROVIDER_KEY
The configuration key of the provider class for JCE cipher.- See Also:
- Constant Field Values
-
CLASSES_KEY
public static final java.lang.String CLASSES_KEY
The configuration key of the CryptoCipher implementation class.The value of CLASSES_KEY needs to be the full name of a class that implements the
CryptoCipher
interface The internal classes are listed in the enumCipherProvider
which can be used to obtain the full class name.The value can also be a comma-separated list of class names in order of descending priority.
- See Also:
- Constant Field Values
-
AES_BLOCK_SIZE
public static final int AES_BLOCK_SIZE
For AES, the algorithm block is fixed size of 128 bits.
-
CLASSES_DEFAULT
private static final java.lang.String CLASSES_DEFAULT
The default value (OPENSSL,JCE) for crypto cipher.
-
-
Constructor Detail
-
CryptoCipherFactory
private CryptoCipherFactory()
The private Constructor ofCryptoCipherFactory
.
-
-
Method Detail
-
getCipherClassString
private static java.lang.String getCipherClassString(java.util.Properties props)
Gets the cipher class.- Parameters:
props
- TheProperties
class represents a set of properties.- Returns:
- the cipher class based on the props.
-
getCryptoCipher
public static CryptoCipher getCryptoCipher(java.lang.String transformation) throws java.security.GeneralSecurityException
Gets a cipher for algorithm/mode/padding in config value commons.crypto.cipher.transformation- Parameters:
transformation
- the name of the transformation, e.g., AES/CBC/PKCS5Padding. See the Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard transformation names.- Returns:
- CryptoCipher the cipher object (defaults to OpenSslCipher if available, else JceCipher)
- Throws:
java.security.GeneralSecurityException
- if JCE cipher initialize failed
-
getCryptoCipher
public static CryptoCipher getCryptoCipher(java.lang.String transformation, java.util.Properties properties) throws java.security.GeneralSecurityException
Gets a cipher instance for specified algorithm/mode/padding.- Parameters:
properties
- the configuration properties - usesCLASSES_KEY
transformation
- algorithm/mode/padding- Returns:
- CryptoCipher the cipher (defaults to OpenSslCipher)
- Throws:
java.security.GeneralSecurityException
- if cipher initialize failedjava.lang.IllegalArgumentException
- if no classname(s) were provided
-
-