use of org.pac4j.saml.transport.Pac4jSAMLResponse in project pac4j by pac4j.
the class SAML2ContextProvider method prepareOutboundMessageContext.
protected MessageContext<Pac4jSAMLResponse> prepareOutboundMessageContext(final WebContext webContext) {
final Pac4jSAMLResponse outTransport = new DefaultPac4jSAMLResponse(webContext);
final MessageContext<Pac4jSAMLResponse> outCtx = new MessageContext<>();
outCtx.setMessage(outTransport);
return outCtx;
}
use of org.pac4j.saml.transport.Pac4jSAMLResponse in project pac4j by pac4j.
the class SAML2LogoutMessageSender method getMessageEncoder.
/**
* Build the WebSSO handler for sending and receiving SAML2 messages.
* @param ctx
* @return the encoder instance
*/
private MessageEncoder getMessageEncoder(final SAML2MessageContext ctx) {
final Pac4jSAMLResponse adapter = ctx.getProfileRequestContextOutboundMessageTransportResponse();
if (SAMLConstants.SAML2_POST_BINDING_URI.equals(destinationBindingType)) {
final VelocityEngine velocityEngine = VelocityEngineFactory.getEngine();
final Pac4jHTTPPostEncoder encoder = new Pac4jHTTPPostEncoder(adapter);
encoder.setVelocityEngine(velocityEngine);
return encoder;
}
if (SAMLConstants.SAML2_REDIRECT_BINDING_URI.equals(destinationBindingType)) {
final Pac4jHTTPRedirectDeflateEncoder encoder = new Pac4jHTTPRedirectDeflateEncoder(adapter, forceSignRedirectBindingLogoutRequest);
return encoder;
}
throw new UnsupportedOperationException("Binding type - " + destinationBindingType + " is not supported");
}
use of org.pac4j.saml.transport.Pac4jSAMLResponse in project pac4j by pac4j.
the class SAML2WebSSOMessageSender method getMessageEncoder.
/**
* Build the WebSSO handler for sending and receiving SAML2 messages.
*
* @param ctx the ctx
* @return the encoder instance
*/
private MessageEncoder getMessageEncoder(final SAML2MessageContext ctx) {
final Pac4jSAMLResponse adapter = ctx.getProfileRequestContextOutboundMessageTransportResponse();
if (SAMLConstants.SAML2_POST_BINDING_URI.equals(destinationBindingType)) {
final VelocityEngine velocityEngine = VelocityEngineFactory.getEngine();
final Pac4jHTTPPostEncoder encoder = new Pac4jHTTPPostEncoder(adapter);
encoder.setVelocityEngine(velocityEngine);
return encoder;
}
if (SAMLConstants.SAML2_REDIRECT_BINDING_URI.equals(destinationBindingType)) {
return new Pac4jHTTPRedirectDeflateEncoder(adapter, isAuthnRequestSigned);
}
throw new UnsupportedOperationException("Binding type - " + destinationBindingType + " is not supported");
}
use of org.pac4j.saml.transport.Pac4jSAMLResponse in project pac4j by pac4j.
the class SAML2RedirectActionBuilder method redirect.
@Override
public RedirectAction redirect(final WebContext wc) {
final SAML2MessageContext context = this.client.getContextProvider().buildContext(wc);
final String relayState = this.client.getStateParameter(wc);
final AuthnRequest authnRequest = this.saml2ObjectBuilder.build(context);
this.client.getProfileHandler().send(context, authnRequest, relayState);
final Pac4jSAMLResponse adapter = context.getProfileRequestContextOutboundMessageTransportResponse();
if (this.client.getConfiguration().getDestinationBindingType().equalsIgnoreCase(SAMLConstants.SAML2_POST_BINDING_URI)) {
final String content = adapter.getOutgoingContent();
return RedirectAction.success(content);
}
final String location = adapter.getRedirectUrl();
return RedirectAction.redirect(location);
}
use of org.pac4j.saml.transport.Pac4jSAMLResponse in project pac4j by pac4j.
the class SAML2LogoutActionBuilder method getLogoutAction.
@Override
public RedirectAction getLogoutAction(final WebContext context, final U currentProfile, final String targetUrl) {
final SAML2MessageContext samlContext = this.client.getContextProvider().buildContext(context);
final String relayState = this.client.getStateParameter(context);
final LogoutRequest logoutRequest = this.saml2LogoutObjectBuilder.build(samlContext);
this.logoutProfileHandler.send(samlContext, logoutRequest, relayState);
final Pac4jSAMLResponse adapter = samlContext.getProfileRequestContextOutboundMessageTransportResponse();
if (this.client.getConfiguration().getDestinationBindingType().equalsIgnoreCase(SAMLConstants.SAML2_POST_BINDING_URI)) {
final String content = adapter.getOutgoingContent();
return RedirectAction.success(content);
}
final String location = adapter.getRedirectUrl();
return RedirectAction.redirect(location);
}
Aggregations