use of org.pac4j.saml.context.SAML2MessageContext 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.context.SAML2MessageContext 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