Repository: commons-crypto Updated Branches: refs/heads/master aef15f417 -> 0304a8707
CRYPTO-84: Utils.getJCEProvider belongs in JceCipher 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/0304a870 Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/0304a870 Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/0304a870 Branch: refs/heads/master Commit: 0304a87074d8fee26a972642bf9665771421fff7 Parents: aef15f4 Author: Sun Dapeng <s...@apache.org> Authored: Tue Jun 21 09:52:20 2016 +0800 Committer: Sun Dapeng <s...@apache.org> Committed: Tue Jun 21 10:07:11 2016 +0800 ---------------------------------------------------------------------- .../org/apache/commons/crypto/cipher/JceCipher.java | 16 +++++++++++++++- .../java/org/apache/commons/crypto/utils/Utils.java | 13 ------------- 2 files changed, 15 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/0304a870/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 65079b6..f5bdf92 100644 --- a/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java +++ b/src/main/java/org/apache/commons/crypto/cipher/JceCipher.java @@ -30,6 +30,7 @@ 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; /** @@ -52,7 +53,7 @@ public class JceCipher implements CryptoCipher { this.props = props; this.transformation = transformation; - String provider = Utils.getJCEProvider(props); + String provider = getJCEProvider(props); if (provider == null || provider.isEmpty()) { cipher = Cipher.getInstance(transformation.getName()); } else { @@ -204,4 +205,17 @@ public class JceCipher implements CryptoCipher { public void close() { // Do nothing } + + /** + * Gets the Jce provider. + * + * @param props The <code>Properties</code> class represents a set of + * properties. + * @return the jce provider based on the props. + */ + private static String getJCEProvider(Properties props) { + return props.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY) != + null ? props.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY) + : System.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY); + } } http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/0304a870/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 0388a0e..3fa3a18 100644 --- a/src/main/java/org/apache/commons/crypto/utils/Utils.java +++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java @@ -158,19 +158,6 @@ public final class Utils { } /** - * Gets the Jce provider. - * - * @param props The <code>Properties</code> class represents a set of - * properties. - * @return the jce provider based on the props. - */ - public static String getJCEProvider(Properties props) { - return props.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY) != - null ? props.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY) - : System.getProperty(ConfigurationKeys.COMMONS_CRYPTO_CIPHER_JCE_PROVIDER_KEY); - } - - /** * Gets the random device path. * * @param props The <code>Properties</code> class represents a set of