You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2016/06/30 19:41:46 UTC
commons-crypto git commit: CRYPTO-93 add a factory method to provide
simpler API
Repository: commons-crypto
Updated Branches:
refs/heads/master b5e7b1b44 -> ae8e3506d
CRYPTO-93 add a factory method to provide simpler API
Added a parameterless ctor along the lines of the one in the cipher
factory. This will try to create the OPENSSL cipher and fall back to the
JAVA one.
Fixes #63
Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/ae8e3506
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/ae8e3506
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/ae8e3506
Branch: refs/heads/master
Commit: ae8e3506d40589962d4414b72cab53a9ca92212b
Parents: b5e7b1b
Author: Sebb <se...@apache.org>
Authored: Thu Jun 30 20:41:42 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Thu Jun 30 20:41:42 2016 +0100
----------------------------------------------------------------------
.../crypto/random/CryptoRandomFactory.java | 21 ++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/ae8e3506/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
index 4f3ca0c..272a4cc 100644
--- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
+++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
@@ -101,11 +101,12 @@ public class CryptoRandomFactory {
}
/**
- * The default value (OpenSslCryptoRandom,JavaCryptoRandom) for crypto cipher.
+ * The default value (OPENSSL,JAVA) used when creating a {@link CryptoCipher}.
*/
- private static final String SECURE_RANDOM_CLASSES_DEFAULT = RandomProvider
- .OPENSSL.getClassName().concat(",").concat(RandomProvider.JAVA
- .getClassName());
+ private static final String SECURE_RANDOM_CLASSES_DEFAULT =
+ RandomProvider.OPENSSL.getClassName()
+ .concat(",")
+ .concat(RandomProvider.JAVA.getClassName());
/**
* The private constructor of {@link CryptoRandomFactory}.
@@ -114,6 +115,18 @@ public class CryptoRandomFactory {
}
/**
+ * Gets a CryptoRandom instance using the default implementation
+ * as defined by {@link #SECURE_RANDOM_CLASSES_DEFAULT}
+ *
+ * @return CryptoRandom the cryptoRandom object.
+ * @throws GeneralSecurityException if cannot create the {@link CryptoRandom} class
+ */
+ public static CryptoRandom getCryptoRandom() throws GeneralSecurityException {
+ Properties properties = new Properties();
+ return getCryptoRandom(properties);
+ }
+
+ /**
* Gets a CryptoRandom instance for specified props.
* Uses the SECURE_RANDOM_CLASSES_KEY from the provided
* properties.