Search in sources :

Example 56 with Status

use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.

the class IdpIdaStatusUnmarshallerTest method shouldThrowWhenNoMatch.

@Test
public void shouldThrowWhenNoMatch() throws Exception {
    Assertions.assertThrows(IllegalStateException.class, () -> {
        String xml = readXmlFile("status-unknown.xml");
        Response response = stringToOpenSamlObjectTransformer.apply(xml);
        getStatusFrom(response);
    });
}
Also used : Response(org.opensaml.saml.saml2.core.Response) Test(org.junit.jupiter.api.Test)

Example 57 with Status

use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.

the class IdpIdaStatusUnmarshallerTest method shouldMapSamlStatusDetailOfLoaPendingToAuthenticationPending.

@Test
public void shouldMapSamlStatusDetailOfLoaPendingToAuthenticationPending() throws Exception {
    String pendingXml = readXmlFile("status-pending.xml");
    Response pendingResponse = stringToOpenSamlObjectTransformer.apply(pendingXml);
    IdpIdaStatus idpIdaStatus = getStatusFrom(pendingResponse);
    assertThat(idpIdaStatus.getStatusCode()).isEqualTo(IdpIdaStatus.Status.AuthenticationPending);
}
Also used : Response(org.opensaml.saml.saml2.core.Response) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) Test(org.junit.jupiter.api.Test)

Example 58 with Status

use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.

the class IdpIdaStatusUnmarshallerTest method transform_shouldTransformRequesterErrorWithRequestDeniedSubstatus.

@Test
public void transform_shouldTransformRequesterErrorWithRequestDeniedSubstatus() {
    OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
    Status status = samlObjectFactory.createStatus();
    StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
    topLevelStatusCode.setValue(StatusCode.REQUESTER);
    StatusCode subStatusCode = samlObjectFactory.createStatusCode();
    subStatusCode.setValue(StatusCode.REQUEST_DENIED);
    status.setStatusCode(topLevelStatusCode);
    IdpIdaStatus transformedStatus = unmarshaller.fromSaml(status);
    assertThat(transformedStatus).isEqualTo(IdpIdaStatus.requesterError());
}
Also used : StatusBuilder.aStatus(uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) OpenSamlXmlObjectFactory(uk.gov.ida.saml.core.OpenSamlXmlObjectFactory) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) Test(org.junit.jupiter.api.Test)

Example 59 with Status

use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.

the class PassthroughAssertionUnmarshallerTest method transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised.

@Test
public void transform_shouldThrowExceptionIfGpg45StatusIsNotRecognised() {
    Assertions.assertThrows(IllegalStateException.class, () -> {
        String gpg45Status = "status not known";
        Assertion theAssertion = givenAFraudEventAssertion(gpg45Status);
        unmarshaller.fromAssertion(theAssertion);
    });
}
Also used : AssertionBuilder.anAssertion(uk.gov.ida.saml.core.test.builders.AssertionBuilder.anAssertion) Assertion(org.opensaml.saml.saml2.core.Assertion) PassthroughAssertion(uk.gov.ida.saml.core.domain.PassthroughAssertion) Test(org.junit.jupiter.api.Test)

Example 60 with Status

use of org.opensaml.saml.saml2.core.Status in project verify-hub by alphagov.

the class ProtectiveMonitoringLogFormatter method formatAuthnResponse.

public String formatAuthnResponse(Response samlResponse, Direction direction, SignatureStatus signatureStatus) {
    Issuer issuer = samlResponse.getIssuer();
    String issuerString = issuer != null ? issuer.getValue() : "";
    Status status = samlResponse.getStatus();
    StatusCode subStatusCode = status.getStatusCode().getStatusCode();
    String subStatus = subStatusCode != null ? subStatusCode.getValue() : "";
    return String.format(AUTHN_RESPONSE, samlResponse.getID(), samlResponse.getInResponseTo(), direction, samlResponse.getDestination(), issuerString, signatureStatus.valid(), status.getStatusCode().getValue(), subStatus, getStatusDetailValues(status));
}
Also used : SignatureStatus(uk.gov.ida.hub.samlproxy.repositories.SignatureStatus) Status(org.opensaml.saml.saml2.core.Status) Issuer(org.opensaml.saml.saml2.core.Issuer) StatusCode(org.opensaml.saml.saml2.core.StatusCode)

Aggregations

Status (org.opensaml.saml.saml2.core.Status)103 Test (org.junit.jupiter.api.Test)83 Response (org.opensaml.saml.saml2.core.Response)59 StatusCode (org.opensaml.saml.saml2.core.StatusCode)33 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)33 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)27 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)22 SAMLCallback (org.apache.wss4j.common.saml.SAMLCallback)20 Document (org.w3c.dom.Document)20 TransactionIdaStatus (uk.gov.ida.saml.core.domain.TransactionIdaStatus)20 Element (org.w3c.dom.Element)19 StatusBuilder.aStatus (uk.gov.ida.saml.core.test.builders.StatusBuilder.aStatus)19 DateTime (org.joda.time.DateTime)17 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)16 ResponseValidatorTestHelper.createStatus (uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus)16 OpenSamlXmlObjectFactory (uk.gov.ida.saml.core.OpenSamlXmlObjectFactory)14 StatusCodeBuilder.aStatusCode (uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode)14 Crypto (org.apache.wss4j.common.crypto.Crypto)9 SamlStatusCode (uk.gov.ida.saml.core.domain.SamlStatusCode)9 InputStream (java.io.InputStream)8