Map<String, String> availableKeys = new HashMap<String, String>();
Set<String> aliases = keyManager.getAvailableCredentials();
for (String key : aliases) {
try {
log.debug("Found key {}", key);
Credential credential = keyManager.getCredential(key);
if (credential.getPrivateKey() != null) {
log.debug("Adding private key with alias {} and entityID {}", key, credential.getEntityId());
availableKeys.put(key, key + " (" + credential.getEntityId() + ")");
}
} catch (Exception e) {
log.debug("Error loading key", e);
}
}