use of uk.gov.ida.saml.security.IdaKeyStore in project verify-hub by alphagov.
the class HubTransformersFactoryTest method getKeyStore.
private static IdaKeyStore getKeyStore(X509Certificate hubSigningCert) throws Base64DecodingException {
List<KeyPair> encryptionKeyPairs = new ArrayList<>();
PublicKeyFactory publicKeyFactory = new PublicKeyFactory(new X509CertificateFactory());
PrivateKeyFactory privateKeyFactory = new PrivateKeyFactory();
PublicKey encryptionPublicKey = publicKeyFactory.createPublicKey(TestCertificateStrings.HUB_TEST_PUBLIC_ENCRYPTION_CERT);
PrivateKey encryptionPrivateKey = privateKeyFactory.createPrivateKey(Base64.decode(TestCertificateStrings.HUB_TEST_PRIVATE_ENCRYPTION_KEY.getBytes()));
encryptionKeyPairs.add(new KeyPair(encryptionPublicKey, encryptionPrivateKey));
PublicKey publicSigningKey = publicKeyFactory.createPublicKey(TestCertificateStrings.HUB_TEST_PUBLIC_SIGNING_CERT);
PrivateKey privateSigningKey = privateKeyFactory.createPrivateKey(Base64.decode(TestCertificateStrings.HUB_TEST_PRIVATE_SIGNING_KEY.getBytes()));
KeyPair signingKeyPair = new KeyPair(publicSigningKey, privateSigningKey);
return new IdaKeyStore(hubSigningCert, signingKeyPair, encryptionKeyPairs);
}
use of uk.gov.ida.saml.security.IdaKeyStore in project verify-hub by alphagov.
the class MatchingServiceHealthCheckIntegrationTests method getKeyStore.
private IdaKeyStore getKeyStore() {
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);
}
use of uk.gov.ida.saml.security.IdaKeyStore in project verify-hub by alphagov.
the class PrometheusMetricsIntegrationTest method getKeyStore.
private static IdaKeyStore getKeyStore() {
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);
}
use of uk.gov.ida.saml.security.IdaKeyStore 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));
}
use of uk.gov.ida.saml.security.IdaKeyStore in project verify-hub by alphagov.
the class SamlMessageSenderApiResourceTest method getKeyStore.
private static IdaKeyStore getKeyStore() {
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);
}
Aggregations