Search in sources :

Example 1 with SAMLOutboundProtocolMessageSigningHandler

use of org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler in project pac4j by pac4j.

the class SAML2WebSSOMessageSender method invokeOutboundMessageHandlers.

protected final void invokeOutboundMessageHandlers(final SPSSODescriptor spDescriptor, final IDPSSODescriptor idpssoDescriptor, final SAML2MessageContext outboundContext) {
    try {
        final EndpointURLSchemeSecurityHandler handlerEnd = new EndpointURLSchemeSecurityHandler();
        handlerEnd.initialize();
        handlerEnd.invoke(outboundContext);
        final SAMLOutboundDestinationHandler handlerDest = new SAMLOutboundDestinationHandler();
        handlerDest.initialize();
        handlerDest.invoke(outboundContext);
        boolean signOutboundContext = false;
        if (this.isAuthnRequestSigned) {
            logger.debug("Authn requests are expected to be always signed before submission");
            signOutboundContext = true;
        } else if (spDescriptor.isAuthnRequestsSigned()) {
            logger.debug("The service provider metadata indicates that authn requests are signed");
            signOutboundContext = true;
        } else if (idpssoDescriptor.getWantAuthnRequestsSigned()) {
            logger.debug("The identity provider metadata indicates that authn requests may be signed");
            signOutboundContext = true;
        }
        if (signOutboundContext) {
            logger.debug("Signing SAML2 outbound context...");
            final SAMLOutboundProtocolMessageSigningHandler handler = new SAMLOutboundProtocolMessageSigningHandler();
            handler.invoke(outboundContext);
        }
    } catch (final Exception e) {
        throw new SAMLException(e);
    }
}
Also used : EndpointURLSchemeSecurityHandler(org.opensaml.saml.common.binding.security.impl.EndpointURLSchemeSecurityHandler) SAMLOutboundProtocolMessageSigningHandler(org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler) SAMLOutboundDestinationHandler(org.opensaml.saml.common.binding.impl.SAMLOutboundDestinationHandler) SAMLException(org.pac4j.saml.exceptions.SAMLException) ComponentInitializationException(net.shibboleth.utilities.java.support.component.ComponentInitializationException) SAMLException(org.pac4j.saml.exceptions.SAMLException) MessageEncodingException(org.opensaml.messaging.encoder.MessageEncodingException)

Example 2 with SAMLOutboundProtocolMessageSigningHandler

use of org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler in project cas by apereo.

the class DefaultSamlIdPObjectSigner method prepareSamlOutboundProtocolMessageSigningHandler.

/**
 * Prepare saml outbound protocol message signing handler.
 *
 * @param <T>             the type parameter
 * @param outboundContext the outbound context
 * @throws Exception the exception
 */
protected <T extends SAMLObject> void prepareSamlOutboundProtocolMessageSigningHandler(final MessageContext outboundContext) throws Exception {
    LOGGER.trace("Attempting to sign the outbound SAML message...");
    val handler = new SAMLOutboundProtocolMessageSigningHandler();
    handler.setSignErrorResponses(casProperties.getAuthn().getSamlIdp().getResponse().isSignError());
    handler.invoke(outboundContext);
    LOGGER.debug("Signed SAML message successfully");
}
Also used : lombok.val(lombok.val) SAMLOutboundProtocolMessageSigningHandler(org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler)

Example 3 with SAMLOutboundProtocolMessageSigningHandler

use of org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler in project cas by apereo.

the class BaseSamlObjectSigner method prepareSamlOutboundProtocolMessageSigningHandler.

/**
     * Prepare saml outbound protocol message signing handler.
     *
     * @param <T>             the type parameter
     * @param outboundContext the outbound context
     * @throws Exception the exception
     */
protected <T extends SAMLObject> void prepareSamlOutboundProtocolMessageSigningHandler(final MessageContext<T> outboundContext) throws Exception {
    LOGGER.debug("Attempting to sign the outbound SAML message...");
    final SAMLOutboundProtocolMessageSigningHandler handler = new SAMLOutboundProtocolMessageSigningHandler();
    handler.setSignErrorResponses(casProperties.getAuthn().getSamlIdp().getResponse().isSignError());
    handler.invoke(outboundContext);
    LOGGER.debug("Signed SAML message successfully");
}
Also used : SAMLOutboundProtocolMessageSigningHandler(org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler)

