harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r425344 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
Date Tue, 25 Jul 2006 09:14:19 GMT
Author: smishura
Date: Tue Jul 25 02:14:19 2006
New Revision: 425344

URL: http://svn.apache.org/viewvc?rev=425344&view=rev
Log:
Fix for HARMONY-770 ([classlib][auth]no expected IllegalArgumentException for javax.security.auth.kerberos.KerberosPrincipal.KerberosPrincipal("@/"))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java?rev=425344&r1=425343&r2=425344&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/javax/security/auth/kerberos/KerberosPrincipal.java
Tue Jul 25 02:14:19 2006
@@ -90,6 +90,14 @@
             throw new UnsupportedOperationException();
         }
         this.name = name;
+        
+        // verify realm name according to RFC 1964(2.1.1 (2))
+        // check invalid chars '\', ':' and null
+        if (realm.indexOf('/') != -1 || realm.indexOf(':') != -1
+                || realm.indexOf(0) != -1) {
+            throw new IllegalArgumentException(
+                    "Illegal character in realm name; one of: '/', ':', null");
+        }
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java?rev=425344&r1=425343&r2=425344&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/javax/security/auth/kerberos/KerberosPrincipalTest.java
Tue Jul 25 02:14:19 2006
@@ -36,6 +36,21 @@
         } catch (IllegalArgumentException e) {
         }
 
+        // testing illegal kerberos principal names
+        String[] illegalNames = new String[] { "bbb@a:a.com", // ':' char
+                "bbb@a/a.com", // '/' char
+                "bbb@a\0a.com",// null char
+                "@/" // Regression for HARMONY-770
+        };
+        for (String illegalName : illegalNames) {
+            try {
+                new KerberosPrincipal(illegalName);
+
+                fail("No expected IllegalArgumentException for: " + illegalName);
+            } catch (IllegalArgumentException e) {
+            }
+        }
+
         // valid values
         KerberosPrincipal principal = new KerberosPrincipal("name@apache.org");
 



Mime
View raw message