Search in sources :

Example 1 with UnableToGenerateSamlException

use of uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException in project verify-hub by alphagov.

the class RpErrorResponseGeneratorService method generate.

public SamlMessageDto generate(RequestForErrorResponseFromHubDto requestForErrorResponseFromHubDto) {
    try {
        final OutboundResponseFromHub response = new OutboundResponseFromHub(requestForErrorResponseFromHubDto.getResponseId(), requestForErrorResponseFromHubDto.getInResponseTo(), hubEntityId, DateTime.now(), TransactionIdaStatus.valueOf(requestForErrorResponseFromHubDto.getStatus().name()), empty(), requestForErrorResponseFromHubDto.getAssertionConsumerServiceUri());
        final String errorResponse = outboundResponseFromHubToResponseTransformerFactory.get(requestForErrorResponseFromHubDto.getAuthnRequestIssuerEntityId()).apply(response);
        return new SamlMessageDto(errorResponse);
    } catch (Exception e) {
        throw new UnableToGenerateSamlException("Unable to generate RP error response", e, Level.ERROR);
    }
}
Also used : SamlMessageDto(uk.gov.ida.hub.samlengine.domain.SamlMessageDto) OutboundResponseFromHub(uk.gov.ida.saml.core.domain.OutboundResponseFromHub) UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException) UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException)

Example 2 with UnableToGenerateSamlException

use of uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException in project verify-hub by alphagov.

the class AttributeQueryGenerator method newCreateAttributeQueryContainer.

public uk.gov.ida.hub.samlengine.contracts.AttributeQueryContainerDto newCreateAttributeQueryContainer(final T attributeQueryRequest, final URI msaUri, final String matchingServiceEntityId, final DateTime matchingServiceRequestTimeOut, boolean onboarding) {
    try {
        entityToEncryptForLocator.addEntityIdForRequestId(attributeQueryRequest.getId(), matchingServiceEntityId);
        String samlRequest = XmlUtils.writeToString(attributeQueryRequestTransformer.apply(attributeQueryRequest));
        return new uk.gov.ida.hub.samlengine.contracts.AttributeQueryContainerDto(attributeQueryRequest.getId(), attributeQueryRequest.getIssuer(), samlRequest, msaUri, matchingServiceRequestTimeOut, onboarding);
    } catch (Exception e) {
        throw new UnableToGenerateSamlException("failed to create attribute query request", e, Level.ERROR);
    } finally {
        entityToEncryptForLocator.removeEntityIdForRequestId(attributeQueryRequest.getId());
    }
}
Also used : AttributeQueryContainerDto(uk.gov.ida.hub.samlengine.domain.AttributeQueryContainerDto) UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException) UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException)

Example 3 with UnableToGenerateSamlException

use of uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException in project verify-hub by alphagov.

the class RpAuthnResponseGeneratorService method generate.

public AuthnResponseFromHubContainerDto generate(ResponseFromHubDto responseFromHub) {
    String entityIdForEncryption = responseFromHub.getAuthnRequestIssuerEntityId();
    String originalRequestId = responseFromHub.getInResponseTo();
    try {
        assignableEntityToEncryptForLocator.addEntityIdForRequestId(originalRequestId, entityIdForEncryption);
        return createSuccessResponse(responseFromHub);
    } catch (Exception e) {
        throw new UnableToGenerateSamlException("Unable to generate RP authn response", e, Level.ERROR);
    } finally {
        assignableEntityToEncryptForLocator.removeEntityIdForRequestId(originalRequestId);
    }
}
Also used : UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException) UnableToGenerateSamlException(uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException)

Aggregations

UnableToGenerateSamlException (uk.gov.ida.hub.samlengine.exceptions.UnableToGenerateSamlException)3 AttributeQueryContainerDto (uk.gov.ida.hub.samlengine.domain.AttributeQueryContainerDto)1 SamlMessageDto (uk.gov.ida.hub.samlengine.domain.SamlMessageDto)1 OutboundResponseFromHub (uk.gov.ida.saml.core.domain.OutboundResponseFromHub)1