7111579: klist starttime, renewtill, ticket etype
authorweijun
Wed, 16 Nov 2011 11:53:40 +0800
changeset 11020 a17d4ff7bae3
parent 11019 aa969c520286
child 11022 52a863b37d61
7111579: klist starttime, renewtill, ticket etype Reviewed-by: mullan
jdk/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java
jdk/src/windows/classes/sun/security/krb5/internal/tools/Klist.java
--- a/jdk/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java	Mon Nov 14 10:06:56 2011 +0000
+++ b/jdk/src/share/classes/sun/security/krb5/internal/ccache/Credentials.java	Wed Nov 16 11:53:40 2011 +0800
@@ -223,6 +223,10 @@
                 cname, sname, key, flags, authtime, starttime, endtime, renewTill, caddr);
     }
 
+    public KerberosTime getStartTime() {
+        return starttime;
+    }
+
     public KerberosTime getAuthTime() {
         return authtime;
     }
@@ -231,6 +235,10 @@
         return endtime;
     }
 
+    public KerberosTime getRenewTill() {
+        return renewTill;
+    }
+
     public TicketFlags getTicketFlags() {
         return flags;
     }
@@ -238,4 +246,8 @@
     public int getEType() {
         return key.getEType();
     }
+
+    public int getTktEType() {
+        return ticket.encPart.getEType();
+    }
 }
--- a/jdk/src/windows/classes/sun/security/krb5/internal/tools/Klist.java	Mon Nov 14 10:06:56 2011 +0000
+++ b/jdk/src/windows/classes/sun/security/krb5/internal/tools/Klist.java	Wed Nov 16 11:53:40 2011 +0800
@@ -207,7 +207,7 @@
                 }
                 if (options[2] == 't') {
                     System.out.println("\t Time stamp: " +
-                            reformat(entries[i].getTimeStamp().toDate().toString()));
+                            format(entries[i].getTimeStamp()));
                 }
             }
         }
@@ -234,30 +234,39 @@
             System.out.println("\nDefault principal: " +
                                defaultPrincipal + ", " +
                                creds.length + " entries found.\n");
-        String starttime = null;
-        String endtime = null;
-        String servicePrincipal = null;
-        String etype = null;
         if (creds != null) {
             for (int i = 0; i < creds.length; i++) {
                 try {
-                    starttime =
-                        reformat(creds[i].getAuthTime().toDate().toString());
-                    endtime =
-                        reformat(creds[i].getEndTime().toDate().toString());
+                    String starttime;
+                    String endtime;
+                    String renewTill;
+                    String servicePrincipal;
+                    if (creds[i].getStartTime() != null) {
+                        starttime = format(creds[i].getStartTime());
+                    } else {
+                        starttime = format(creds[i].getAuthTime());
+                    }
+                    endtime = format(creds[i].getEndTime());
                     servicePrincipal =
                         creds[i].getServicePrincipal().toString();
                     System.out.println("[" + (i + 1) + "] " +
                                        " Service Principal:  " +
                                        servicePrincipal);
-                    System.out.println("     Valid starting:  " + starttime);
-                    System.out.println("     Expires:         " + endtime);
+                    System.out.println("     Valid starting:     " + starttime);
+                    System.out.println("     Expires:            " + endtime);
+                    if (creds[i].getRenewTill() != null) {
+                        renewTill = format(creds[i].getRenewTill());
+                        System.out.println(
+                                "     Renew until:        " + renewTill);
+                    }
                     if (options[0] == 'e') {
-                        etype = EType.toString(creds[i].getEType());
-                        System.out.println("     Encryption type: " + etype);
+                        String eskey = EType.toString(creds[i].getEType());
+                        String etkt = EType.toString(creds[i].getTktEType());
+                        System.out.println("     EType (skey, tkt):  "
+                                + eskey + ", " + etkt);
                     }
                     if (options[1] == 'f') {
-                        System.out.println("     Flags:           " +
+                        System.out.println("     Flags:              " +
                                            creds[i].getTicketFlags().toString());
                     }
                     if (options[2] == 'a') {
@@ -312,13 +321,14 @@
      * and yyyy is the year.
      * @param date the string form of Date object.
      */
-    String reformat(String date) {
+    private String format(KerberosTime kt) {
+        String date = kt.toDate().toString();
         return (date.substring(4, 7) + " " + date.substring(8, 10) +
                 ", " + date.substring(24)
-                + " " + date.substring(11, 16));
+                + " " + date.substring(11, 19));
     }
     /**
-     * Printes out the help information.
+     * Prints out the help information.
      */
     void printHelp() {
         System.out.println("\nUsage: klist " +