changeset 16499:0e78d0a7a517

8149521: automatic discovery of LDAP servers with Kerberos authentication Reviewed-by: vinnie
author weijun
date Fri, 20 May 2016 11:15:05 +0800
parents 3bcf2d4fdb54
children b244dce93e06
files src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java test/sun/security/krb5/canonicalize/Test.java
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java	Thu May 19 19:45:04 2016 -0700
+++ b/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java	Fri May 20 11:15:05 2016 +0800
@@ -424,6 +424,9 @@
                 } catch (UnknownHostException | SecurityException e) {
                     // not canonicalized or no permission to do so, use old
                 }
+                if (hostName.endsWith(".")) {
+                    hostName = hostName.substring(0, hostName.length() - 1);
+                }
                 nameParts[1] = hostName.toLowerCase(Locale.ENGLISH);
             }
             nameStrings = nameParts;
--- a/test/sun/security/krb5/canonicalize/Test.java	Thu May 19 19:45:04 2016 -0700
+++ b/test/sun/security/krb5/canonicalize/Test.java	Fri May 20 11:15:05 2016 +0800
@@ -22,7 +22,7 @@
  */
 /*
  * @test
- * @bug 6682516
+ * @bug 6682516 8149521
  * @summary SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
  * @modules java.security.jgss/sun.security.krb5
  * @run main/othervm  -Djava.security.krb5.conf=krb5.conf Test
@@ -44,9 +44,11 @@
         check("c1", "c1.this.domain");
         check("c1.this", "c1.this.domain");
         check("c1.this.domain", "c1.this.domain");
+        check("c1.this.domain.", "c1.this.domain");
 
         // canonicalized name goes IP, reject
         check("c2", "c2");
+        check("c2.", "c2");
 
         // canonicalized name goes strange, reject
         check("c3", "c3");
@@ -63,4 +65,4 @@
             throw new Exception("Output is " + pn);
         }
     }
-            }
+}