use of uk.gov.ida.common.shared.security.PrivateKeyFactory 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);
}
use of uk.gov.ida.common.shared.security.PrivateKeyFactory 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);
}
use of uk.gov.ida.common.shared.security.PrivateKeyFactory in project verify-hub by alphagov.
the class ExecuteAttributeQueryRequestTest method run_shouldThrowCertChainValidationExceptionOnResponse.
@Test
public void run_shouldThrowCertChainValidationExceptionOnResponse() throws Exception {
when(attributeQueryRequestClient.sendQuery(any(Element.class), anyString(), any(SessionId.class), any(URI.class))).thenReturn(matchingServiceResponse);
final BasicX509Credential x509Credential = new BasicX509Credential(new X509CertificateFactory().createCertificate(UNCHAINED_PUBLIC_CERT), new PrivateKeyFactory().createPrivateKey(Base64.decode(UNCHAINED_PRIVATE_KEY.getBytes())));
Response response = aResponse().withSigningCredential(x509Credential).withIssuer(anIssuer().withIssuerId("issuer-id").build()).build();
when(elementToResponseTransformer.apply(matchingServiceResponse)).thenReturn(response);
executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto);
verify(matchingResponseSignatureValidator).validate(response, AttributeAuthorityDescriptor.DEFAULT_ELEMENT_NAME);
}
Aggregations