use of uk.gov.ida.hub.samlengine.exceptions.KeyLoadingException in project verify-hub by alphagov.
the class SamlEngineModule method getKeyStore.
@Provides
@Singleton
private IdaKeyStore getKeyStore(SamlEngineConfiguration configuration, SigningCertFromMetadataExtractor signingCertExtractor) {
try {
PrivateKey primaryEncryptionKey = configuration.getPrimaryPrivateEncryptionKeyConfiguration().getPrivateKey();
PrivateKey secondaryEncryptionKey = configuration.getSecondaryPrivateEncryptionKeyConfiguration().getPrivateKey();
PrivateKey signingKey = configuration.getPrivateSigningKeyConfiguration().getPrivateKey();
PublicKey publicSigningKey = KeySupport.derivePublicKey(signingKey);
KeyPair primaryEncryptionKeyPair = new KeyPair(KeySupport.derivePublicKey(primaryEncryptionKey), primaryEncryptionKey);
KeyPair secondaryEncryptionKeyPair = new KeyPair(KeySupport.derivePublicKey(secondaryEncryptionKey), secondaryEncryptionKey);
KeyPair signingKeyPair = new KeyPair(publicSigningKey, signingKey);
X509Certificate signingCertificate = signingCertExtractor.getSigningCertForCurrentSigningKey(publicSigningKey);
return new IdaKeyStore(signingCertificate, signingKeyPair, asList(primaryEncryptionKeyPair, secondaryEncryptionKeyPair));
} catch (KeyException e) {
throw new KeyLoadingException(e);
}
}
Aggregations