use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class MatchingServiceIdaStatusUnmarshallerTest method shouldTransformCreateFailureCaseFromMatchingService.
@Test
public void shouldTransformCreateFailureCaseFromMatchingService() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status status = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.RESPONDER);
status.setStatusCode(topLevelStatusCode);
StatusCode subStatusCode = samlObjectFactory.createStatusCode();
subStatusCode.setValue(SamlStatusCode.CREATE_FAILURE);
topLevelStatusCode.setStatusCode(subStatusCode);
MatchingServiceIdaStatus transformedStatus = unmarshaller.fromSaml(status);
assertThat(transformedStatus).isEqualTo(MatchingServiceIdaStatus.UserAccountCreationFailed);
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class TransactionIdaStatusUnmarshallerTest method transform_shouldTransformAuthnFailed.
@Test
public void transform_shouldTransformAuthnFailed() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status status = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.RESPONDER);
status.setStatusCode(topLevelStatusCode);
StatusCode subStatusCode = samlObjectFactory.createStatusCode();
subStatusCode.setValue(StatusCode.AUTHN_FAILED);
topLevelStatusCode.setStatusCode(subStatusCode);
TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(status);
assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.AuthenticationFailed);
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class TransactionIdaStatusUnmarshallerTest method transform_shouldTransformSuccessWithNoSubCode.
@Test
public void transform_shouldTransformSuccessWithNoSubCode() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status originalStatus = samlObjectFactory.createStatus();
StatusCode successStatusCode = samlObjectFactory.createStatusCode();
successStatusCode.setValue(StatusCode.SUCCESS);
originalStatus.setStatusCode(successStatusCode);
TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.Success);
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class TransactionIdaStatusUnmarshallerTest method transform_shouldTransformNoAuthenticationContext.
@Test
public void transform_shouldTransformNoAuthenticationContext() {
OpenSamlXmlObjectFactory samlObjectFactory = new OpenSamlXmlObjectFactory();
Status originalStatus = samlObjectFactory.createStatus();
StatusCode topLevelStatusCode = samlObjectFactory.createStatusCode();
topLevelStatusCode.setValue(StatusCode.RESPONDER);
StatusCode subStatusCode = samlObjectFactory.createStatusCode();
subStatusCode.setValue(StatusCode.NO_AUTHN_CONTEXT);
topLevelStatusCode.setStatusCode(subStatusCode);
originalStatus.setStatusCode(topLevelStatusCode);
TransactionIdaStatus transformedStatus = unmarshaller.fromSaml(originalStatus);
assertThat(transformedStatus).isEqualTo(TransactionIdaStatus.NoAuthenticationContext);
}
use of org.opensaml.saml.saml2.core.StatusCode in project verify-hub by alphagov.
the class HealthCheckResponseFromMatchingServiceValidator method validateStatusAndSubStatus.
protected void validateStatusAndSubStatus(Response response) {
StatusCode statusCode = response.getStatus().getStatusCode();
if (StatusCode.REQUESTER.equals(statusCode.getValue()))
return;
if (statusCode.getStatusCode() == null)
throw new SamlValidationException(missingSubStatus());
String statusCodeValue = statusCode.getValue();
if (!StatusCode.SUCCESS.equals(statusCodeValue))
throw new SamlValidationException(invalidStatusCode(statusCodeValue));
String subStatusCodeValue = statusCode.getStatusCode().getValue();
if (!SamlStatusCode.HEALTHY.equals(subStatusCodeValue)) {
throw new SamlValidationException(invalidSubStatusCode(subStatusCodeValue, StatusCode.SUCCESS));
}
}
Aggregations