use of com.nimbusds.openid.connect.sdk.LogoutRequest in project pac4j by pac4j.
the class OidcLogoutActionBuilder method getLogoutAction.
@Override
public RedirectAction getLogoutAction(final WebContext context, final U currentProfile, final String targetUrl) {
final String logoutUrl = configuration.getLogoutUrl();
if (CommonHelper.isNotBlank(logoutUrl)) {
try {
final URI endSessionEndpoint = new URI(logoutUrl);
final JWT idToken = currentProfile.getIdToken();
LogoutRequest logoutRequest;
if (CommonHelper.isNotBlank(targetUrl)) {
logoutRequest = new LogoutRequest(endSessionEndpoint, idToken, new URI(targetUrl), null);
} else {
logoutRequest = new LogoutRequest(endSessionEndpoint, idToken);
}
if (ajaxRequestResolver.isAjax(context)) {
context.getSessionStore().set(context, Pac4jConstants.REQUESTED_URL, "");
context.setResponseHeader(HttpConstants.LOCATION_HEADER, logoutRequest.toURI().toString());
throw HttpAction.status(403, context);
}
return RedirectAction.redirect(logoutRequest.toURI().toString());
} catch (final URISyntaxException e) {
throw new TechnicalException(e);
}
}
return null;
}
Aggregations