/** * 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 void removeKeytabEntries(PrincipalName principal, int kvno) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry entry : entries) { if (entry.getKvno() == kvno) { removeKeytabEntry(entry); } } }
@Override public void removeKeytabEntries(PrincipalName principal, int kvno) { List<KeytabEntry> entries = getKeytabEntries(principal); for (KeytabEntry entry : entries) { if (entry.getKvno() == kvno) { removeKeytabEntry(entry); } } }
/** * Remove all the old keys of the specified principal * in the specified keytab file. * * @param keytabFile The keytab file * @param principalName The principal name * @throws KrbException If there is a problem in removing the old keys of the specified principal */ public static void removeOldKeytabEntriesOf(File keytabFile, String principalName) throws KrbException { Keytab keytab = loadKeytab(keytabFile); List<KeytabEntry> entries = keytab.getKeytabEntries( new PrincipalName(principalName)); int maxKvno = 0; for (KeytabEntry entry : entries) { if (maxKvno < entry.getKvno()) { maxKvno = entry.getKvno(); } } for (KeytabEntry entry : entries) { if (entry.getKvno() < maxKvno) { keytab.removeKeytabEntry(entry); } } storeKeytab(keytab, keytabFile); }
/** * Remove all the old keys of the specified principal * in the specified keytab file. * * @param keytabFile The keytab file * @param principalName The principal name * @throws KrbException If there is a problem in removing the old keys of the specified principal */ public static void removeOldKeytabEntriesOf(File keytabFile, String principalName) throws KrbException { Keytab keytab = loadKeytab(keytabFile); List<KeytabEntry> entries = keytab.getKeytabEntries( new PrincipalName(principalName)); int maxKvno = 0; for (KeytabEntry entry : entries) { if (maxKvno < entry.getKvno()) { maxKvno = entry.getKvno(); } } for (KeytabEntry entry : entries) { if (entry.getKvno() < maxKvno) { keytab.removeKeytabEntry(entry); } } storeKeytab(keytab, keytabFile); }
for (KeytabEntry entry : keytabEntries) { StringBuilder sb = new StringBuilder(); sb.append(String.format("%-4d ", entry.getKvno())); if ((outputIndex & 2) != 0) { Date date = new Date(entry.getTimestamp().getTime());
for (KeytabEntry entry : keytabEntries) { StringBuilder sb = new StringBuilder(); sb.append(String.format("%-4d ", entry.getKvno())); if ((outputIndex & 2) != 0) { Date date = new Date(entry.getTimestamp().getTime());