Search in sources :

Example 1 with SAMLSignatureRequiredException

use of org.pac4j.saml.exceptions.SAMLSignatureRequiredException in project pac4j by pac4j.

the class SAML2DefaultResponseValidator method validateAssertionSignature.

/**
 * Validate assertion signature. If none is found and the SAML response did not have one and the SP requires
 * the assertions to be signed, the validation fails.
 *
 * @param signature the signature
 * @param context   the context
 * @param engine    the engine
 */
protected final void validateAssertionSignature(final Signature signature, final SAML2MessageContext context, final SignatureTrustEngine engine) {
    final SAMLPeerEntityContext peerContext = context.getSAMLPeerEntityContext();
    if (signature != null) {
        final String entityId = peerContext.getEntityId();
        validateSignature(signature, entityId, engine);
    } else {
        if (wantsAssertionsSigned(context) && !peerContext.isAuthenticated()) {
            throw new SAMLSignatureRequiredException("Assertion or response must be signed");
        }
    }
}
Also used : SAMLPeerEntityContext(org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext) SAMLSignatureRequiredException(org.pac4j.saml.exceptions.SAMLSignatureRequiredException)

Example 2 with SAMLSignatureRequiredException

use of org.pac4j.saml.exceptions.SAMLSignatureRequiredException in project pac4j by pac4j.

the class SAML2LogoutResponseValidator method validateAssertionSignature.

/**
 * Validate assertion signature. If none is found and the SAML response did not have one and the SP requires
 * the assertions to be signed, the validation fails.
 *
 * @param signature the signature
 * @param context the context
 * @param engine the engine
 */
protected final void validateAssertionSignature(final Signature signature, final SAML2MessageContext context, final SignatureTrustEngine engine) {
    final SAMLPeerEntityContext peerContext = context.getSAMLPeerEntityContext();
    if (signature != null) {
        final String entityId = peerContext.getEntityId();
        validateSignature(signature, entityId, engine);
    } else {
        if (!peerContext.isAuthenticated()) {
            throw new SAMLSignatureRequiredException("Assertion or response must be signed");
        }
    }
}
Also used : SAMLPeerEntityContext(org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext) SAMLSignatureRequiredException(org.pac4j.saml.exceptions.SAMLSignatureRequiredException)

Aggregations

SAMLPeerEntityContext (org.opensaml.saml.common.messaging.context.SAMLPeerEntityContext)2 SAMLSignatureRequiredException (org.pac4j.saml.exceptions.SAMLSignatureRequiredException)2