Search in sources :

Example 6 with OutboundResponseFromHub

use of uk.gov.ida.saml.core.domain.OutboundResponseFromHub in project verify-hub by alphagov.

the class RpAuthnResponseGeneratorService method createSuccessResponse.

private AuthnResponseFromHubContainerDto createSuccessResponse(final ResponseFromHubDto responseFromHub) {
    String authnRequestIssuerEntityId = responseFromHub.getAuthnRequestIssuerEntityId();
    final OutboundResponseFromHub response = new OutboundResponseFromHub(responseFromHub.getResponseId(), responseFromHub.getInResponseTo(), hubEntityId, DateTime.now(), TransactionIdaStatus.valueOf(responseFromHub.getStatus().name()), responseFromHub.getMatchingServiceAssertion(), responseFromHub.getAssertionConsumerServiceUri());
    String samlMessage = outboundResponseFromHubToResponseTransformerFactory.get(authnRequestIssuerEntityId).apply(response);
    return new AuthnResponseFromHubContainerDto(samlMessage, responseFromHub.getAssertionConsumerServiceUri(), responseFromHub.getRelayState(), responseFromHub.getResponseId());
}
Also used : AuthnResponseFromHubContainerDto(uk.gov.ida.hub.samlengine.contracts.AuthnResponseFromHubContainerDto) OutboundResponseFromHub(uk.gov.ida.saml.core.domain.OutboundResponseFromHub)

Example 7 with OutboundResponseFromHub

use of uk.gov.ida.saml.core.domain.OutboundResponseFromHub in project verify-hub by alphagov.

the class SamlMessageSenderApiResourceTest method sendSignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation.

@Test
public void sendSignedJsonAuthnResponseFromHub_shouldRespondWithNextLocation() throws Exception {
    SessionId sessionId = SessionId.createNewSessionId();
    URI nextLocationUri = URI.create("http://blah");
    String requestId = UUID.randomUUID().toString();
    ResponseAssertionSigner responseAssertionSigner = new ResponseAssertionSigner(new SignatureFactory(new IdaKeyStoreCredentialRetriever(getKeyStore()), SIGNATURE_ALGORITHM, DIGEST_ALGORITHM));
    Function<OutboundResponseFromHub, String> outboundResponseFromHubToStringTransformer = new HubTransformersFactory().getOutboundResponseFromHubToStringTransformer(new HardCodedKeyStore(HUB_ENTITY_ID), getKeyStore(), new IdpHardCodedEntityToEncryptForLocator(), responseAssertionSigner, SIGNATURE_ALGORITHM, DIGEST_ALGORITHM);
    OutboundResponseFromHub authnResponseFromHub = anAuthnResponse().withInResponseTo(requestId).withIssuerId(HUB_ENTITY_ID).withTransactionIdaStatus(TransactionIdaStatus.Success).buildOutboundResponseFromHub();
    String samlString = outboundResponseFromHubToStringTransformer.apply(authnResponseFromHub);
    AuthnResponseFromHubContainerDto authnResponseFromHubContainerDto = new AuthnResponseFromHubContainerDto(samlString, nextLocationUri, com.google.common.base.Optional.absent(), authnResponseFromHub.getId());
    policyStubRule.anAuthnResponseFromHubToRp(sessionId, authnResponseFromHubContainerDto);
    javax.ws.rs.core.Response response = getResponseFromSamlProxy(Urls.SamlProxyUrls.SEND_RESPONSE_FROM_HUB_API_RESOURCE, sessionId);
    assertThat(response.readEntity(SamlMessageSenderHandler.SamlMessage.class).getPostEndpoint()).isEqualTo(nextLocationUri.toASCIIString());
}
Also used : HubTransformersFactory(uk.gov.ida.saml.hub.api.HubTransformersFactory) HardCodedKeyStore(uk.gov.ida.saml.core.test.HardCodedKeyStore) AuthnResponseFromHubContainerDto(uk.gov.ida.hub.samlproxy.contracts.AuthnResponseFromHubContainerDto) URI(java.net.URI) ResponseAssertionSigner(uk.gov.ida.saml.core.transformers.outbound.decorators.ResponseAssertionSigner) IdaKeyStoreCredentialRetriever(uk.gov.ida.saml.security.IdaKeyStoreCredentialRetriever) OutboundResponseFromHub(uk.gov.ida.saml.core.domain.OutboundResponseFromHub) Response(javax.ws.rs.core.Response) SignatureFactory(uk.gov.ida.saml.security.SignatureFactory) SessionId(uk.gov.ida.common.SessionId) Test(org.junit.Test)

Aggregations

OutboundResponseFromHub (uk.gov.ida.saml.core.domain.OutboundResponseFromHub)7 URI (java.net.URI)5 Response (javax.ws.rs.core.Response)5 Test (org.junit.Test)5 SessionId (uk.gov.ida.common.SessionId)5 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.samlproxy.contracts.AuthnResponseFromHubContainerDto)5 HardCodedKeyStore (uk.gov.ida.saml.core.test.HardCodedKeyStore)3 HubTransformersFactory (uk.gov.ida.saml.hub.api.HubTransformersFactory)3 AuthnResponseFromHubContainerDto (uk.gov.ida.hub.samlengine.contracts.AuthnResponseFromHubContainerDto)1 SamlMessageDto (uk.gov.ida.hub.samlengine.domain.SamlMessageDto)1 UnableToGenerateSamlException (uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException)1 ResponseAssertionSigner (uk.gov.ida.saml.core.transformers.outbound.decorators.ResponseAssertionSigner)1 IdaKeyStoreCredentialRetriever (uk.gov.ida.saml.security.IdaKeyStoreCredentialRetriever)1 SignatureFactory (uk.gov.ida.saml.security.SignatureFactory)1