Package org.apache.commons.crypto.cipher
Class CryptoCipherFactory
java.lang.Object
org.apache.commons.crypto.cipher.CryptoCipherFactory
Creates
CryptoCipher instances.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the internal CryptoCipher implementations. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFor AES, the algorithm block is fixed size of 128 bits.private static final StringThe default value (OPENSSL,JCE) for crypto cipher.static final StringThe configuration key of the CryptoCipher implementation class.static final StringThe configuration key of the provider class for JCE cipher. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringgetCipherClassString(Properties props) Gets the cipher class.static CryptoCiphergetCryptoCipher(String transformation) Gets a cipher for algorithm/mode/padding in config value commons.crypto.cipher.transformationstatic CryptoCiphergetCryptoCipher(String transformation, Properties properties) Gets a cipher instance for specified algorithm/mode/padding.
-
Field Details
-
JCE_PROVIDER_KEY
The configuration key of the provider class for JCE cipher.- See Also:
-
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
CryptoCipherinterface The internal classes are listed in the enumCipherProviderwhich 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:
-
AES_BLOCK_SIZE
public static final int AES_BLOCK_SIZEFor AES, the algorithm block is fixed size of 128 bits.- See Also:
-
CLASSES_DEFAULT
The default value (OPENSSL,JCE) for crypto cipher.
-
-
Constructor Details
-
CryptoCipherFactory
private CryptoCipherFactory()The private Constructor ofCryptoCipherFactory.
-
-
Method Details
-
getCipherClassString
Gets the cipher class.- Parameters:
props- ThePropertiesclass represents a set of properties.- Returns:
- the cipher class based on the props.
-
getCryptoCipher
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:
GeneralSecurityException- if JCE cipher initialize failed
-
getCryptoCipher
public static CryptoCipher getCryptoCipher(String transformation, Properties properties) throws GeneralSecurityException Gets a cipher instance for specified algorithm/mode/padding.- Parameters:
transformation- algorithm/mode/paddingproperties- the configuration properties - usesCLASSES_KEY- Returns:
- CryptoCipher the cipher (defaults to OpenSslCipher)
- Throws:
GeneralSecurityException- if cipher initialize failedIllegalArgumentException- if no classname(s) were provided
-