changeset 14249:a44d40b5739a

8134297: NPE in GSSNameElement nameType check Reviewed-by: xuelei
author weijun
date Thu, 17 Sep 2015 18:41:05 -0700
parents 0be735572230
children 95dca8033930
files src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/GSSNameElement.java	Tue Apr 19 11:42:29 2016 -0700
+++ b/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 {