Repository: commons-crypto Updated Branches: refs/heads/master 7274287f3 -> 8997a623e
CRYPTO-105 Eliminate Configuration class Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/8997a623 Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/8997a623 Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/8997a623 Branch: refs/heads/master Commit: 8997a623e8608474db886e53bb8cb19d1a51b33f Parents: 7274287 Author: Sebb <[email protected]> Authored: Tue Jul 5 13:41:55 2016 +0100 Committer: Sebb <[email protected]> Committed: Tue Jul 5 13:41:55 2016 +0100 ---------------------------------------------------------------------- .../java/org/apache/commons/crypto/Crypto.java | 26 +++- .../apache/commons/crypto/NativeCodeLoader.java | 7 +- .../crypto/cipher/CryptoCipherFactory.java | 38 ++++-- .../apache/commons/crypto/cipher/JceCipher.java | 5 +- .../commons/crypto/conf/ConfigurationKeys.java | 133 ------------------- .../commons/crypto/conf/package-info.java | 22 --- .../crypto/random/CryptoRandomFactory.java | 64 +++++++-- .../commons/crypto/random/JavaCryptoRandom.java | 10 +- .../commons/crypto/random/OsCryptoRandom.java | 9 +- .../crypto/stream/CryptoInputStream.java | 18 ++- .../org/apache/commons/crypto/utils/Utils.java | 19 ++- .../commons/crypto/AbstractBenchmark.java | 5 +- .../crypto/cipher/AbstractCipherTest.java | 3 +- .../crypto/cipher/CryptoCipherFactoryTest.java | 6 +- .../crypto/examples/CipherByteArrayExample.java | 6 +- .../commons/crypto/examples/RandomExample.java | 3 +- .../crypto/jna/OpenSslJnaCryptoRandomTest.java | 3 +- .../crypto/random/CryptoRandomFactoryTest.java | 9 +- .../crypto/random/JavaCryptoRandomTest.java | 3 +- .../crypto/random/OpensslCryptoRandomTest.java | 3 +- .../crypto/random/OsCryptoRandomTest.java | 4 +- 21 files changed, 165 insertions(+), 231 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/Crypto.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/Crypto.java b/src/main/java/org/apache/commons/crypto/Crypto.java index 4fc6ccf..4fb455e 100644 --- a/src/main/java/org/apache/commons/crypto/Crypto.java +++ b/src/main/java/org/apache/commons/crypto/Crypto.java @@ -18,11 +18,34 @@ package org.apache.commons.crypto; /** - * Provides diagnostic information about Commons Crypto. + * Provides diagnostic information about Commons Crypto and keys for native class loading */ public final class Crypto { /** + * The prefix of all crypto configuration keys + */ + public static final String CONF_PREFIX = "commons.crypto."; + + // native lib related configuration keys + /** + * The configuration key of the path for loading crypto library. + */ + public static final String LIB_PATH_KEY = Crypto.CONF_PREFIX + + "lib.path"; + /** + * The configuration key of the file name for loading crypto library. + */ + public static final String LIB_NAME_KEY = Crypto.CONF_PREFIX + + "lib.name"; + /** + * The configuration key of temp directory for extracting crypto library. + * Defaults to "java.io.tempdir" if not found. + */ + public static final String LIB_TEMPDIR_KEY = Crypto.CONF_PREFIX + + "lib.tempdir"; + + /** * Gets the currently active version of Apache Commons Crypto. * * @return the version @@ -39,4 +62,5 @@ public final class Crypto { public static boolean isNativeCodeLoaded() { return NativeCodeLoader.isNativeCodeLoaded(); } + } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java index 1a4725e..fa7c436 100644 --- a/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java +++ b/src/main/java/org/apache/commons/crypto/NativeCodeLoader.java @@ -27,7 +27,6 @@ import java.net.URL; import java.util.Properties; import java.util.UUID; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.utils.IoUtils; import org.apache.commons.crypto.utils.Utils; @@ -78,8 +77,8 @@ final class NativeCodeLoader { final Properties props = Utils.getDefaultProperties(); // Try to load the library in commons-crypto.lib.path */ - String nativeLibraryPath = props.getProperty(ConfigurationKeys.LIB_PATH_KEY); - String nativeLibraryName = props.getProperty(ConfigurationKeys.LIB_NAME_KEY); + String nativeLibraryPath = props.getProperty(Crypto.LIB_PATH_KEY); + String nativeLibraryName = props.getProperty(Crypto.LIB_NAME_KEY); // Resolve the library file name with a suffix (e.g., dll, .so, etc.) if (nativeLibraryName == null) { @@ -115,7 +114,7 @@ final class NativeCodeLoader { // Temporary folder for the native lib. Use the value of // commons-crypto.tempdir or java.io.tmpdir - String tempFolder = new File(props.getProperty(ConfigurationKeys.LIB_TEMPDIR_KEY, + String tempFolder = new File(props.getProperty(Crypto.LIB_TEMPDIR_KEY, System.getProperty("java.io.tmpdir"))).getAbsolutePath(); // Extract and load a native library inside the jar file http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java index 6c19101..5d5b789 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java +++ b/src/main/java/org/apache/commons/crypto/cipher/CryptoCipherFactory.java @@ -20,7 +20,7 @@ package org.apache.commons.crypto.cipher; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; +import org.apache.commons.crypto.Crypto; import org.apache.commons.crypto.utils.ReflectionUtils; import org.apache.commons.crypto.utils.Utils; @@ -30,12 +30,34 @@ import org.apache.commons.crypto.utils.Utils; public class CryptoCipherFactory { /** + * The configuration key of the provider class for JCE cipher. + */ + public static final String JCE_PROVIDER_KEY = Crypto.CONF_PREFIX + + "cipher.jce.provider"; + /** + * The configuration key of the CryptoCipher implementation class. + * <p> + * The value of CLASSES_KEY needs to be the full name of a + * class that implements the + * {@link org.apache.commons.crypto.cipher.CryptoCipher CryptoCipher} interface + * The internal classes are listed in the enum + * {@link CipherProvider CipherProvider} + * which can be used to obtain the full class name. + * <p> + * The value can also be a comma-separated list of class names in + * order of descending priority. + */ + + public static final String CLASSES_KEY = Crypto.CONF_PREFIX + + "cipher.classes"; + + /** * Defines the internal CryptoCipher implementations. * <p> * Usage: * <p> * <blockquote><pre> - * props.setProperty(CIPHER_CLASSES_KEY, CipherProvider.OPENSSL.getClassName()); + * props.setProperty(CryptoCipherFactory.CLASSES_KEY, CipherProvider.OPENSSL.getClassName()); * props.setProperty(...); // if required by the implementation * cipher = CryptoCipherFactory.getInstance(transformation, props); * </pre></blockquote> @@ -49,11 +71,11 @@ public class CryptoCipherFactory { */ // Please ensure the property description agrees with the implementation OPENSSL(OpenSslCipher.class), - + /** * The JCE cipher implementation from the JVM * <p> - * uses the property {@link ConfigurationKeys#CIPHER_JCE_PROVIDER_KEY} + * uses the property {@link #JCE_PROVIDER_KEY} * to define the provider name, if present. */ // Please ensure the property description agrees with the implementation @@ -90,7 +112,7 @@ public class CryptoCipherFactory { /** * The default value (OPENSSL,JCE) for crypto cipher. */ - private static final String CIPHER_CLASSES_DEFAULT = + private static final String CLASSES_DEFAULT = CipherProvider.OPENSSL.getClassName() .concat(",") .concat(CipherProvider.JCE.getClassName()); @@ -104,7 +126,7 @@ public class CryptoCipherFactory { /** * Gets a cipher instance for specified algorithm/mode/padding. * - * @param props the configuration properties (uses ConfigurationKeys.CIPHER_CLASSES_KEY) + * @param props the configuration properties - uses {@link #CLASSES_KEY} * @param transformation algorithm/mode/padding * @return CryptoCipher the cipher (defaults to OpenSslCipher) * @throws GeneralSecurityException if cipher initialize failed @@ -164,9 +186,9 @@ public class CryptoCipherFactory { * @return the cipher class based on the props. */ private static String getCipherClassString(Properties props) { - String cipherClassString = props.getProperty(ConfigurationKeys.CIPHER_CLASSES_KEY, CIPHER_CLASSES_DEFAULT); + String cipherClassString = props.getProperty(CryptoCipherFactory.CLASSES_KEY, CLASSES_DEFAULT); if (cipherClassString.isEmpty()) { // TODO does it make sense to treat the empty string as the default? - cipherClassString = CIPHER_CLASSES_DEFAULT; + cipherClassString = CLASSES_DEFAULT; } return cipherClassString; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java index c4a8654..a6b64fd 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java +++ b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java @@ -30,7 +30,6 @@ import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.ShortBufferException; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.utils.Utils; /** @@ -42,7 +41,7 @@ class JceCipher implements CryptoCipher { /** * Constructs a {@link CryptoCipher} based on JCE Cipher {@link Cipher}. * - * @param props properties for JCE cipher (only uses {@link ConfigurationKeys#CIPHER_JCE_PROVIDER_KEY}) + * @param props properties for JCE cipher (only uses {@link CryptoCipherFactory#JCE_PROVIDER_KEY}) * @param transformation transformation for JCE cipher (algorithm/mode/padding) * @throws GeneralSecurityException if JCE cipher initialize failed */ @@ -50,7 +49,7 @@ class JceCipher implements CryptoCipher { // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider public JceCipher(Properties props, String transformation) throws GeneralSecurityException { - final String provider = props.getProperty(ConfigurationKeys.CIPHER_JCE_PROVIDER_KEY); + final String provider = props.getProperty(CryptoCipherFactory.JCE_PROVIDER_KEY); if (provider == null || provider.isEmpty()) { cipher = Cipher.getInstance(transformation); } else { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java b/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java deleted file mode 100644 index b69b89f..0000000 --- a/src/main/java/org/apache/commons/crypto/conf/ConfigurationKeys.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.crypto.conf; - -/** - * The ConfigurationKeys contains Configuration keys and default values. - */ -public class ConfigurationKeys { - - /** - * The prefix of crypto configuration. - */ - public static final String CONF_PREFIX = "commons.crypto."; - - /** - * The filename of configuration file. - */ - public static final String SYSTEM_PROPERTIES_FILE = CONF_PREFIX - + "properties"; - - /** - * The configuration key of the CryptoCipher implementation class. - * <p> - * The value of CIPHER_CLASSES_KEY needs to be the full name of a - * class that implements the - * {@link org.apache.commons.crypto.cipher.CryptoCipher CryptoCipher} interface - * The internal classes are listed in the enum - * {@link org.apache.commons.crypto.cipher.CryptoCipherFactory.CipherProvider CipherProvider} - * which can be used to obtain the full class name. - * <p> - * The value can also be a comma-separated list of class names in - * order of descending priority. - */ - public static final String CIPHER_CLASSES_KEY = CONF_PREFIX - + "cipher.classes"; - - /** - * The configuration key of the provider class for JCE cipher. - */ - public static final String CIPHER_JCE_PROVIDER_KEY = CONF_PREFIX - + "cipher.jce.provider"; - - // security random related configuration keys - /** - * The configuration key of the file path for secure random device. - */ - public static final String SECURE_RANDOM_DEVICE_FILE_PATH_KEY = CONF_PREFIX - + "secure.random.device.file.path"; - - /** - * The default value ({@value}) of the file path for secure random device. - */ - public static final String SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT = "/dev/urandom"; - - /** - * The configuration key of the algorithm of secure random. - */ - public static final String SECURE_RANDOM_JAVA_ALGORITHM_KEY = CONF_PREFIX - + "secure.random.java.algorithm"; - - /** - * The default value ({@value}) of the algorithm of secure random. - */ - public static final String SECURE_RANDOM_JAVA_ALGORITHM_DEFAULT = "SHA1PRNG"; - - /** - * The configuration key of the CryptoRandom implementation class. - * <p> - * The value of SECURE_RANDOM_CLASSES_KEY needs to be the full name of a - * class that implements the - * {@link org.apache.commons.crypto.random.CryptoRandom CryptoRandom} interface - * The internal classes are listed in the enum - * {@link org.apache.commons.crypto.random.CryptoRandomFactory.RandomProvider RandomProvider} - * which can be used to obtain the full class name. - * <p> - * The value can also be a comma-separated list of class names in - * order of descending priority. - */ - public static final String SECURE_RANDOM_CLASSES_KEY = CONF_PREFIX - + "secure.random.classes"; - - /** - * The configuration key of the buffer size for stream. - */ - public static final String STREAM_BUFFER_SIZE_KEY = CONF_PREFIX - + "stream.buffer.size"; - - // stream related configuration keys - /** - * The default value of the buffer size for stream. - */ - public static final int STREAM_BUFFER_SIZE_DEFAULT = 8192; - - // native lib related configuration keys - /** - * The configuration key of the path for loading crypto library. - */ - public static final String LIB_PATH_KEY = CONF_PREFIX - + "lib.path"; - - /** - * The configuration key of the file name for loading crypto library. - */ - public static final String LIB_NAME_KEY = CONF_PREFIX - + "lib.name"; - - /** - * The configuration key of temp directory for extracting crypto library. - */ - public static final String LIB_TEMPDIR_KEY = CONF_PREFIX - + "lib.tempdir"; - - /** - * The private constructor of {@link ConfigurationKeys}. - */ - private ConfigurationKeys() { - } -} http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/conf/package-info.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/conf/package-info.java b/src/main/java/org/apache/commons/crypto/conf/package-info.java deleted file mode 100644 index 6e340a9..0000000 --- a/src/main/java/org/apache/commons/crypto/conf/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Configuration classes - */ -package org.apache.commons.crypto.conf; - http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/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 272a4cc..83e7d37 100644 --- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java +++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java @@ -20,7 +20,7 @@ package org.apache.commons.crypto.random; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; +import org.apache.commons.crypto.Crypto; import org.apache.commons.crypto.utils.ReflectionUtils; import org.apache.commons.crypto.utils.Utils; @@ -29,13 +29,53 @@ import org.apache.commons.crypto.utils.Utils; */ public class CryptoRandomFactory { + // security random related configuration keys + /** + * The configuration key of the file path for secure random device. + */ + public static final String DEVICE_FILE_PATH_KEY = Crypto.CONF_PREFIX + + "secure.random.device.file.path"; + + /** + * The default value ({@value}) of the file path for secure random device. + */ + // Note: this is public mainly for use by the Javadoc + public static final String DEVICE_FILE_PATH_DEFAULT = "/dev/urandom"; + + /** + * The configuration key of the algorithm of secure random. + */ + public static final String JAVA_ALGORITHM_KEY = Crypto.CONF_PREFIX + + "secure.random.java.algorithm"; + + /** + * The default value ({@value}) of the algorithm of secure random. + */ + // Note: this is public mainly for use by the Javadoc + public static final String JAVA_ALGORITHM_DEFAULT = "SHA1PRNG"; + + /** + * The configuration key of the CryptoRandom implementation class. + * <p> + * The value of the CLASSES_KEY needs to be the full name of a + * class that implements the + * {@link org.apache.commons.crypto.random.CryptoRandom CryptoRandom} interface + * The internal classes are listed in the enum + * {@link RandomProvider RandomProvider} + * which can be used to obtain the full class name. + * <p> + * The value can also be a comma-separated list of class names in + * order of descending priority. + */ + public static final String CLASSES_KEY = Crypto.CONF_PREFIX + + "secure.random.classes"; /** * Defines the internal CryptoRandom implementations. * <p> * Usage: * <p> * <blockquote><pre> - * props.setProperty(RANDOM_CLASSES_KEY, RandomProvider.OPENSSL.getClassName()); + * props.setProperty(CryptoRandomFactory.CLASSES_KEY, RandomProvider.OPENSSL.getClassName()); * props.setProperty(...); // if required by the implementation * random = CryptoRandomFactory.getCryptoRandom(transformation, props); * </pre></blockquote> @@ -54,10 +94,10 @@ public class CryptoRandomFactory { /** * The SecureRandom implementation from the JVM * <p> - * Uses the property with key - * {@link ConfigurationKeys#SECURE_RANDOM_JAVA_ALGORITHM_KEY SECURE_RANDOM_JAVA_ALGORITHM_KEY} - * with the default of - * {@link ConfigurationKeys#SECURE_RANDOM_JAVA_ALGORITHM_DEFAULT SECURE_RANDOM_JAVA_ALGORITHM_DEFAULT} + * Uses the property with key + * {@link #JAVA_ALGORITHM_KEY} + * with the default of + * {@link #JAVA_ALGORITHM_DEFAULT} */ // Please ensure the property description agrees with the implementation JAVA(JavaCryptoRandom.class), @@ -65,9 +105,9 @@ public class CryptoRandomFactory { /** * The OS random device implementation. May not be available on some OSes. * <p> - * Uses {@link ConfigurationKeys#SECURE_RANDOM_DEVICE_FILE_PATH_KEY} to determine the + * Uses {@link #DEVICE_FILE_PATH_KEY} to determine the * path to the random device, default is - * {@link ConfigurationKeys#SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT} + * {@link #DEVICE_FILE_PATH_DEFAULT} */ // Please ensure the property description agrees with the implementation OS(OsCryptoRandom.class); @@ -103,7 +143,7 @@ public class CryptoRandomFactory { /** * The default value (OPENSSL,JAVA) used when creating a {@link CryptoCipher}. */ - private static final String SECURE_RANDOM_CLASSES_DEFAULT = + private static final String CLASSES_DEFAULT = RandomProvider.OPENSSL.getClassName() .concat(",") .concat(RandomProvider.JAVA.getClassName()); @@ -116,7 +156,7 @@ public class CryptoRandomFactory { /** * Gets a CryptoRandom instance using the default implementation - * as defined by {@link #SECURE_RANDOM_CLASSES_DEFAULT} + * as defined by {@link #CLASSES_DEFAULT} * * @return CryptoRandom the cryptoRandom object. * @throws GeneralSecurityException if cannot create the {@link CryptoRandom} class @@ -175,9 +215,9 @@ public class CryptoRandomFactory { * @return the CryptoRandom class based on the props. */ private static String getRandomClassString(Properties props) { - String randomClassString = props.getProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, SECURE_RANDOM_CLASSES_DEFAULT); + String randomClassString = props.getProperty(CryptoRandomFactory.CLASSES_KEY, CLASSES_DEFAULT); if (randomClassString.isEmpty()) { // TODO does it make sense to treat the empty string as the default? - randomClassString = SECURE_RANDOM_CLASSES_DEFAULT; + randomClassString = CLASSES_DEFAULT; } return randomClassString; } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java index 39e0d18..ed2b680 100644 --- a/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java +++ b/src/main/java/org/apache/commons/crypto/random/JavaCryptoRandom.java @@ -21,8 +21,6 @@ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; - /** * A CryptoRandom of Java implementation. */ @@ -34,9 +32,9 @@ class JavaCryptoRandom implements CryptoRandom { * Constructs a {@link JavaCryptoRandom}. * * @param properties the configuration properties. - * Uses the key {@link ConfigurationKeys#SECURE_RANDOM_JAVA_ALGORITHM_KEY} + * Uses the key {@link CryptoRandomFactory#SECURE_RANDOM_JAVA_ALGORITHM_KEY} * to get the name of the algorithm, with a default of - * {@link ConfigurationKeys#SECURE_RANDOM_JAVA_ALGORITHM_DEFAULT} + * {@link CryptoRandomFactory#JAVA_ALGORITHM_DEFAULT} * @throws NoSuchAlgorithmException if no Provider supports a * SecureRandomSpi implementation for the specified algorithm. */ @@ -47,8 +45,8 @@ class JavaCryptoRandom implements CryptoRandom { instance = SecureRandom .getInstance(properties .getProperty( - ConfigurationKeys.SECURE_RANDOM_JAVA_ALGORITHM_KEY, - ConfigurationKeys.SECURE_RANDOM_JAVA_ALGORITHM_DEFAULT)); + CryptoRandomFactory.JAVA_ALGORITHM_KEY, + CryptoRandomFactory.JAVA_ALGORITHM_DEFAULT)); } /** http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java index a15686c..1d40bd2 100644 --- a/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java +++ b/src/main/java/org/apache/commons/crypto/random/OsCryptoRandom.java @@ -23,7 +23,6 @@ import java.io.IOException; import java.util.Properties; import java.util.Random; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.utils.IoUtils; /** @@ -62,16 +61,16 @@ class OsCryptoRandom extends Random implements CryptoRandom { * Constructs a {@link OsCryptoRandom}. * * @param props the configuration properties. - * Uses {@link ConfigurationKeys#SECURE_RANDOM_DEVICE_FILE_PATH_KEY} to determine the + * Uses {@link CryptoRandomFactory#DEVICE_FILE_PATH_KEY} to determine the * path to the random device, default is - * {@link ConfigurationKeys#SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT} + * {@link CryptoRandomFactory#DEVICE_FILE_PATH_DEFAULT} */ // N.B. this class is not public/protected so does not appear in the main Javadoc // Please ensure that property use is documented in the enum CryptoRandomFactory.RandomProvider public OsCryptoRandom(Properties props) { File randomDevFile = new File( - props.getProperty(ConfigurationKeys.SECURE_RANDOM_DEVICE_FILE_PATH_KEY, - ConfigurationKeys.SECURE_RANDOM_DEVICE_FILE_PATH_DEFAULT)); + props.getProperty(CryptoRandomFactory.DEVICE_FILE_PATH_KEY, + CryptoRandomFactory.DEVICE_FILE_PATH_DEFAULT)); try { close(); http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java index 334d391..cd1e639 100644 --- a/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java +++ b/src/main/java/org/apache/commons/crypto/stream/CryptoInputStream.java @@ -33,8 +33,8 @@ import javax.crypto.IllegalBlockSizeException; import javax.crypto.ShortBufferException; import javax.crypto.spec.IvParameterSpec; +import org.apache.commons.crypto.Crypto; import org.apache.commons.crypto.cipher.CryptoCipher; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.stream.input.ChannelInput; import org.apache.commons.crypto.stream.input.Input; import org.apache.commons.crypto.stream.input.StreamInput; @@ -51,6 +51,12 @@ public class CryptoInputStream extends InputStream implements ReadableByteChannel { private final byte[] oneByteBuf = new byte[1]; + /** + * The configuration key of the buffer size for stream. + */ + public static final String STREAM_BUFFER_SIZE_KEY = Crypto.CONF_PREFIX + + "stream.buffer.size"; + /** The CryptoCipher instance. */ final CryptoCipher cipher; @@ -86,6 +92,12 @@ public class CryptoInputStream extends InputStream implements */ ByteBuffer outBuffer; + // stream related configuration keys + /** + * The default value of the buffer size for stream. + */ + private static final int STREAM_BUFFER_SIZE_DEFAULT = 8192; + private static final int MIN_BUFFER_SIZE = 512; /** @@ -608,9 +620,9 @@ public class CryptoInputStream extends InputStream implements * @return the buffer size. * */ static int getBufferSize(Properties props) { - String bufferSizeStr = props.getProperty(ConfigurationKeys.STREAM_BUFFER_SIZE_KEY); + String bufferSizeStr = props.getProperty(CryptoInputStream.STREAM_BUFFER_SIZE_KEY); if (bufferSizeStr == null || bufferSizeStr.isEmpty()) { - return ConfigurationKeys.STREAM_BUFFER_SIZE_DEFAULT; + return CryptoInputStream.STREAM_BUFFER_SIZE_DEFAULT; } return Integer.parseInt(bufferSizeStr); } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/main/java/org/apache/commons/crypto/utils/Utils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/crypto/utils/Utils.java b/src/main/java/org/apache/commons/crypto/utils/Utils.java index 46a51f8..1c96b44 100644 --- a/src/main/java/org/apache/commons/crypto/utils/Utils.java +++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java @@ -25,9 +25,9 @@ import java.util.Enumeration; import java.util.List; import java.util.Properties; +import org.apache.commons.crypto.Crypto; import org.apache.commons.crypto.cipher.CryptoCipher; import org.apache.commons.crypto.cipher.CryptoCipherFactory; -import org.apache.commons.crypto.conf.ConfigurationKeys; /** * General utility methods. @@ -37,7 +37,14 @@ public final class Utils { private static class DefaultPropertiesHolder { static final Properties DEFAULT_PROPERTIES = createDefaultProperties(); } - + + /** + * The filename of configuration file. + * TODO is there any need for it to have the CONF_PREFIX? + */ + private static final String SYSTEM_PROPERTIES_FILE = Crypto.CONF_PREFIX + + "properties"; + /** * The private constructor of {@link Utils}. */ @@ -46,7 +53,7 @@ public final class Utils { /** * Loads system properties when configuration file of the name - * {@link ConfigurationKeys#SYSTEM_PROPERTIES_FILE} is found. + * {@link #SYSTEM_PROPERTIES_FILE} is found. * * @return the default properties */ @@ -55,7 +62,7 @@ public final class Utils { Properties defaultedProps = new Properties(System.getProperties()); try { InputStream is = Thread.currentThread().getContextClassLoader() - .getResourceAsStream(ConfigurationKeys.SYSTEM_PROPERTIES_FILE); + .getResourceAsStream(SYSTEM_PROPERTIES_FILE); if (is == null) { return defaultedProps; // no configuration file is found @@ -74,7 +81,7 @@ public final class Utils { } } catch (Exception ex) { System.err.println("Could not load '" - + ConfigurationKeys.SYSTEM_PROPERTIES_FILE + + SYSTEM_PROPERTIES_FILE + "' from classpath: " + ex.toString()); } return defaultedProps; @@ -83,7 +90,7 @@ public final class Utils { /** * Gets a properties instance that defaults to the System Properties * plus any other properties found in the file - * {@link ConfigurationKeys#SYSTEM_PROPERTIES_FILE SYSTEM_PROPERTIES_FILE} + * {@link #SYSTEM_PROPERTIES_FILE} * @return a Properties instance with defaults */ public static Properties getDefaultProperties() { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/AbstractBenchmark.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/AbstractBenchmark.java b/src/test/java/org/apache/commons/crypto/AbstractBenchmark.java index 3687982..175d85f 100644 --- a/src/test/java/org/apache/commons/crypto/AbstractBenchmark.java +++ b/src/test/java/org/apache/commons/crypto/AbstractBenchmark.java @@ -26,7 +26,6 @@ import javax.crypto.spec.SecretKeySpec; import org.apache.commons.crypto.cipher.CryptoCipher; import org.apache.commons.crypto.cipher.CryptoCipherFactory; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.random.CryptoRandom; import org.apache.commons.crypto.random.CryptoRandomFactory; import org.junit.Assert; @@ -66,7 +65,7 @@ public abstract class AbstractBenchmark { protected CryptoRandom getRandom(String className) throws Exception { Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, className); + props.setProperty(CryptoRandomFactory.CLASSES_KEY, className); final CryptoRandom cryptoRandom = CryptoRandomFactory.getCryptoRandom(props); Assert.assertEquals(className, cryptoRandom.getClass().getCanonicalName()); return cryptoRandom; @@ -74,7 +73,7 @@ public abstract class AbstractBenchmark { protected CryptoCipher getCipher(String className) throws Exception { Properties properties = new Properties(); - properties.setProperty(ConfigurationKeys.CIPHER_CLASSES_KEY, className); + properties.setProperty(CryptoCipherFactory.CLASSES_KEY, className); CryptoCipher cipher = CryptoCipherFactory.getCryptoCipher("AES/CBC/PKCS5Padding", properties); Assert.assertEquals(className, cipher.getClass().getCanonicalName()); return cipher; http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java index 47d91d1..0c422f2 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/AbstractCipherTest.java @@ -30,7 +30,6 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import javax.xml.bind.DatatypeConverter; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.utils.ReflectionUtils; import org.apache.commons.crypto.utils.Utils; import org.junit.Assert; @@ -64,7 +63,7 @@ public abstract class AbstractCipherTest { Utils.checkNotNull(cipherClass); Utils.checkNotNull(transformations); props = new Properties(); - props.setProperty(ConfigurationKeys.CIPHER_CLASSES_KEY, + props.setProperty(CryptoCipherFactory.CLASSES_KEY, cipherClass); } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java index 4547aab..9690cad 100644 --- a/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java +++ b/src/test/java/org/apache/commons/crypto/cipher/CryptoCipherFactoryTest.java @@ -20,8 +20,6 @@ package org.apache.commons.crypto.cipher; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; - import org.junit.Assert; import org.junit.Test; @@ -38,7 +36,7 @@ public class CryptoCipherFactoryTest { public void testEmptyCipher() throws GeneralSecurityException { Properties properties = new Properties(); properties.setProperty( - ConfigurationKeys.CIPHER_CLASSES_KEY, ""); + CryptoCipherFactory.CLASSES_KEY, ""); CryptoCipher defaultCipher = CryptoCipherFactory.getCryptoCipher( "AES/CBC/NoPadding", properties); Assert.assertEquals(OpenSslCipher.class.getName(), defaultCipher @@ -48,7 +46,7 @@ public class CryptoCipherFactoryTest { @Test(expected = GeneralSecurityException.class) public void testInvalidCipher() throws GeneralSecurityException { Properties properties = new Properties(); - properties.setProperty(ConfigurationKeys.CIPHER_CLASSES_KEY, + properties.setProperty(CryptoCipherFactory.CLASSES_KEY, "InvalidCipherName"); CryptoCipherFactory.getCryptoCipher("AES/CBC/NoPadding", properties); } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java b/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java index 784b722..61f13ad 100644 --- a/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java +++ b/src/test/java/org/apache/commons/crypto/examples/CipherByteArrayExample.java @@ -26,9 +26,9 @@ import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import org.apache.commons.crypto.cipher.CryptoCipher; +import org.apache.commons.crypto.cipher.CryptoCipherFactory; import org.apache.commons.crypto.cipher.CryptoCipherFactory.CipherProvider; import org.apache.commons.crypto.utils.Utils; -import static org.apache.commons.crypto.conf.ConfigurationKeys.CIPHER_CLASSES_KEY; /** * Example showing use of the CryptoCipher API using a byte array @@ -41,7 +41,7 @@ public class CipherByteArrayExample { final IvParameterSpec iv = new IvParameterSpec(getUTF8Bytes("1234567890123456")); Properties properties = new Properties(); - properties.setProperty(CIPHER_CLASSES_KEY, CipherProvider.OPENSSL.getClassName()); + properties.setProperty(CryptoCipherFactory.CLASSES_KEY, CipherProvider.OPENSSL.getClassName()); //Creates a CryptoCipher instance with the transformation and properties. final String transform = "AES/CBC/PKCS5Padding"; CryptoCipher encipher = Utils.getCipherInstance(transform, properties); @@ -67,7 +67,7 @@ public class CipherByteArrayExample { System.out.println(Arrays.toString(Arrays.copyOf(output, updateBytes+finalBytes))); // Now reverse the process using a different implementation with the same settings - properties.setProperty(CIPHER_CLASSES_KEY, CipherProvider.JCE.getClassName()); + properties.setProperty(CryptoCipherFactory.CLASSES_KEY, CipherProvider.JCE.getClassName()); CryptoCipher decipher = Utils.getCipherInstance(transform, properties); System.out.println("Cipher: " + encipher.getClass().getCanonicalName()); http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/examples/RandomExample.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/examples/RandomExample.java b/src/test/java/org/apache/commons/crypto/examples/RandomExample.java index 2a9ff41..0387472 100644 --- a/src/test/java/org/apache/commons/crypto/examples/RandomExample.java +++ b/src/test/java/org/apache/commons/crypto/examples/RandomExample.java @@ -22,7 +22,6 @@ import java.security.GeneralSecurityException; import java.util.Arrays; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.random.CryptoRandom; import org.apache.commons.crypto.random.CryptoRandomFactory; @@ -37,7 +36,7 @@ public class RandomExample { byte[] iv = new byte[32]; Properties properties = new Properties(); - properties.put(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + properties.put(CryptoRandomFactory.CLASSES_KEY, CryptoRandomFactory.RandomProvider.OPENSSL.getClassName()); //Gets the 'CryptoRandom' instance. http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java index 990bfd2..0c0356b 100644 --- a/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/jna/OpenSslJnaCryptoRandomTest.java @@ -20,7 +20,6 @@ package org.apache.commons.crypto.jna; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.apache.commons.crypto.jna.OpenSslJnaCryptoRandom; import org.apache.commons.crypto.random.AbstractRandomTest; import org.apache.commons.crypto.random.CryptoRandom; @@ -34,7 +33,7 @@ public class OpenSslJnaCryptoRandomTest extends AbstractRandomTest { public CryptoRandom getCryptoRandom() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, OpenSslJnaCryptoRandom.class.getName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); if (!(random instanceof OpenSslJnaCryptoRandom)) { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java index a8d2946..c0654da 100644 --- a/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java +++ b/src/test/java/org/apache/commons/crypto/random/CryptoRandomFactoryTest.java @@ -20,7 +20,6 @@ package org.apache.commons.crypto.random; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; import org.junit.Assert; import org.junit.Test; @@ -34,7 +33,7 @@ public class CryptoRandomFactoryTest { @Test public void testEmpty() throws Exception { final Properties props = new Properties(); - props.setProperty(ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, ""); + props.setProperty(CryptoRandomFactory.CLASSES_KEY, ""); CryptoRandomFactory.getCryptoRandom(props); } @@ -51,7 +50,7 @@ public class CryptoRandomFactoryTest { public void testGetOSRandom() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, CryptoRandomFactory.RandomProvider.OS.getClassName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); @@ -63,7 +62,7 @@ public class CryptoRandomFactoryTest { public void testFullClassName() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, OsCryptoRandom.class.getName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); @@ -75,7 +74,7 @@ public class CryptoRandomFactoryTest { public void testInvalidRandom() throws GeneralSecurityException { Properties properties = new Properties(); properties.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, "InvalidCipherName"); CryptoRandomFactory.getCryptoRandom(properties); } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java index 972a66a..0b7fdd9 100644 --- a/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/random/JavaCryptoRandomTest.java @@ -20,7 +20,6 @@ package org.apache.commons.crypto.random; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; import static org.junit.Assert.fail; public class JavaCryptoRandomTest extends AbstractRandomTest { @@ -29,7 +28,7 @@ public class JavaCryptoRandomTest extends AbstractRandomTest { public CryptoRandom getCryptoRandom() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, JavaCryptoRandom.class.getName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); if (!(random instanceof JavaCryptoRandom)) { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java index 4cca0f0..6f40484 100644 --- a/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/random/OpensslCryptoRandomTest.java @@ -20,7 +20,6 @@ package org.apache.commons.crypto.random; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; import static org.junit.Assert.fail; public class OpensslCryptoRandomTest extends AbstractRandomTest { @@ -29,7 +28,7 @@ public class OpensslCryptoRandomTest extends AbstractRandomTest { public CryptoRandom getCryptoRandom() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, OpenSslCryptoRandom.class.getName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); if (!(random instanceof OpenSslCryptoRandom)) { http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/8997a623/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java index a284825..0c95371 100644 --- a/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java +++ b/src/test/java/org/apache/commons/crypto/random/OsCryptoRandomTest.java @@ -22,15 +22,13 @@ import static org.junit.Assert.fail; import java.security.GeneralSecurityException; import java.util.Properties; -import org.apache.commons.crypto.conf.ConfigurationKeys; - public class OsCryptoRandomTest extends AbstractRandomTest { @Override public CryptoRandom getCryptoRandom() throws GeneralSecurityException { Properties props = new Properties(); props.setProperty( - ConfigurationKeys.SECURE_RANDOM_CLASSES_KEY, + CryptoRandomFactory.CLASSES_KEY, OsCryptoRandom.class.getName()); CryptoRandom random = CryptoRandomFactory.getCryptoRandom(props); if (!(random instanceof OsCryptoRandom)) {
