// We are looking for a KerberosKey credentials for the
// serverPrincipal
Iterator<KerberosKey> iterator =
subject.getPrivateCredentials(KerberosKey.class).iterator();
while (iterator.hasNext()) {
KerberosKey key = iterator.next();
if (serverPrincipal == null ||
serverPrincipal.equals(key.getPrincipal().getName())) {
if (DEBUG) {
System.out.println("Found key for "
+ key.getPrincipal() + "(" +
key.getKeyType() + ")");
}
if (oneOnly) {
return key;
} else {
if (serverPrincipal == null) {
// Record name so that keys returned will all
// belong to the same principal
serverPrincipal =
key.getPrincipal().getName();
}
answer.add(key);
}
}
}