org.opensaml.saml.security.impl.SAMLSignatureProfileValidator Java Examples

The following examples show how to use org.opensaml.saml.security.impl.SAMLSignatureProfileValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsumerServlet.java    From OpenSAML-ref-project-demo-v3 with Apache License 2.0 6 votes vote down vote up
private void verifyAssertionSignature(Assertion assertion) {

        if (!assertion.isSigned()) {
            throw new RuntimeException("The SAML Assertion was not signed");
        }

        try {
            SAMLSignatureProfileValidator profileValidator = new SAMLSignatureProfileValidator();
            profileValidator.validate(assertion.getSignature());

            SignatureValidator.validate(assertion.getSignature(), IDPCredentials.getCredential());

            logger.info("SAML Assertion signature verified");
        } catch (SignatureException e) {
            e.printStackTrace();
        }

    }
 
Example #2
Source File: AuthenticationHandlerSAML2.java    From sling-whiteboard with Apache License 2.0 5 votes vote down vote up
private void verifyAssertionSignature(final Assertion assertion) {
    if (!assertion.isSigned()) {
        logger.error("Halting");
        throw new RuntimeException("The SAML Assertion was not signed!");
    }
    try {
        SAMLSignatureProfileValidator profileValidator = new SAMLSignatureProfileValidator();
        profileValidator.validate(assertion.getSignature());
        // use IDP Cert to verify signature
        SignatureValidator.validate(assertion.getSignature(), this.getIdpVerificationCert());
        logger.info("SAML Assertion signature verified");
    } catch (SignatureException e) {
        throw new RuntimeException("SAML Assertion signature problem", e);
    }
}