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
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
For AES, the algorithm block is fixed size of 128 bits.- See Also:
-
-
Method Details
-
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
-