harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r789934 - in /harmony/enhanced/classlib/trunk/modules/security/src: main/java/common/org/apache/harmony/security/x509/GeneralName.java test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
Date Tue, 30 Jun 2009 20:27:30 GMT
Author: tellison
Date: Tue Jun 30 20:27:30 2009
New Revision: 789934

URL: http://svn.apache.org/viewvc?rev=789934&view=rev
Log:
Apply patch for HARMONY-6248 ([classlib][security] Wildcard subjectAltName dNSName entries
throw IOException)

Modified:
    harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
    harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java

Modified: harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java?rev=789934&r1=789933&r2=789934&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/main/java/common/org/apache/harmony/security/x509/GeneralName.java
Tue Jun 30 20:27:30 2009
@@ -580,7 +580,8 @@
 
     /**
      * Checks the correctness of the string representation of DNS name.
-     * The correctness is checked as specified in RFC 1034 p. 10.
+     * The correctness is checked as specified in RFC 1034 p. 10, and modified
+     * by RFC 1123 (section 2.1).
      */
     public static void checkDNS(String dns) throws IOException {
         byte[] bytes = dns.toLowerCase().getBytes("UTF-8"); //$NON-NLS-1$
@@ -589,7 +590,11 @@
         for (int i=0; i<bytes.length; i++) {
             byte ch = bytes[i];
             if (first_letter) {
-                if (ch > 'z' || ch < 'a') {
+                if ((bytes.length > 2) && (ch == '*') && (bytes[1] ==
'.')) {
+                    first_letter = false;
+                    continue;
+                }
+                if ((ch > 'z' || ch < 'a') && (ch < '0' || ch > '9'))
{
                     throw new IOException(Messages.getString("security.184", //$NON-NLS-1$
                             (char)ch, dns));
                 }

Modified: harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java?rev=789934&r1=789933&r2=789934&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/cert/X509CertSelectorTest.java
Tue Jun 30 20:27:30 2009
@@ -39,7 +39,7 @@
             try {
                 new X509CertSelector().addSubjectAlternativeName(types[i],
                         (byte[]) null);
-                fail("No expected NullPointerException for type: " + i);
+                fail("No expected NullPointerException for type: " + types[i]);
             } catch (NullPointerException e) {
             }
         }
@@ -48,17 +48,34 @@
     /**
      * @tests java.security.cert.X509CertSelector#addSubjectAlternativeName(int, String)
      */
-    public void test_addSubjectAlternativeNameLintLjava_lang_String() {
+    public void test_addSubjectAlternativeNameLintLjava_lang_String() throws IOException
{
         // Regression for HARMONY-727
-        int[] types = { 0, 2, 3, 4, 5, 6, 7, 8 };
+        int[] types = { 0, 3, 4, 5, 6, 7, 8 };
         for (int i = 0; i < types.length; i++) {
             try {
                 new X509CertSelector().addSubjectAlternativeName(types[i],
                         "0xDFRF");
-                fail("IOException expected");
+                fail("IOException expected for type: " + types[i]);
             } catch (IOException e) {
             }
         }
+        // Tests for DNSGeneralName
+        // Legal DNS names
+        new X509CertSelector().addSubjectAlternativeName(2, "0xDFRF");
+        new X509CertSelector().addSubjectAlternativeName(2, "");
+        new X509CertSelector().addSubjectAlternativeName(2, "foo.example.com");
+        new X509CertSelector().addSubjectAlternativeName(2, "3g.example.com");
+        new X509CertSelector().addSubjectAlternativeName(2, "*.example.com");
+        // Illegal DNS names
+        String[] names = new String[] {"*", "*.", "%anything"};
+        for (String badName : names) {
+            try {
+                new X509CertSelector().addSubjectAlternativeName(2, badName);
+                fail("IOException expected for DNS name " + badName);
+            } catch (IOException e) {
+                // Expected
+            }
+        }
     }
 
     /**
@@ -70,7 +87,7 @@
         for (int i = 0; i < types.length; i++) {
             try {
                 new X509CertSelector().addPathToName(types[i], (byte[]) null);
-                fail("No expected NullPointerException for type: " + i);
+                fail("No expected NullPointerException for type: " + types[i]);
             } catch (NullPointerException e) {
             }
         }
@@ -84,7 +101,7 @@
         for (int type = 0; type <= 8; type++) {
             try {
                 new X509CertSelector().addPathToName(type, (String) null);
-                fail("IOException expected!");
+                fail("IOException expected for type: " + type);
             } catch (IOException ioe) {
                 // expected
             }



Mime
View raw message