try {
Collection<Credential> credentials = new ArrayList<Credential>();
if (useExtendedMetadata) {
ExtendedMetadata extendedMetadata = manager.getExtendedMetadata(entityID);
if (usage.equals(UsageType.UNSPECIFIED)) {
if (extendedMetadata.getSigningKey() != null) {
log.debug("Using customized signing key {} from extended metadata for entityID {}", extendedMetadata.getSigningKey(), entityID);
credentials.add(keyManager.getCredential(extendedMetadata.getSigningKey()));
}
if (extendedMetadata.getEncryptionKey() != null) {
log.debug("Using customized encryption key {} from extended metadata for entityID {}", extendedMetadata.getEncryptionKey(), entityID);
credentials.add(keyManager.getCredential(extendedMetadata.getEncryptionKey()));
}
if (extendedMetadata.getTlsKey() != null) {
log.debug("Using customized TLS key {} from extended metadata for entityID {}", extendedMetadata.getEncryptionKey(), entityID);
credentials.add(keyManager.getCredential(extendedMetadata.getTlsKey()));
}
} else if (usage.equals(UsageType.SIGNING)) {
if (extendedMetadata.getSigningKey() != null) {
log.debug("Using customized signing key {} from extended metadata for entityID {}", extendedMetadata.getSigningKey(), entityID);
credentials.add(keyManager.getCredential(extendedMetadata.getSigningKey()));
}
} else if (usage.equals(UsageType.ENCRYPTION)) {
if (extendedMetadata.getEncryptionKey() != null) {
log.debug("Using customized encryption key {} from extended metadata for entityID {}", extendedMetadata.getEncryptionKey(), entityID);
credentials.add(keyManager.getCredential(extendedMetadata.getEncryptionKey()));
}
}
}
if (useXmlMetadata) {