SAMLSignatureProfileValidator validator = new SAMLSignatureProfileValidator();
try {
validator.validate(signature);
} catch (ValidationException e) {
throw new SamlException("SAMLSignatureProfileValidator failed to validate signature", e);
}
CriteriaSet criteriaSet = new CriteriaSet();
criteriaSet.add(new UsageCriteria(UsageType.SIGNING));
criteriaSet.add(new MetadataCriteria(IDPSSODescriptor.DEFAULT_ELEMENT_NAME, SAMLConstants.SAML20P_NS));
criteriaSet.add(new EntityIDCriteria(idpEntityId));
boolean valid = false;
try {
valid = trustEngine.validate(signature, criteriaSet);
} catch (SecurityException e) {
throw new SamlException("An error occured during signature validation", e);
}
if (!valid) {
throw new SamlException("Signature is not trusted");
}
}