use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class EncryptedResponseFromMatchingServiceValidator method validateStatusAndSubStatus.
protected void validateStatusAndSubStatus(Response response) {
StatusCode statusCode = response.getStatus().getStatusCode();
String statusCodeValue = statusCode.getValue();
StatusCode subStatusCode = statusCode.getStatusCode();
if (StatusCode.REQUESTER.equals(statusCodeValue))
return;
if (subStatusCode == null)
throw new SamlValidationException(missingSubStatus());
String subStatusCodeValue = subStatusCode.getValue();
if (!StatusCode.RESPONDER.equals(statusCodeValue)) {
validateSuccessResponse(statusCodeValue, subStatusCodeValue);
} else {
validateResponderError(subStatusCodeValue);
}
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidator method validateAttribute.
private void validateAttribute(Attribute attribute) {
String attributeName = attribute.getName();
if (!VALID_ATTRIBUTE_NAMES_1_1.contains(attributeName))
throw new SamlValidationException(mdsAttributeNotRecognised(attributeName));
List<XMLObject> attributeValues = attribute.getAttributeValues();
if (attributeValues.isEmpty())
throw new SamlValidationException(emptyAttribute(attributeName));
QName schemaType = attributeValues.get(0).getSchemaType();
if (!VALID_TYPE_FOR_ATTRIBUTE.get(attributeName).equals(schemaType))
throw new SamlValidationException(attributeWithIncorrectType(attributeName, VALID_TYPE_FOR_ATTRIBUTE.get(attributeName), schemaType));
if (!VALID_ATTRIBUTE_NAME_FORMATS.contains(attribute.getNameFormat()))
warn(invalidAttributeNameFormat(attribute.getNameFormat()));
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class MatchingDatasetAssertionValidator method validateAttributes.
private void validateAttributes(Assertion assertion) {
final List<AttributeStatement> attributeStatements = assertion.getAttributeStatements();
if (attributeStatements.isEmpty())
throw new SamlValidationException(mdsStatementMissing());
if (attributeStatements.size() > 1)
throw new SamlValidationException(mdsMultipleStatements());
final List<Attribute> attributes = attributeStatements.get(0).getAttributes();
if (attributes.isEmpty())
throw new SamlValidationException(attributeStatementEmpty(assertion.getID()));
attributes.forEach(this::validateAttribute);
}
Aggregations