spSingleLogoutInit.jsp revision 881ea1b9f1a22a7d7bf65c6c2bf46ca282641f82
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin The contents of this file are subject to the terms
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin of the Common Development and Distribution License
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (the License). You may not use this file except in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin compliance with the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin You can obtain a copy of the License at
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin See the License for the specific language governing
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin permission and limitations under the License.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin When distributing Covered Code, include this CDDL
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Header Notice in each file and include the License file
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin If applicable, add the following below the CDDL Header,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin with the fields enclosed by brackets [] replaced by
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin your own identifying information:
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin "Portions Copyrighted [year] [name of copyright owner]"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin $Id: spSingleLogoutInit.jsp,v 1.13 2009/10/15 00:01:11 exu Exp $
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Portions Copyrighted 2012-2013 ForgeRock AS
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.plugin.session.SessionManager" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.plugin.session.SessionException" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml.common.SAMLUtils" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.common.SAML2Constants" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.meta.SAML2MetaManager" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.meta.SAML2MetaUtils" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.common.SAML2Exception" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.profile.LogoutUtil" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.profile.SPCache" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="com.sun.identity.saml2.profile.SPSingleLogout" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="java.util.HashMap" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="java.util.List" %>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin<%@ page import="org.owasp.esapi.ESAPI" %>
if (!ESAPI.validator().isValidInput("HTTP Query String: " + RelayState,
if (RelayState == null || RelayState.isEmpty()) {
if (!ESAPI.validator().isValidInput("HTTP Query String: " + RelayState, RelayState, "HTTPQueryString", 1024, true)) {
ssoToken = SessionManager.getProvider().getSession(request);
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("No session.");
if (!SPCache.isFedlet) {
if (RelayState != null && !RelayState.isEmpty() &&
ESAPI.validator().isValidInput("HTTP URL Parameter: " + RelayState, RelayState, "URL", 2000, true)) {
response.sendRedirect(RelayState);
<jsp:forward page="/saml2/jsp/default.jsp?message=spSloSuccess"/>
String[] values = SessionManager.getProvider().
getProperty(ssoToken, SAML2Constants.SP_METAALIAS);
if (values != null && values.length > 0) {
spEntityID = request.getParameter("spEntityID");
if ((spEntityID == null) || (spEntityID.length() == 0)) {
if ((spMetaAliases != null) && !spMetaAliases.isEmpty()) {
metaAlias = (String) spMetaAliases.get(0);
manager.getSPSSOConfig("/", spEntityID);
metaAlias = spConfig.getMetaAlias();
SessionManager.getProvider().invalidateSession(
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("No session.");
if (RelayState != null && SAML2Utils.isRelayStateURLValid(request, RelayState, SAML2Constants.SP_ROLE) &&
ESAPI.validator().isValidInput("HTTP URL Parameter: " + RelayState, RelayState, "URL", 2000, true)) {
response.sendRedirect(RelayState);
<jsp:forward page="/saml2/jsp/default.jsp?message=spSloSuccess"/>
String idpEntityID = request.getParameter("idpEntityID");
String binding = LogoutUtil.getSLOBindingInfo(request, metaAlias,
SAML2Constants.SP_ROLE, idpEntityID);
spEntityID = manager.getEntityByMetaAlias(metaAlias);
String realm = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
realm, spEntityID, SAML2Constants.SLO_SERVICE, binding))
SAML2Utils.bundle.getString("unsupportedBinding"));
* this parameter is /realm_name/SP_name.
if (SPCache.isFedlet) {
String sessionIndex = request.getParameter("SessionIndex");
if ((sessionIndex == null) || (sessionIndex.length() == 0)) {
SAML2Utils.bundle.getString("nullSessionIndex"));
paramsMap.put("SessionIndex", sessionIndex);
String nameID = request.getParameter("NameIDValue");
if ((nameID == null) || (nameID.length() == 0)) {
SAML2Utils.bundle.getString("nullNameID"));
spEntityID = manager.getEntityByMetaAlias(metaAlias);
SAMLUtils.sendError(request, response,
SAML2Utils.bundle.getString("nullIDPEntityID"));
paramsMap.put("metaAlias", metaAlias);
paramsMap.put("idpEntityID", idpEntityID);
if (RelayState == null || RelayState.isEmpty()) {
RelayState = SAML2Utils.getAttributeValueFromSSOConfig(
realm, spEntityID, SAML2Constants.SP_ROLE,
String sessionIndex = request.getParameter("sessionIndex");
SPSingleLogout.initiateLogoutRequest( request,response,
if (RelayState != null && !RelayState.isEmpty() &&
ESAPI.validator().isValidInput("HTTP URL: " + RelayState, RelayState, "URL", 2000, true)) {
response.sendRedirect(RelayState);
<jsp:forward page="/saml2/jsp/default.jsp?message=spSloSuccess"/>
SAML2Utils.debug.error("Error sending Logout Request " , sse);
SAML2Utils.bundle.getString("LogoutRequestCreationError") + " " +
sse.getMessage());
SAML2Utils.debug.error("Error initializing Request ",e);
SAML2Utils.bundle.getString("LogoutRequestCreationError") + " " +
e.getMessage());