jdk/src/share/classes/sun/security/krb5/Credentials.java
changeset 12423 a69d7fadb9f8
parent 12047 320a714614e9
child 12538 211d6e82fe51
--- a/jdk/src/share/classes/sun/security/krb5/Credentials.java	Tue Apr 10 10:17:36 2012 +0800
+++ b/jdk/src/share/classes/sun/security/krb5/Credentials.java	Tue Apr 10 12:15:03 2012 +0800
@@ -330,12 +330,17 @@
         CredentialsCache ccache =
             CredentialsCache.getInstance(princ, ticketCache);
 
-        if (ccache == null)
+        if (ccache == null) {
             return null;
+        }
 
         sun.security.krb5.internal.ccache.Credentials tgtCred  =
             ccache.getDefaultCreds();
 
+        if (tgtCred == null) {
+            return null;
+        }
+
         if (EType.isSupported(tgtCred.getEType())) {
             return tgtCred.setKrbCreds();
         } else {
@@ -375,19 +380,21 @@
             cache = CredentialsCache.getInstance();
         }
         if (cache != null) {
-            if (DEBUG) {
-                System.out.println(">>> KrbCreds found the default ticket " +
-                                   "granting ticket in credential cache.");
-            }
             sun.security.krb5.internal.ccache.Credentials temp =
                 cache.getDefaultCreds();
-            if (EType.isSupported(temp.getEType())) {
-                result = temp.setKrbCreds();
-            } else {
+            if (temp != null) {
                 if (DEBUG) {
-                    System.out.println(
-                        ">>> unsupported key type found the default TGT: " +
-                        temp.getEType());
+                    System.out.println(">>> KrbCreds found the default ticket"
+                            + " granting ticket in credential cache.");
+                }
+                if (EType.isSupported(temp.getEType())) {
+                    result = temp.setKrbCreds();
+                } else {
+                    if (DEBUG) {
+                        System.out.println(
+                            ">>> unsupported key type found the default TGT: " +
+                            temp.getEType());
+                    }
                 }
             }
         }