Example 4 with SAMLOutboundProtocolMessageSigningHandler

use of org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler in project cas by apereo.

the class SamlIdPObjectSigner method prepareSamlOutboundProtocolMessageSigningHandler.

/**
 * Prepare saml outbound protocol message signing handler.
 *
 * @param <T>             the type parameter
 * @param outboundContext the outbound context
 * @throws Exception the exception
 */
protected <T extends SAMLObject> void prepareSamlOutboundProtocolMessageSigningHandler(final MessageContext<T> outboundContext) throws Exception {
    LOGGER.debug("Attempting to sign the outbound SAML message...");
    final SAMLOutboundProtocolMessageSigningHandler handler = new SAMLOutboundProtocolMessageSigningHandler();
    handler.setSignErrorResponses(casProperties.getAuthn().getSamlIdp().getResponse().isSignError());
    handler.invoke(outboundContext);
    LOGGER.debug("Signed SAML message successfully");
}
Also used : SAMLOutboundProtocolMessageSigningHandler(org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler)

Example 5 with SAMLOutboundProtocolMessageSigningHandler

use of org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler in project pac4j by pac4j.

the class SAML2LogoutMessageSender method invokeOutboundMessageHandlers.

protected final void invokeOutboundMessageHandlers(final SPSSODescriptor spDescriptor, final IDPSSODescriptor idpssoDescriptor, final SAML2MessageContext outboundContext) {
    try {
        final EndpointURLSchemeSecurityHandler handlerEnd = new EndpointURLSchemeSecurityHandler();
        handlerEnd.initialize();
        handlerEnd.invoke(outboundContext);
        final SAMLOutboundDestinationHandler handlerDest = new SAMLOutboundDestinationHandler();
        handlerDest.initialize();
        handlerDest.invoke(outboundContext);
        if (spDescriptor.isAuthnRequestsSigned()) {
            final SAMLOutboundProtocolMessageSigningHandler handler = new SAMLOutboundProtocolMessageSigningHandler();
            handler.setSignErrorResponses(this.signErrorResponses);
            handler.invoke(outboundContext);
        } else if (idpssoDescriptor.getWantAuthnRequestsSigned()) {
            logger.warn("IdP wants authn requests signed, it will perhaps reject your authn requests unless you provide a keystore");
        }
    } catch (final Exception e) {
        throw new SAMLException(e);
    }
}
Also used : EndpointURLSchemeSecurityHandler(org.opensaml.saml.common.binding.security.impl.EndpointURLSchemeSecurityHandler) SAMLOutboundProtocolMessageSigningHandler(org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler) SAMLOutboundDestinationHandler(org.opensaml.saml.common.binding.impl.SAMLOutboundDestinationHandler) SAMLException(org.pac4j.saml.exceptions.SAMLException) ComponentInitializationException(net.shibboleth.utilities.java.support.component.ComponentInitializationException) SAMLException(org.pac4j.saml.exceptions.SAMLException) MessageEncodingException(org.opensaml.messaging.encoder.MessageEncodingException)

Aggregations

SAMLOutboundProtocolMessageSigningHandler (org.opensaml.saml.common.binding.security.impl.SAMLOutboundProtocolMessageSigningHandler)6 lombok.val (lombok.val)2 ComponentInitializationException (net.shibboleth.utilities.java.support.component.ComponentInitializationException)2 MessageEncodingException (org.opensaml.messaging.encoder.MessageEncodingException)2 SAMLOutboundDestinationHandler (org.opensaml.saml.common.binding.impl.SAMLOutboundDestinationHandler)2 EndpointURLSchemeSecurityHandler (org.opensaml.saml.common.binding.security.impl.EndpointURLSchemeSecurityHandler)2 SAMLException (org.pac4j.saml.exceptions.SAMLException)2 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1 Executable (org.junit.jupiter.api.function.Executable)1 MessageContext (org.opensaml.messaging.context.MessageContext)1 SAML2MessageContext (org.pac4j.saml.context.SAML2MessageContext)1 DefaultSignatureSigningParametersProvider (org.pac4j.saml.crypto.DefaultSignatureSigningParametersProvider)1 SAML2AuthnRequestBuilder (org.pac4j.saml.sso.impl.SAML2AuthnRequestBuilder)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1