Search in sources :

Example 1 with SessionId

use of uk.gov.ida.common.SessionId 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 SessionId

use of uk.gov.ida.common.SessionId 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 SessionId

use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.

the class CountryMetadataConsumerTest method shouldReturnErrorWhenValidatingEidasAuthnResponseContainingInvalidSignature.

@Test
public void shouldReturnErrorWhenValidatingEidasAuthnResponseContainingInvalidSignature() throws Exception {
    // Given
    SessionId sessionId = SessionId.createNewSessionId();
    String response = authnResponseFactory.aSamlResponseFromIdp("a-request", countryMetadata.getCountryMetadataUri(), anotherIdpSigningCert, anotherIdpSigningKey, "", SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
    // When
    Response responseFromSamlProxy = postSAML(new SamlRequestDto(response, sessionId.getSessionId(), "127.0.0.1"));
    // Then
    assertThat(responseFromSamlProxy.getStatus()).isEqualTo(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
}
Also used : Response(javax.ws.rs.core.Response) SamlRequestDto(uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto) SessionId(uk.gov.ida.common.SessionId) Test(org.junit.Test)

Example 4 with SessionId

use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.

the class CountryAuthnResponseTranslatorResourceTest method createAuthnResponseSignedByKeyPair.

private SamlAuthnResponseTranslatorDto createAuthnResponseSignedByKeyPair(String publicKey, String privateKey) throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    String samlResponse = authnResponseFactory.aSamlResponseFromCountry("a-request", samlEngineAppRule.getCountryMetadataUri(), publicKey, privateKey, DESTINATION, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM, EncryptionConstants.ALGO_ID_BLOCKCIPHER_AES256_GCM, EidasAuthnContext.EIDAS_LOA_SUBSTANTIAL, DESTINATION, samlEngineAppRule.getCountryMetadataUri());
    return new SamlAuthnResponseTranslatorDto(samlResponse, sessionId, "127.0.0.1", matchingServiceEntityId);
}
Also used : SamlAuthnResponseTranslatorDto(uk.gov.ida.hub.samlengine.contracts.SamlAuthnResponseTranslatorDto) SessionId(uk.gov.ida.common.SessionId)

Example 5 with SessionId

use of uk.gov.ida.common.SessionId in project verify-hub by alphagov.

the class AttributeQueryRequestRunnableTest method run_shouldNotSendResponse_IfAttributeQueryHasTimedOut_AfterSendingMessage.

@Test
public void run_shouldNotSendResponse_IfAttributeQueryHasTimedOut_AfterSendingMessage() throws Exception {
    final Element matchingServiceResponse = XmlUtils.convertToElement("<someResponse/>");
    when(executeAttributeQueryRequest.execute(sessionId, attributeQueryContainerDto)).thenReturn(matchingServiceResponse);
    doNothing().doThrow(new AttributeQueryTimeoutException()).when(timeoutEvaluator).hasAttributeQueryTimedOut(attributeQueryContainerDto);
    attributeQueryRequestRunnable.run();
    verify(executeAttributeQueryRequest).execute(sessionId, attributeQueryContainerDto);
    verify(hubMatchingServiceResponseReceiverProxy, never()).notifyHubOfAResponseFromMatchingService(any(SessionId.class), any(String.class));
    verify(eventSinkProxy, times(1)).logHubEvent(isA(EventSinkHubEvent.class));
    verify(eventEmitter, times(1)).record(isA(EventSinkHubEvent.class));
}
Also used : Element(org.w3c.dom.Element) AttributeQueryTimeoutException(uk.gov.ida.hub.samlsoapproxy.exceptions.AttributeQueryTimeoutException) SessionId(uk.gov.ida.common.SessionId) EventSinkHubEvent(uk.gov.ida.hub.shared.eventsink.EventSinkHubEvent) Test(org.junit.jupiter.api.Test)

Aggregations

SessionId (uk.gov.ida.common.SessionId)41 Test (org.junit.jupiter.api.Test)31 URI (java.net.URI)17 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)15 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)15 Response (javax.ws.rs.core.Response)13 Response (org.opensaml.saml.saml2.core.Response)12 Element (org.w3c.dom.Element)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.samlproxy.contracts.AuthnResponseFromHubContainerDto)6 SamlRequestDto (uk.gov.ida.hub.samlproxy.contracts.SamlRequestDto)5 ResponseActionDto (uk.gov.ida.hub.samlproxy.domain.ResponseActionDto)5 OutboundResponseFromHub (uk.gov.ida.saml.core.domain.OutboundResponseFromHub)5 HubTransformersFactory (uk.gov.ida.saml.hub.api.HubTransformersFactory)4 Timed (com.codahale.metrics.annotation.Timed)3 Consumes (javax.ws.rs.Consumes)3 POST (javax.ws.rs.POST)3 Produces (javax.ws.rs.Produces)3 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)3 SamlMessage (uk.gov.ida.hub.samlproxy.controllogic.SamlMessageSenderHandler.SamlMessage)3