Search in sources :

Example 61 with Response

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

the class EncryptedResponseFromIdpValidatorTest method validateStatus_shouldThrowExceptionIfRequesterHasASubStatus.

@Test
public void validateStatus_shouldThrowExceptionIfRequesterHasASubStatus() throws Exception {
    StatusCode subStatusCode = createSubStatusCode();
    Status status = createStatus(StatusCode.REQUESTER, subStatusCode);
    Response response = aResponse().withStatus(status).build();
    assertValidationFailure(response, invalidSubStatusCode(subStatusCode.getValue(), StatusCode.REQUESTER));
}
Also used : ResponseValidatorTestHelper.createStatus(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlTransformationErrorFactory.invalidSubStatusCode(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidSubStatusCode) ResponseValidatorTestHelper.createSubStatusCode(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createSubStatusCode) StatusCode(org.opensaml.saml.saml2.core.StatusCode) SamlTransformationErrorFactory.invalidStatusCode(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.invalidStatusCode) StatusCodeBuilder.aStatusCode(uk.gov.ida.saml.core.test.builders.StatusCodeBuilder.aStatusCode) Test(org.junit.jupiter.api.Test)

Example 62 with Response

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

the class EncryptedResponseFromIdpValidatorTest method validateStatus_shouldThrowExceptionIfStatusIsResponderWithNoSubStatus.

@Test
public void validateStatus_shouldThrowExceptionIfStatusIsResponderWithNoSubStatus() throws Exception {
    Status status = createStatus(StatusCode.RESPONDER);
    Response response = aResponse().withStatus(status).withNoDefaultAssertion().build();
    assertValidationFailure(response, invalidStatusCode(StatusCode.RESPONDER));
}
Also used : ResponseValidatorTestHelper.createStatus(uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus) Status(org.opensaml.saml.saml2.core.Status) IdpIdaStatus(uk.gov.ida.saml.hub.domain.IdpIdaStatus) Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Test(org.junit.jupiter.api.Test)

Example 63 with Response

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

the class EncryptedResponseFromIdpValidatorTest method validate_shouldThrowExceptionIfIssuerIdIsMissing.

@Test
public void validate_shouldThrowExceptionIfIssuerIdIsMissing() throws Exception {
    Issuer issuer = anIssuer().withIssuerId(null).build();
    Response response = aResponse().withIssuer(issuer).build();
    assertValidationFailure(response, emptyIssuer());
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlTransformationErrorFactory.missingIssuer(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.missingIssuer) IssuerBuilder.anIssuer(uk.gov.ida.saml.core.test.builders.IssuerBuilder.anIssuer) SamlTransformationErrorFactory.emptyIssuer(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.emptyIssuer) Issuer(org.opensaml.saml.saml2.core.Issuer) Test(org.junit.jupiter.api.Test)

Example 64 with Response

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

the class EncryptedResponseFromIdpValidatorTest method validate_shouldThrowExceptionIfIdIsMissing.

@Test
public void validate_shouldThrowExceptionIfIdIsMissing() throws Exception {
    Response response = aResponse().withId(null).build();
    assertValidationFailure(response, missingId());
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) Test(org.junit.jupiter.api.Test)

Example 65 with Response

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

the class EncryptedResponseFromIdpValidatorTest method validateIssuer_shouldThrowExceptionIfFormatAttributeHasInvalidValue.

@Test
public void validateIssuer_shouldThrowExceptionIfFormatAttributeHasInvalidValue() throws Exception {
    String invalidFormat = "goo";
    Issuer issuer = anIssuer().withFormat(invalidFormat).build();
    Response response = aResponse().withIssuer(issuer).build();
    assertValidationFailure(response, illegalIssuerFormat(invalidFormat, NameIDType.ENTITY));
}
Also used : Response(org.opensaml.saml.saml2.core.Response) ResponseBuilder.aResponse(uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse) SamlTransformationErrorFactory.missingIssuer(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.missingIssuer) IssuerBuilder.anIssuer(uk.gov.ida.saml.core.test.builders.IssuerBuilder.anIssuer) SamlTransformationErrorFactory.emptyIssuer(uk.gov.ida.saml.core.errors.SamlTransformationErrorFactory.emptyIssuer) Issuer(org.opensaml.saml.saml2.core.Issuer) Test(org.junit.jupiter.api.Test)

Aggregations

Response (org.opensaml.saml.saml2.core.Response)245 Test (org.junit.jupiter.api.Test)148 ResponseBuilder.aResponse (uk.gov.ida.saml.core.test.builders.ResponseBuilder.aResponse)84 Assertion (org.opensaml.saml.saml2.core.Assertion)62 EncryptedAssertion (org.opensaml.saml.saml2.core.EncryptedAssertion)51 Element (org.w3c.dom.Element)44 Status (org.opensaml.saml.saml2.core.Status)37 DateTime (org.joda.time.DateTime)36 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)31 Document (org.w3c.dom.Document)31 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)26 SAMLCallback (org.apache.wss4j.common.saml.SAMLCallback)19 SubjectConfirmationDataBean (org.apache.wss4j.common.saml.bean.SubjectConfirmationDataBean)19 SamlValidationResponse (uk.gov.ida.saml.core.validation.SamlValidationResponse)19 IdpIdaStatus (uk.gov.ida.saml.hub.domain.IdpIdaStatus)18 Authentication (org.springframework.security.core.Authentication)16 ResponseValidatorTestHelper.createStatus (uk.gov.ida.saml.hub.validators.response.helpers.ResponseValidatorTestHelper.createStatus)16 Crypto (org.apache.wss4j.common.crypto.Crypto)15 NameID (org.opensaml.saml.saml2.core.NameID)14 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)13