Search in sources :

Example 1 with PublicKeyFactory

use of uk.gov.ida.common.shared.security.PublicKeyFactory in project verify-hub by alphagov.

the class MatchingServiceHealthCheckIntegrationTests method getKeyStore.

private IdaKeyStore getKeyStore() throws Base64DecodingException {
    List<KeyPair> encryptionKeyPairs = new ArrayList<>();
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKeyFactory privateKeyFactory = new PrivateKeyFactory();
    PublicKey encryptionPublicKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
    PrivateKey encryptionPrivateKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_ENCRYPTION_KEY.getBytes()));
    encryptionKeyPairs.add(new KeyPair(encryptionPublicKey, encryptionPrivateKey));
    PublicKey publicSigningKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_SIGNING_CERT);
    PrivateKey privateSigningKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_SIGNING_KEY.getBytes()));
    KeyPair signingKeyPair = new KeyPair(publicSigningKey, privateSigningKey);
    return new IdaKeyStore(signingKeyPair, encryptionKeyPairs);
}
Also used : X509CertificateFactory(uk.gov.ida.common.shared.security.X509CertificateFactory) KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) PrivateKeyFactory(uk.gov.ida.common.shared.security.PrivateKeyFactory) PublicKey(java.security.PublicKey) ArrayList(java.util.ArrayList) PublicKeyFactory(uk.gov.ida.common.shared.security.PublicKeyFactory) IdaKeyStore(uk.gov.ida.saml.security.IdaKeyStore)

Example 2 with PublicKeyFactory

use of uk.gov.ida.common.shared.security.PublicKeyFactory in project verify-hub by alphagov.

the class SamlMessageSenderApiResourceTest method getKeyStore.

private static IdaKeyStore getKeyStore() throws Base64DecodingException {
    List<KeyPair> encryptionKeyPairs = new ArrayList<>();
    PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
    PrivateKeyFactory privateKeyFactory = new PrivateKeyFactory();
    PublicKey encryptionPublicKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_ENCRYPTION_CERT);
    PrivateKey encryptionPrivateKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_ENCRYPTION_KEY.getBytes()));
    encryptionKeyPairs.add(new KeyPair(encryptionPublicKey, encryptionPrivateKey));
    PublicKey publicSigningKey = publicKeyFactory.createPublicKey(HUB_TEST_PUBLIC_SIGNING_CERT);
    PrivateKey privateSigningKey = privateKeyFactory.createPrivateKey(Base64.getDecoder().decode(HUB_TEST_PRIVATE_SIGNING_KEY.getBytes()));
    KeyPair signingKeyPair = new KeyPair(publicSigningKey, privateSigningKey);
    return new IdaKeyStore(signingKeyPair, encryptionKeyPairs);
}
Also used : X509CertificateFactory(uk.gov.ida.common.shared.security.X509CertificateFactory) KeyPair(java.security.KeyPair) PrivateKey(java.security.PrivateKey) PrivateKeyFactory(uk.gov.ida.common.shared.security.PrivateKeyFactory) PublicKey(java.security.PublicKey) ArrayList(java.util.ArrayList) PublicKeyFactory(uk.gov.ida.common.shared.security.PublicKeyFactory) IdaKeyStore(uk.gov.ida.saml.security.IdaKeyStore)

Aggregations

KeyPair (java.security.KeyPair)2 PrivateKey (java.security.PrivateKey)2 PublicKey (java.security.PublicKey)2 ArrayList (java.util.ArrayList)2 PrivateKeyFactory (uk.gov.ida.common.shared.security.PrivateKeyFactory)2 PublicKeyFactory (uk.gov.ida.common.shared.security.PublicKeyFactory)2 X509CertificateFactory (uk.gov.ida.common.shared.security.X509CertificateFactory)2 IdaKeyStore (uk.gov.ida.saml.security.IdaKeyStore)2