You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2006/03/28 10:19:09 UTC

svn commit: r389435 [2/2] - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc: java/security/KeyStore.java java/security/MessageDigestSpi.java java/security/SignatureSpi.java javax/crypto/spec/SecretKeySpec.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/javax/crypto/spec/SecretKeySpec.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/javax/crypto/spec/SecretKeySpec.java?rev=389435&r1=389434&r2=389435&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/javax/crypto/spec/SecretKeySpec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/common/javasrc/javax/crypto/spec/SecretKeySpec.java Tue Mar 28 00:19:07 2006
@@ -40,17 +40,20 @@
     private final String algorithm;
     private final String format = "RAW";
 
-    private static final IllegalArgumentException BADPARAMS_EXC =
-            new IllegalArgumentException(
-                    "algorithm is null or key is null, empty, or too short.");
-
     /**
      * @com.intel.drl.spec_ref
      */
     public SecretKeySpec(byte[] key, String algorithm) {
-        if ((key == null) || (key.length == 0) || (algorithm == null)) {
-            throw BADPARAMS_EXC;
+    	if (key == null) {
+    		throw new IllegalArgumentException("key is null");
+    	}
+    	if (key.length == 0) {
+    		throw new IllegalArgumentException("key is empty");
+    	}
+        if (algorithm == null) {
+            throw new IllegalArgumentException("algorithm is null");
         }
+
         this.algorithm = algorithm;
         this.key = new byte[key.length];
         System.arraycopy(key, 0, this.key, 0, key.length);
@@ -60,9 +63,17 @@
      * @com.intel.drl.spec_ref
      */
     public SecretKeySpec(byte[] key, int offset, int len, String algorithm) {
-        if ((key == null) || (key.length == 0)
-                || (key.length - offset < len) || (algorithm == null)) {
-            throw BADPARAMS_EXC;
+    	if (key == null) {
+    		throw new IllegalArgumentException("key is null");
+    	}
+    	if (key.length == 0) {
+    		throw new IllegalArgumentException("key is empty");
+    	}
+    	if ((key.length - offset < len)) {
+    		throw new IllegalArgumentException("key is too short");
+    	}
+        if (algorithm == null) {
+            throw new IllegalArgumentException("algorithm is null");
         }
         this.algorithm = algorithm;
         this.key = new byte[len];