Search in sources :

Example 1 with DeserializablePublicKeyConfiguration

use of uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration in project verify-hub by alphagov.

the class SignatureVerificationCertificateBuilder method build.

public SignatureVerificationCertificate build() {
    String fullCert = format("-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----", x509Value.trim());
    DeserializablePublicKeyConfiguration configuration = mock(DeserializablePublicKeyConfiguration.class);
    when(configuration.getCert()).thenReturn(fullCert);
    return new SignatureVerificationCertificate(configuration);
}
Also used : DeserializablePublicKeyConfiguration(uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration) SignatureVerificationCertificate(uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)

Example 2 with DeserializablePublicKeyConfiguration

use of uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration in project verify-hub by alphagov.

the class SamlEngineModule method getKeyStore.

@Provides
@Singleton
private IdaKeyStore getKeyStore(X509CertificateFactory certificateFactory, SamlEngineConfiguration configuration) {
    Map<KeyPosition, PrivateKey> privateKeyStore = privateEncryptionKeys(configuration);
    DeserializablePublicKeyConfiguration publicSigningKeyConfiguration = configuration.getPublicSigningCert();
    String encodedSigningCertificate = publicSigningKeyConfiguration.getCert();
    X509Certificate signingCertificate = encodedSigningCertificate != null ? certificateFactory.createCertificate(encodedSigningCertificate) : null;
    KeyPair primaryEncryptionKeyPair = Crypto.keyPairFromPrivateKey(privateKeyStore.get(KeyPosition.PRIMARY));
    KeyPair secondaryEncryptionKeyPair = Crypto.keyPairFromPrivateKey(privateKeyStore.get(KeyPosition.SECONDARY));
    KeyPair signingKeyPair = Crypto.keyPairFromPrivateKey(privateSigningKey(configuration));
    return new IdaKeyStore(signingCertificate, signingKeyPair, asList(primaryEncryptionKeyPair, secondaryEncryptionKeyPair));
}
Also used : KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) DeserializablePublicKeyConfiguration(uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration) IdaKeyStore(uk.gov.ida.saml.security.IdaKeyStore) X509Certificate(java.security.cert.X509Certificate) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

DeserializablePublicKeyConfiguration (uk.gov.ida.common.shared.configuration.DeserializablePublicKeyConfiguration)2 Provides (com.google.inject.Provides)1 KeyPair (java.security.KeyPair)1 PrivateKey (java.security.PrivateKey)1 X509Certificate (java.security.cert.X509Certificate)1 Singleton (javax.inject.Singleton)1 SignatureVerificationCertificate (uk.gov.ida.hub.config.domain.SignatureVerificationCertificate)1 IdaKeyStore (uk.gov.ida.saml.security.IdaKeyStore)1