use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class ResponseAssertionsFromIdpValidator method validate.
public void validate(ValidatedResponse validatedResponse, ValidatedAssertions validatedAssertions) {
validatedAssertions.getAssertions().forEach(assertion -> identityProviderAssertionValidator.validate(assertion, validatedResponse.getInResponseTo(), hubEntityId));
if (!validatedResponse.isSuccess())
return;
Assertion matchingDatasetAssertion = getMatchingDatasetAssertion(validatedAssertions);
Assertion authnStatementAssertion = getAuthnStatementAssertion(validatedAssertions);
if (authnStatementAssertion.getAuthnStatements().size() > 1) {
throw new SamlValidationException(multipleAuthnStatements());
}
matchingDatasetAssertionValidator.validate(matchingDatasetAssertion, validatedResponse.getIssuer().getValue());
authnStatementAssertionValidator.validate(authnStatementAssertion);
identityProviderAssertionValidator.validateConsistency(authnStatementAssertion, matchingDatasetAssertion);
ipAddressValidator.validate(authnStatementAssertion);
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class DestinationValidator method validate.
/*
Validate that the destination sent to us matches the configured host & the given path
Path is added because we have to do validation on both Responses & Requests
*/
public void validate(String destination) {
if (destination == null)
throw new SamlValidationException(destinationMissing(expectedUri));
URI destinationURI = URI.create(destination);
URI destinationURIWithoutPort;
destinationURIWithoutPort = uriWithoutPort(destinationURI, destinationURI.getPath());
if (!expectedUri.equals(destinationURIWithoutPort))
throw new SamlValidationException(destinationEmpty(expectedUri, destination));
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class EncryptedResponseFromIdpValidator method validateResponse.
private void validateResponse(Response response) {
if (Strings.isNullOrEmpty(response.getID()))
throw new SamlValidationException(missingId());
if (response.getIssueInstant() == null)
throw new SamlValidationException(missingIssueInstant(response.getID()));
Signature signature = response.getSignature();
if (signature == null)
throw new SamlValidationException(missingSignature());
if (!isSignaturePresent(signature))
throw new SamlValidationException(signatureNotSigned());
validateStatus(response.getStatus());
validateAssertionPresence(response);
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class EncryptedResponseFromIdpValidator method fail.
private void fail(Status status) {
StatusCode statusCode = status.getStatusCode();
StatusCode subStatusCode = statusCode.getStatusCode();
if (subStatusCode == null)
throw new SamlValidationException(invalidStatusCode(statusCode.getValue()));
SamlValidationSpecificationFailure failure = invalidSubStatusCode(subStatusCode.getValue(), statusCode.getValue());
throw new SamlValidationException(failure);
}
use of uk.gov.ida.saml.hub.exception.SamlValidationException in project verify-hub by alphagov.
the class EncryptedResponseFromMatchingServiceValidator method validateResponse.
private void validateResponse(Response response) {
if (Strings.isNullOrEmpty(response.getID()))
throw new SamlValidationException(missingId());
Signature signature = response.getSignature();
if (signature == null)
throw new SamlValidationException(missingSignature());
if (!isSignaturePresent(signature))
throw new SamlValidationException(signatureNotSigned());
validateStatusAndSubStatus(response);
validateAssertionPresence(response);
}
Aggregations