harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r408642 - in /incubator/harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/java/security/cert/TrustAnchor.java test/java/common/java/security/cert/TrustAnchorTest.java
Date Mon, 22 May 2006 11:16:48 GMT
Author: smishura
Date: Mon May 22 04:16:48 2006
New Revision: 408642

URL: http://svn.apache.org/viewvc?rev=408642&view=rev
Log:
Fixing bug: TrustAnchor should throw IAE in case of empty distinguished name. Adding regression
test.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java
  (contents, props changed)
    incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java
  (contents, props changed)

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java?rev=408642&r1=408641&r2=408642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java
Mon May 22 04:16:48 2006
@@ -93,7 +93,12 @@
         }
 
         this.trustedCert = null;
+
         // X500Principal checks caName validity
+        if (caName.length() == 0) {
+            throw new IllegalArgumentException(
+                    "the caName parameter is empty string");
+        }
         this.caPrincipal = new X500Principal(this.caName);
     }
 

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/java/security/cert/TrustAnchor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java?rev=408642&r1=408641&r2=408642&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java
Mon May 22 04:16:48 2006
@@ -462,32 +462,45 @@
      * or <code>caPublicKey</code> parameter is <code>null</code><br>
      * Test preconditions: pass <code>null</code> as mentioned parameter<br>
      * Expected: NullPointerException
-     * @throws InvalidKeySpecException
      */
     public final void testTrustAnchorStringPublicKeybyteArray04()
             throws Exception {
 
         PublicKey pk = new TestKeyPair(keyAlg).getPublic();
 
-        // sub testcase 1
+        // sub testcase 1: 'caName' param is null
         try {
             new TrustAnchor((String)null, pk, getEncodingPSOnly());
             fail("NullPointerException has not been thrown");
         } catch (NullPointerException ok) {
         }
 
-        // sub testcase 2
+        // sub testcase 2: 'caPublicKey' param is null
         try {
             new TrustAnchor(validCaNameRfc2253, null, getEncodingPSOnly());
             fail("NullPointerException has not been thrown");
         } catch (NullPointerException ok) {
         }
 
-        // sub testcase 3
+        // sub testcase 3: 'caName' and 'caPublicKey' params are null
         try {
             new TrustAnchor((String)null, null, getEncodingPSOnly());
             fail("NullPointerException has not been thrown");
         } catch (NullPointerException ok) {
+        }
+
+        // sub testcase 4: 'caName' param is empty
+        try {
+            new TrustAnchor("", pk, getEncodingPSOnly());
+            fail("IllegalArgumentException has not been thrown");
+        } catch (IllegalArgumentException ok) {
+        }
+
+        // sub testcase 5: 'caName' param is incorrect distinguished name
+        try {
+            new TrustAnchor("AID.11.12=A", pk, getEncodingPSOnly());
+            fail("IllegalArgumentException has not been thrown");
+        } catch (IllegalArgumentException ok) {
         }
     }
 

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/security/src/test/java/common/java/security/cert/TrustAnchorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message