Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 616d230a authored by Sebastian-Ion TINCU's avatar Sebastian-Ion TINCU
Browse files

EDELIVERY-12998 Extract methods to a generic security library

Extract find duplicate certificates method.
parent 5730c6d6
No related branches found
No related tags found
No related merge requests found
......@@ -285,22 +285,7 @@ public class UIKeystoreService extends BasicKeystoreService {
String keystoreSecToken = configurationService.getKeystoreCredentialToken();
KeyStore keyStore = loadKeystore(configurationService.getKeystoreFile(), keystoreSecToken);
if (keyStore != null) {
return list(newKeystore.aliases())
.stream()
.filter(alias -> containsCertificate(keyStore, newKeystore, alias))
.peek(alias -> LOG.debug("Found entry with duplicate certificate [{}]", alias))
.collect(Collectors.toSet());
}
return Collections.emptySet();
}
private boolean containsCertificate(KeyStore keyStore, KeyStore newKeystore, String alias) {
try {
return keyStore.getCertificateAlias(newKeystore.getCertificate(alias)) != null;
} catch (KeyStoreException e) {
throw new SMPRuntimeException(ErrorCode.CERTIFICATE_ERROR, "An error occurred while loading the entry " + alias, e);
}
return KeystoreUtils.findDuplicateCertificates(keyStore, newKeystore);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment