8134297: NPE in GSSNameElement nameType check
authorweijun
Thu, 17 Sep 2015 18:41:05 -0700
changeset 37577 8ba03c9fa5ee
parent 37574 906cb708a629
child 37578 561997281f4a
8134297: NPE in GSSNameElement nameType check Reviewed-by: xuelei
jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
--- a/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java	Tue Apr 19 11:42:29 2016 -0700
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java	Thu Sep 17 18:41:05 2015 -0700
@@ -159,7 +159,9 @@
             int atPos = krbName.lastIndexOf('@');
             if (atPos != -1) {
                 String atRealm = krbName.substring(atPos);
-                if (nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL)
+                // getNativeNameType() can modify NT_GSS_KRB5_PRINCIPAL to null
+                if ((nameType == null
+                            || nameType.equals(GSSUtil.NT_GSS_KRB5_PRINCIPAL))
                         && new String(nameBytes).endsWith(atRealm)) {
                     // Created from Kerberos name with realm, no need to check
                 } else {