Java Code Examples for sun.security.krb5.internal.crypto.EType#toString()

The following examples show how to use sun.security.krb5.internal.crypto.EType#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KrbAsRep.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq, cname);
}
 
Example 2
Source File: KrbAsRep.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 3
Source File: KrbAsRep.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 4
Source File: KrbAsRep.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 5
Source File: KrbAsRep.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq, cname);
}
 
Example 6
Source File: KrbAsRep.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 7
Source File: KrbAsRep.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 8
Source File: KrbAsRep.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 9
Source File: KrbAsRep.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Called by KrbAsReqBuilder to resolve a AS-REP message using a keytab.
 * @param ktab the keytab, not null
 * @param asReq the original AS-REQ sent, used to validate AS-REP
 * @param cname the user principal name, used to locate keys in ktab
 */
void decryptUsingKeyTab(KeyTab ktab, KrbAsReq asReq, PrincipalName cname)
        throws KrbException, Asn1Exception, IOException {
    EncryptionKey dkey = null;
    int encPartKeyType = rep.encPart.getEType();
    Integer encPartKvno = rep.encPart.kvno;
        try {
            dkey = EncryptionKey.findKey(encPartKeyType, encPartKvno,
                    Krb5Util.keysFromJavaxKeyTab(ktab, cname));
        } catch (KrbException ke) {
            if (ke.returnCode() == Krb5.KRB_AP_ERR_BADKEYVER) {
                // Fallback to no kvno. In some cases, keytab is generated
                // not by sysadmin but Java's ktab command
                dkey = EncryptionKey.findKey(encPartKeyType,
                        Krb5Util.keysFromJavaxKeyTab(ktab, cname));
            }
        }
        if (dkey == null) {
            throw new KrbException(Krb5.API_INVALID_ARG,
                "Cannot find key for type/kvno to decrypt AS REP - " +
                EType.toString(encPartKeyType) + "/" + encPartKvno);
        }
    decrypt(dkey, asReq);
}
 
Example 10
Source File: Ktab.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 11
Source File: Ktab.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 12
Source File: Ktab.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 13
Source File: Ktab.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 14
Source File: Ktab.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 15
Source File: Ktab.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 16
Source File: Ktab.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 17
Source File: Ktab.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 18
Source File: Ktab.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 19
Source File: Ktab.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}
 
Example 20
Source File: Ktab.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Lists key table name and entries in it.
 */
void listKt() {
    System.out.println("Keytab name: " + table.tabName());
    KeyTabEntry[] entries = table.getEntries();
    if ((entries != null) && (entries.length > 0)) {
        String[][] output = new String[entries.length+1][showTime?3:2];
        int column = 0;
        output[0][column++] = "KVNO";
        if (showTime) output[0][column++] = "Timestamp";
        output[0][column++] = "Principal";
        for (int i = 0; i < entries.length; i++) {
            column = 0;
            output[i+1][column++] = entries[i].getKey().
                    getKeyVersionNumber().toString();
            if (showTime) output[i+1][column++] =
                    DateFormat.getDateTimeInstance(
                    DateFormat.SHORT, DateFormat.SHORT).format(
                    new Date(entries[i].getTimeStamp().getTime()));
            String princ = entries[i].getService().toString();
            if (showEType) {
                int e = entries[i].getKey().getEType();
                output[i+1][column++] = princ + " (" + e + ":" +
                        EType.toString(e) + ")";
            } else {
                output[i+1][column++] = princ;
            }
        }
        int[] width = new int[column];
        for (int j=0; j<column; j++) {
            for (int i=0; i <= entries.length; i++) {
                if (output[i][j].length() > width[j]) {
                    width[j] = output[i][j].length();
                }
            }
            if (j != 0) width[j] = -width[j];
        }
        for (int j=0; j<column; j++) {
            System.out.printf("%" + width[j] + "s ", output[0][j]);
        }
        System.out.println();
        for (int j=0; j<column; j++) {
            for (int k=0; k<Math.abs(width[j]); k++) System.out.print("-");
            System.out.print(" ");
        }
        System.out.println();
        for (int i=0; i<entries.length; i++) {
            for (int j=0; j<column; j++) {
                System.out.printf("%" + width[j] + "s ", output[i+1][j]);
            }
            System.out.println();
        }
    } else {
        System.out.println("0 entry.");
    }
}