4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<%--
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster The contents of this file are subject to the terms
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster of the Common Development and Distribution License
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster (the License). You may not use this file except in
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster compliance with the License.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster You can obtain a copy of the License at
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster https://opensso.dev.java.net/public/CDDLv1.0.html or
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster opensso/legal/CDDLv1.0.txt
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster See the License for the specific language governing
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster permission and limitations under the License.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster When distributing Covered Code, include this CDDL
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Header Notice in each file and include the License file
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster at opensso/legal/CDDLv1.0.txt.
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster If applicable, add the following below the CDDL Header,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster with the fields enclosed by brackets [] replaced by
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster your own identifying information:
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster "Portions Copyrighted [year] [name of copyright owner]"
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster $Id: header.jsp,v 1.3 2008/06/25 05:49:24 qcheng Exp $
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster--%>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<%@ page language="java"
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Fosterimport="java.io.IOException,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster java.net.URLEncoder,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster java.text.MessageFormat,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.plugin.session.SessionException,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.plugin.session.SessionProvider,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.plugin.session.SessionManager,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.shared.Constants,
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster com.sun.identity.shared.configuration.SystemPropertiesManager"
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster%>
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster<%
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster boolean loggedIn = false;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String redirectUrl = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String localAuthUrl = null;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String baseURL = request.getRequestURI().toString();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster int idx = baseURL.indexOf('/', 1);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String localProto = request.getScheme();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String localHost = request.getServerName();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String localPort = "" + request.getServerPort();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String localDeploymentURI = baseURL.substring(0, idx);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster baseURL = localProto + "://" + localHost +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster ":" + localPort + localDeploymentURI;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String realBaseURL =
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SystemPropertiesManager.get(Constants.AM_SERVER_PROTOCOL) + "://" +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SystemPropertiesManager.get(Constants.AM_SERVER_HOST) + ":" +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SystemPropertiesManager.get(Constants.AM_SERVER_PORT) +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SystemPropertiesManager.get(Constants.AM_SERVICES_DEPLOYMENT_DESCRIPTOR);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster try {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster SessionProvider provider = SessionManager.getProvider();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster Object sess = provider.getSession(request);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if (sess != null) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster loggedIn = provider.isValid(sess);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster }
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster } catch (SessionException e) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster //ignored
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster }
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if(!loggedIn) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String gotoUrl = request.getRequestURL().toString();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster String qs = request.getQueryString();
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster if ((qs != null) && (qs.length() > 0)) {
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster gotoUrl = gotoUrl + "?" + qs;
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster }
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster redirectUrl = baseURL + "/preLogin?metaAlias={0}&goto=" +
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster URLEncoder.encode(gotoUrl);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster localAuthUrl = baseURL + "/UI/Login?goto=" + URLEncoder.encode(gotoUrl);
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster }
4fe4e4f798a84a46e567f64ceadd3648eb0582d4Allan Foster%>