Search in sources :

Example 1 with ResponseActionDto

use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.

the class PolicyStubRule method receiveAuthnResponseFromCountry.

public void receiveAuthnResponseFromCountry(String sessionId, LevelOfAssurance loaAchieved) throws JsonProcessingException {
    String locationUri = getAuthnResponseFromCountryLocation(sessionId);
    ResponseActionDto responseActionDto = ResponseActionDto.success(new SessionId(sessionId), false, loaAchieved);
    register(locationUri, Status.OK.getStatusCode(), responseActionDto);
}
Also used : ResponseActionDto(uk.gov.ida.hub.samlproxy.domain.ResponseActionDto) SessionId(uk.gov.ida.common.SessionId)

Example 2 with ResponseActionDto

use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.

the class PolicyStubRule method receiveAuthnResponseFromIdp.

public void receiveAuthnResponseFromIdp(String sessionId, LevelOfAssurance loaAchieved) throws JsonProcessingException {
    String locationUri = getAuthnResponseFromIdpLocation(sessionId);
    ResponseActionDto responseActionDto = ResponseActionDto.success(new SessionId(sessionId), false, loaAchieved);
    register(locationUri, Status.OK.getStatusCode(), responseActionDto);
}
Also used : ResponseActionDto(uk.gov.ida.hub.samlproxy.domain.ResponseActionDto) SessionId(uk.gov.ida.common.SessionId)

Example 3 with ResponseActionDto

use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.

the class CountryMetadataConsumerTest method shouldServeCountryMetadata.

@Test
public void shouldServeCountryMetadata() throws Exception {
    // Given
    SessionId sessionId = SessionId.createNewSessionId();
    policyStubRule.receiveAuthnResponseFromCountry(sessionId.toString(), LEVEL_2);
    String response = authnResponseFactory.aSamlResponseFromIdp("a-request", countryMetadata.getCountryMetadataUri(), idpSigningCert, idpSigningKey, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
    // When
    ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
    // Then
    assertThat(post.getSessionId()).isEqualTo(sessionId);
    assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
Also used : ResponseActionDto(uk.gov.ida.hub.samlproxy.domain.ResponseActionDto) SamlRequestDto(uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto) SessionId(uk.gov.ida.common.SessionId) Test(org.junit.Test)

Example 4 with ResponseActionDto

use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.

the class MetadataConsumerTests method shouldAllowRequestsWhenMetadataIsAvailableAndValid.

@Test
public void shouldAllowRequestsWhenMetadataIsAvailableAndValid() throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    policyStubRule.register(UriBuilder.fromPath(Urls.PolicyUrls.IDP_AUTHN_RESPONSE_RESOURCE).build(sessionId).getPath(), 200, ResponseActionDto.success(sessionId, true, LEVEL_2));
    String response = authnResponseFactory.aSamlResponseFromIdp(TestEntityIds.STUB_IDP_ONE, STUB_IDP_PUBLIC_PRIMARY_CERT, STUB_IDP_PUBLIC_PRIMARY_PRIVATE_KEY, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
    ResponseActionDto post = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1")).readEntity(ResponseActionDto.class);
    assertThat(post.getSessionId()).isEqualTo(sessionId);
    assertThat(post.getLoaAchieved()).isEqualTo(LEVEL_2);
}
Also used : ResponseActionDto(uk.gov.ida.hub.samlproxy.domain.ResponseActionDto) SamlRequestDto(uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto) SessionId(uk.gov.ida.common.SessionId) Test(org.junit.Test)

Example 5 with ResponseActionDto

use of uk.gov.ida.hub.samlproxy.domain.ResponseActionDto in project verify-hub by alphagov.

the class SamlMessageReceiverApiTest method handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration.

@Test
public void handleResponsePost_shouldReturnActionDtoOnSuccessfulRegistration() throws MarshallingException, SignatureException {
    ResponseActionDto responseActionDto = ResponseActionDto.success(SESSION_ID, true, LevelOfAssurance.LEVEL_2);
    when(stringSamlResponseTransformer.apply(SAML_REQUEST)).thenReturn(validSamlResponse);
    when(samlMessageSignatureValidator.validate(any(org.opensaml.saml.saml2.core.Response.class), any(QName.class))).thenReturn(SamlValidationResponse.aValidResponse());
    when(sessionProxy.receiveAuthnResponseFromIdp(any(SamlAuthnResponseContainerDto.class), eq(SESSION_ID))).thenReturn(responseActionDto);
    Response response = samlMessageReceiverApi.handleResponsePost(SAML_REQUEST_DTO);
    assertThat(response.getStatus()).isEqualTo(Status.OK.getStatusCode());
    assertThat(response.getEntity()).isEqualTo(responseActionDto);
}
Also used : ResponseBuilder.aValidIdpResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aValidIdpResponse) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlValidationResponse(uk.gov.ida.saml.core.validation.SamlValidationResponse) Response(javax.ws.rs.core.Response) ResponseActionDto(uk.gov.ida.hub.samlproxy.domain.ResponseActionDto) QName(javax.xml.namespace.QName) SamlAuthnResponseContainerDto(uk.gov.ida.hub.samlproxy.domain.SamlAuthnResponseContainerDto) Test(org.junit.Test)

Aggregations

ResponseActionDto (uk.gov.ida.hub.samlproxy.domain.ResponseActionDto)5 SessionId (uk.gov.ida.common.SessionId)4 Test (org.junit.Test)3 SamlRequestDto (uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto)2 Response (javax.ws.rs.core.Response)1 QName (javax.xml.namespace.QName)1 SamlAuthnResponseContainerDto (uk.gov.ida.hub.samlproxy.domain.SamlAuthnResponseContainerDto)1 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)1 ResponseBuilder.aValidIdpResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aValidIdpResponse)1 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)1