spAssertionConsumer.jsp revision b0b2a539bb8760144e2e1e3c300fe70a422dc0a3
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The contents of this file are subject to the terms
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the Common Development and Distribution License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (the License). You may not use this file except in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync compliance with the License.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync You can obtain a copy of the License at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync https://opensso.dev.java.net/public/CDDLv1.0.html or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync See the License for the specific language governing
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync permission and limitations under the License.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync When distributing Covered Code, include this CDDL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Header Notice in each file and include the License file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If applicable, add the following below the CDDL Header,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync with the fields enclosed by brackets [] replaced by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync your own identifying information:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync "Portions Copyrighted [year] [name of copyright owner]"
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync $Id: spAssertionConsumer.jsp,v 1.17 2010/01/23 00:07:06 exu Exp $
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Portions Copyrighted 2012-2014 ForgeRock AS.
<%@ page import="java.io.PrintWriter" %>
String localLoginUrl = SPACSUtils.prepareForLocalLogin(
if (localLoginUrl.indexOf("?") == -1) {
if (relayState != null && relayState.length() != 0) {
gotoURL += "&RelayState=" + URLEncDec.encode(relayState);
localLoginUrl += URLEncDec.encode(gotoURL);
if (SAML2Utils.debug.messageEnabled()) {
"nullInput", SAML2Utils.bundle.getString("nullInput"));
SAMLUtils.checkHTTPContentLength(request);
"largeContentLength", se.getMessage());
if (FSUtils.needSetLBCookieAndRedirect(request, response, false)) {
String requestURL = request.getRequestURL().toString();
String metaAlias = SAML2MetaUtils.getMetaAliasByUri(requestURL);
SAML2MetaManager metaManager = SAML2Utils.getSAML2MetaManager();
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "errorMetaManager",
SAML2Utils.bundle.getString("errorMetaManager"));
hostEntityId = metaManager.getEntityByMetaAlias(metaAlias);
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "metaDataError",
SAML2Utils.bundle.getString("metaDataError"));
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "metaDataError",
SAML2Utils.bundle.getString("metaDataError"));
String orgName = SAML2MetaUtils.getRealmByMetaAlias(metaAlias);
if (orgName == null || orgName.length() == 0) {
sessionProvider = SessionManager.getProvider();
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "nullSessionProvider",
se.getMessage());
respInfo = SPACSUtils.getResponse(
if (!response.isCommitted()) {
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "getResponseError",
se.getMessage());
String ecpRelayState = respInfo.getRelayState();
if ((ecpRelayState != null) && (ecpRelayState.length() > 0)) {
token = sessionProvider.getSession(request);
if (SAML2Utils.debug.messageEnabled()) {
"spAssertionConsumer.jsp: Token is null." +
se.getMessage());
if (federate != null && federate.trim().equals("true") &&
if (SAML2Utils.debug.messageEnabled()) {
FSUtils.forwardRequest(request, response, getLocalLoginUrl(
Response saml2Resp = respInfo.getResponse();
String requestID = saml2Resp.getInResponseTo();
boolean isProxyOn = IDPProxyUtil.isIDPProxyEnabled(requestID);
newSession = SPACSUtils.processResponse(
String[] data = {hostEntityId, se.getMessage(), ""};
data[2] = saml2Resp.toXMLString(true, true);
if (se.isRedirectionDone()) {
if ("noPassiveResponse".equals(se.getErrorCode())) {
IDPProxyUtil.sendNoPassiveProxyResponse(request, response, requestID, metaAlias, hostEntityId,
SAML2Utils.debug.error("Failed to send nopassive proxy response", samle);
if (SAML2Utils.debug.messageEnabled()) {
FSUtils.forwardRequest(request, response, getLocalLoginUrl(
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "SSOFailed",
SAML2Utils.bundle.getString("SSOFailed"));
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("Session is null.");
SAMLUtils.sendError(request, response,
response.SC_INTERNAL_SERVER_ERROR, "SSOFailed",
SAML2Utils.bundle.getString("SSOFailed"));
SAML2Utils.debug.message("SSO SUCCESS");
String[] redirected = sessionProvider.getProperty(newSession,
if ((redirected != null) && (redirected.length != 0) &&
SAML2Utils.debug.message("Redirection already done in SPAdapter.");
IDPProxyUtil.generateProxyResponse(request, response, new PrintWriter(out, true), metaAlias, respInfo,
SAML2Utils.debug.error("Failed sending proxy response", se);
String finalUrl = SPACSUtils.getRelayState(
if (finalUrl != null && finalUrl.length() != 0) {
sessionProvider.rewriteURL(newSession, finalUrl);
"spAssertionConsumer.jsp: URL rewriting failed.", se);
String redirectUrl = SPACSUtils.getIntermediateURL(
if (redirectUrl != null && redirectUrl.length() != 0) {
if (realFinalUrl != null && realFinalUrl.length() != 0) {
if (redirectUrl.indexOf("?") != -1) {
redirectUrl += URLEncDec.encode(realFinalUrl);
realRedirectUrl = sessionProvider.rewriteURL(
"spAssertionConsumer.jsp: URL rewriting failed.", se);
if (realRedirectUrl == null || (realRedirectUrl.trim().length() == 0)) {
<jsp:forward page="/saml2/jsp/default.jsp?message=ssoSuccess" />
SAML2Utils.validateRelayStateURL(orgName, hostEntityId,
SAMLUtils.sendError(request, response,
response.SC_BAD_REQUEST, "requestProcessingError",
SAML2Utils.bundle.getString("requestProcessingError") + " " +
se.getMessage());
response.sendRedirect(realRedirectUrl);