/** * Dump a keytab: list all principals. * * @param keytabFile the keytab file * @throws IOException IO problems */ private void dumpKeytab(File keytabFile) throws IOException { title("Examining keytab %s", keytabFile); File kt = keytabFile.getCanonicalFile(); verifyFileIsValid(kt, CAT_KERBEROS, "keytab"); Keytab loadKeytab = Keytab.loadKeytab(kt); List<PrincipalName> principals = loadKeytab.getPrincipals(); println("keytab principal count: %d", principals.size()); int entrySize = 0; for (PrincipalName princ : principals) { List<KeytabEntry> entries = loadKeytab.getKeytabEntries(princ); entrySize = entrySize + entries.size(); for (KeytabEntry entry : entries) { EncryptionKey key = entry.getKey(); println(" %s: version=%d expires=%s encryption=%s", entry.getPrincipal(), entry.getKvno(), entry.getTimestamp(), key.getKeyType()); } } println("keytab entry count: %d", entrySize); endln(); }
@Override public EncryptionKey getKey(PrincipalName principal, EncryptionType keyType) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry ke : entries) { if (ke.getKey().getKeyType() == keyType) { return ke.getKey(); } } // Maybe we have a key stored under a different name for the same type int keyTypeValue = keyType.getValue(); for (KeytabEntry ke : entries) { if (keyTypeValue == ke.getKey().getKeyType().getValue()) { return ke.getKey(); } } return null; }
@Override public EncryptionKey getKey(PrincipalName principal, EncryptionType keyType) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry ke : entries) { if (ke.getKey().getKeyType() == keyType) { return ke.getKey(); } } // Maybe we have a key stored under a different name for the same type int keyTypeValue = keyType.getValue(); for (KeytabEntry ke : entries) { if (keyTypeValue == ke.getKey().getKeyType().getValue()) { return ke.getKey(); } } return null; }
if ((outputIndex & 1) != 0) { sb.append("(0x"); sb.append(HexUtil.bytesToHex(entry.getKey().getKeyData())); sb.append(")");
if ((outputIndex & 1) != 0) { sb.append("(0x"); sb.append(HexUtil.bytesToHex(entry.getKey().getKeyData())); sb.append(")");