a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The contents of this file are subject to the terms
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * of the Common Development and Distribution License
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * (the License). You may not use this file except in
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * compliance with the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You can obtain a copy of the License at
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * See the License for the specific language governing
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * permission and limitations under the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * When distributing Covered Code, include this CDDL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Header Notice in each file and include the License file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * If applicable, add the following below the CDDL Header,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * with the fields enclosed by brackets [] replaced by
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * your own identifying information:
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * $Id: FSFederationHandler.java,v 1.3 2008/08/29 04:57:15 exu Exp $
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.common.FSUtils;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.common.IFSConstants;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.federation.services.util.FSServiceUtils;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This servlet processes requests to initiate Federation
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * and redirects to the provider home pager URL on
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * successful federation.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterpublic class FSFederationHandler extends HttpServlet {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Processes requests for both HTTP <code>GET</code> and
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * <code>POST</code> methods. Redirects to provider URL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * if the action is cancel else to the provider URL or
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * to the error page on error.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param request the <code>HttpServletRequest</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param response the <code>HttpServletResponse</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception ServletException if the request could not be
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception IOException if an input or output error occurs.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster protected void processRequest(HttpServletRequest request,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String action = request.getParameter(IFSConstants.USERACTION);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster action.trim().equalsIgnoreCase(IFSConstants.CANCEL))
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.message("FSFederationHandler:: user pressed "
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster + "cancel proceding to lrurl");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String lrURL = request.getParameter(IFSConstants.LRURL);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.message("FSFederationHandler::Redirecting to "
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.forwardRequest(request, response, lrURL);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "FSFederationHandler::LRURL is null in reqest ");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if (FSUtils.needSetLBCookieAndRedirect(request, response, false)) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster request.getParameter(IFSConstants.SELECTEDPROVIDER);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.debug.error("FSFederationHandler:: No MetaAlias "
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster + "in request. Redirecting to error page");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String errorPage = FSServiceUtils.getErrorPageURL(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster FSUtils.forwardRequest(request, response, errorPage);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "FSFederationHandler::selected provider is "
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String lrURL = postLogin.doFederation(request, response);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster + " after postLogin" );
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster + " LRURL is null from postlogin ");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "FSFederationHandler::FSPostLogin Exception:", fsPostExp);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Handles the HTTP <code>GET</code> method.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param request the <code>HttpServletRequest</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param response the <code>HttpServletResponse</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception ServletException if the request could not be
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception IOException if an input or output error occurs.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster protected void doGet(HttpServletRequest request,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Handles the HTTP <code>POST</code> method.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param request the <code>HttpServletRequest</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param response the <code>HttpServletResponse</code> object.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception ServletException if the request could not be
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @exception IOException if an input or output error occurs.