Search in sources :

Example 1 with ValidatedAssertions

use of uk.gov.ida.saml.security.validators.ValidatedAssertions in project verify-hub by alphagov.

the class CountryAuthnResponseTranslatorServiceTest method setup.

@Before
public void setup() throws Exception {
    IdaSamlBootstrap.bootstrap();
    service = new CountryAuthnResponseTranslatorService(stringToOpenSamlResponseTransformer, responseFromCountryValidator, new IdpIdaStatusUnmarshaller(new IdpIdaStatus.IdpIdaStatusFactory(), new SamlStatusToIdpIdaStatusMappingsFactory()), responseAssertionsFromCountryValidator, validateSamlResponseIssuedByIdpDestination, assertionDecrypter, assertionBlobEncrypter, samlResponseSignatureValidator, samlAssertionsSignatureValidator, new PassthroughAssertionUnmarshaller(new XmlObjectToBase64EncodedStringTransformer<>(), new AuthnContextFactory()));
    Response eidasSAMLResponse = (Response) buildResponseFromFile();
    ValidatedResponse validateEIDASSAMLResponse = new ValidatedResponse(eidasSAMLResponse);
    List<Assertion> decryptedAssertions = eidasSAMLResponse.getAssertions();
    when(samlAuthnResponseTranslatorDto.getSamlResponse()).thenReturn("eidas");
    when(samlAuthnResponseTranslatorDto.getMatchingServiceEntityId()).thenReturn("mid");
    when(stringToOpenSamlResponseTransformer.apply("eidas")).thenReturn(eidasSAMLResponse);
    doNothing().when(responseFromCountryValidator).validate(eidasSAMLResponse);
    when(samlResponseSignatureValidator.validate(eidasSAMLResponse, IDPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(validateEIDASSAMLResponse);
    when(assertionDecrypter.decryptAssertions(validateEIDASSAMLResponse)).thenReturn(decryptedAssertions);
    when(assertionBlobEncrypter.encryptAssertionBlob(eq("mid"), any(String.class))).thenReturn(identityUnderlyingAssertionBlob);
    when(samlAssertionsSignatureValidator.validate(decryptedAssertions, IDPSSODescriptor.DEFAULT_ELEMENT_NAME)).thenReturn(new ValidatedAssertions(decryptedAssertions));
}
Also used : IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) Assertion(org.opensaml.saml.saml2.core.Assertion) ValidatedResponse(uk.gov.ida.saml.security.validators.ValidatedResponse) ValidatedResponse(uk.gov.ida.saml.security.validators.ValidatedResponse) Response(org.opensaml.saml.saml2.core.Response) PassthroughAssertionUnmarshaller(uk.gov.ida.saml.hub.transformers.inbound.PassthroughAssertionUnmarshaller) IdpIdaStatusUnmarshaller(uk.gov.ida.saml.hub.transformers.inbound.IdpIdaStatusUnmarshaller) ValidatedAssertions(uk.gov.ida.saml.security.validators.ValidatedAssertions) AuthnContextFactory(uk.gov.ida.saml.core.transformers.AuthnContextFactory) SamlStatusToIdpIdaStatusMappingsFactory(uk.gov.ida.saml.hub.transformers.inbound.SamlStatusToIdpIdaStatusMappingsFactory) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)1 Assertion (org.opensaml.saml.saml2.core.Assertion)1 Response (org.opensaml.saml.saml2.core.Response)1 AuthnContextFactory (uk.gov.ida.saml.core.transformers.AuthnContextFactory)1 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)1 IdpIdaStatusUnmarshaller (uk.gov.ida.saml.hub.transformers.inbound.IdpIdaStatusUnmarshaller)1 PassthroughAssertionUnmarshaller (uk.gov.ida.saml.hub.transformers.inbound.PassthroughAssertionUnmarshaller)1 SamlStatusToIdpIdaStatusMappingsFactory (uk.gov.ida.saml.hub.transformers.inbound.SamlStatusToIdpIdaStatusMappingsFactory)1 ValidatedAssertions (uk.gov.ida.saml.security.validators.ValidatedAssertions)1 ValidatedResponse (uk.gov.ida.saml.security.validators.ValidatedResponse)1