Package org.apache.commons.crypto.random
Class CryptoRandomFactory
java.lang.Object
org.apache.commons.crypto.random.CryptoRandomFactory
Creates
CryptoRandom instances-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines the internal CryptoRandom implementations. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringThe default value (OPENSSL,JAVA) used when creating aCryptoCipher.static final StringThe configuration key of the CryptoRandom implementation class.static final StringThe default value ("/dev/urandom") of the file path for secure random device.static final StringThe configuration key of the file path for secure random device.static final StringThe default value ("SHA1PRNG") of the algorithm of secure random.static final StringThe configuration key of the algorithm of secure random. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CryptoRandomGets a CryptoRandom instance using the default implementation as defined byCLASSES_DEFAULTstatic CryptoRandomgetCryptoRandom(Properties props) Gets a CryptoRandom instance for specified props.private static StringgetRandomClassString(Properties props) Gets the CryptoRandom class.
-
Field Details
-
DEVICE_FILE_PATH_KEY
The configuration key of the file path for secure random device.- See Also:
-
DEVICE_FILE_PATH_DEFAULT
The default value ("/dev/urandom") of the file path for secure random device.- See Also:
-
JAVA_ALGORITHM_KEY
The configuration key of the algorithm of secure random.- See Also:
-
JAVA_ALGORITHM_DEFAULT
The default value ("SHA1PRNG") of the algorithm of secure random.- See Also:
-
CLASSES_KEY
The configuration key of the CryptoRandom implementation class.The value of the CLASSES_KEY needs to be the full name of a class that implements the
CryptoRandominterface The internal classes are listed in the enumRandomProviderwhich 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:
-
CLASSES_DEFAULT
The default value (OPENSSL,JAVA) used when creating aCryptoCipher.
-
-
Constructor Details
-
CryptoRandomFactory
private CryptoRandomFactory()The private constructor ofCryptoRandomFactory.
-
-
Method Details
-
getCryptoRandom
Gets a CryptoRandom instance using the default implementation as defined byCLASSES_DEFAULT- Returns:
- CryptoRandom the cryptoRandom object.
- Throws:
GeneralSecurityException- if cannot create theCryptoRandomclass
-
getCryptoRandom
Gets a CryptoRandom instance for specified props. Uses the SECURE_RANDOM_CLASSES_KEY from the provided properties. If it is not set, then it checks the System properties. Failing that, it defaults to OpenSslCryptoRandom,JavaCryptoRandom The properties are passed to the generated class.- Parameters:
props- the configuration properties.- Returns:
- CryptoRandom the cryptoRandom object.
- Throws:
GeneralSecurityException- if cannot create theCryptoRandomclassIllegalArgumentException- if no classname(s) are provided
-
getRandomClassString
Gets the CryptoRandom class.- Parameters:
props- ThePropertiesclass represents a set of properties.- Returns:
- the CryptoRandom class based on the props.
-