commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject commons-crypto git commit: Fix up error messages (wrong classname was used); Javadoc
Date Mon, 27 Jun 2016 21:56:47 GMT
Repository: commons-crypto
Updated Branches:
  refs/heads/master 0746a877c -> cc6233f20


Fix up error messages (wrong classname was used); Javadoc

Project: http://git-wip-us.apache.org/repos/asf/commons-crypto/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-crypto/commit/cc6233f2
Tree: http://git-wip-us.apache.org/repos/asf/commons-crypto/tree/cc6233f2
Diff: http://git-wip-us.apache.org/repos/asf/commons-crypto/diff/cc6233f2

Branch: refs/heads/master
Commit: cc6233f206488d5ab9e3da2a43a83721fdae0776
Parents: 0746a87
Author: Sebb <sebb@apache.org>
Authored: Mon Jun 27 22:56:44 2016 +0100
Committer: Sebb <sebb@apache.org>
Committed: Mon Jun 27 22:56:44 2016 +0100

----------------------------------------------------------------------
 .../commons/crypto/random/CryptoRandomFactory.java  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-crypto/blob/cc6233f2/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 0b775be..4b9fc58 100644
--- a/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
+++ b/src/main/java/org/apache/commons/crypto/random/CryptoRandomFactory.java
@@ -44,10 +44,9 @@ public class CryptoRandomFactory {
      * The properties are passed to the generated class.
      *
      * @param props the configuration properties.
-     * @return CryptoRandom the cryptoRandom object.Null value will be returned
-     *         if no CryptoRandom classes with props.
-     * @throws GeneralSecurityException if fail to create the
-     *         {@link CryptoRandom}.
+     * @return CryptoRandom  the cryptoRandom object.
+     * @throws GeneralSecurityException if cannot create the {@link CryptoRandom} class
+     * @throws IllegalArgumentException if no classname(s) are provided and fallback is disabled
      */
     public static CryptoRandom getCryptoRandom(Properties props)
             throws GeneralSecurityException {
@@ -66,11 +65,9 @@ public class CryptoRandomFactory {
                     break;
                 }
             } catch (ClassCastException e) {
-                errorMessage.append("Class: [" + klassName + "] is not a " +
-                        "CryptoCipher.");
+                errorMessage.append("Class: [" + klassName + "] is not a CryptoRandom.");
             } catch (ClassNotFoundException e) {
-                errorMessage.append("CryptoCipher: [" + klassName + "] " +
-                        "not " + "found.");
+                errorMessage.append("CryptoRandom: [" + klassName + "] not found.");
             }
         }
 
@@ -79,6 +76,9 @@ public class CryptoRandomFactory {
         } else if (Utils.isFallbackEnabled(props)) {
             return  new JavaCryptoRandom(props);
         } else {
+            if (errorMessage.length() == 0) {
+                throw new IllegalArgumentException("No classname(s) provided, and fallback
is not enabled");
+            }
             throw new GeneralSecurityException(errorMessage.toString());
         }
     }


Mime
View raw message