spSingleLogoutPOST.jsp revision 31995e9edcce4393cdab93d80f27d5ab54ff5264
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen The contents of this file are subject to the terms
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen of the Common Development and Distribution License
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen (the License). You may not use this file except in
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen compliance with the License.
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen You can obtain a copy of the License at
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen https://opensso.dev.java.net/public/CDDLv1.0.html or
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen See the License for the specific language governing
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen permission and limitations under the License.
c664d0da658c8d3200d88ea3c4cd580afd33fa73Timo Sirainen When distributing Covered Code, include this CDDL
$Id: spSingleLogoutPOST.jsp,v 1.8 2009/06/24 23:05:31 mrudulahg Exp $
<%@ page import="com.sun.identity.sae.api.SecureAttrs" %>
<%@ page import="com.sun.identity.saml.common.SAMLUtils" %>
<%@ page import="com.sun.identity.saml2.common.SAML2Utils" %>
<%@ page import="com.sun.identity.saml2.common.SAML2Constants" %>
<%@ page import="com.sun.identity.saml2.common.SAML2Exception" %>
<%@ page import="com.sun.identity.saml2.jaxb.entityconfig.SPSSOConfigElement" %>
<%@ page import="com.sun.identity.saml2.meta.SAML2MetaUtils" %>
<%@ page import="com.sun.identity.saml2.meta.SAML2MetaManager" %>
<%@ page import="com.sun.identity.saml2.profile.CacheObject" %>
<%@ page import="com.sun.identity.saml2.profile.SPCache" %>
<%@ page import="com.sun.identity.saml2.profile.SPSingleLogout" %>
<%@ page import="com.sun.identity.saml2.profile.IDPCache" %>
<%@ page import="com.sun.identity.saml2.protocol.LogoutRequest" %>
<%@ page import="com.sun.identity.saml2.profile.IDPProxyUtil" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Properties" %>
<%@ page import="org.owasp.esapi.ESAPI" %>
<%@ page import="java.io.PrintWriter" %>
(CacheObject) SPCache.relayStateHash.remove(relayState);
relayState = (String) tmpRs.getObject();
if (!ESAPI.validator().isValidInput("HTTP Query String: " + relayState, relayState, "HTTPQueryString", 2000, true)) {
SPSingleLogout.processLogoutResponse(request, response, samlResponse, relayState);
String inRes = infoMap.get("inResponseTo");
if (origLogoutRequest != null && !origLogoutRequest.equals("")) {
IDPProxyUtil.sendProxyLogoutResponse(response, request,
origLogoutRequest.getID(), infoMap,
origLogoutRequest.getIssuer().getValue(),
SAML2Utils.debug.error("Error processing LogoutResponse :", sse);
SAML2Utils.bundle.getString("LogoutResponseProcessingError") +
" " + sse.getMessage());
SAML2Utils.debug.error("Error processing LogoutResponse ",e);
SAML2Utils.bundle.getString("LogoutResponseProcessingError") +
" " + e.getMessage());
if (!SPCache.isFedlet) {
isRelayStateURLValid = relayState != null && !relayState.isEmpty()
&& ESAPI.validator().isValidInput("RelayState", relayState, "URL", 2000, true);
List<String> spMetaAliases = manager.getAllHostedServiceProviderMetaAliases("/");
if (spMetaAliases != null && !spMetaAliases.isEmpty()) {
metaAlias = spMetaAliases.get(0);
isRelayStateURLValid = relayState != null && !relayState.isEmpty()
&& ESAPI.validator().isValidInput("RelayState", relayState, "URL", 2000, true);
response.sendRedirect(relayState);
} catch (java.io.IOException ioe) {
if (SAML2Utils.debug.messageEnabled()) {
<jsp:forward page="/saml2/jsp/default.jsp?message=spSloSuccess" />
if (!SPCache.isFedlet) {
SPSingleLogout.processLogoutRequest(request,response, new PrintWriter(out, true),
SAML2Utils.debug.error("Error processing LogoutRequest :", sse);
SAML2Utils.bundle.getString("LogoutRequestProcessingError")
+ " " + sse.getMessage());
SAML2Utils.debug.error("Error processing LogoutRequest ",e);
SAML2Utils.bundle.getString("LogoutRequestProcessingError")
+ " " + e.getMessage());
String realm = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
SAML2MetaManager mm = SAML2Utils.getSAML2MetaManager();
String entityId = mm.getEntityByMetaAlias(metaAlias);
SPSSOConfigElement spConfig = mm.getSPSSOConfig(realm, entityId);
appSLOUrlStr = SAML2Utils.getAttributeValueFromSPSSOConfig(
spConfig, SAML2Constants.SAE_SP_LOGOUT_URL);
if (SAML2Utils.debug.messageEnabled()) {
Map hp = SAML2Utils.getSAEAttrs(
realm, entityId, SAML2Constants.SP_ROLE, appSLOUrlStr);
String encAlg = (String)hp.get(
String encStrength = (String)hp.get(
if (SecureAttrs.SAE_CRYPTO_TYPE_SYM.equals(cryptoType)) {
if (secret == null || secret.length() == 0) {
"spSLOPOST:SAE:processing App SLO:getSAEAttrs no secret/key");
String returnURL = request.getRequestURL()+
"?"+request.getQueryString()+"&"+
SecureAttrs.SAE_PARAM_APPRETURN+"=true";
SecureAttrs sa = SecureAttrs.getInstance(saInstanceName);
SecureAttrs.SAE_CONFIG_ENCRYPTION_KEY_STRENGTH,encStrength); }
SecureAttrs.init(saInstanceName, cryptoType, prop);
sa = SecureAttrs.getInstance(saInstanceName);
String encodedString = sa.getEncodedString(map, secret, encSecret);
if (appSLOUrl.indexOf("?") > 0) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("spSLOPOST:SAE:about to redirect"+
"spSLOPOST:SAE:SecureAttrs.getEncodedStr failed");