AbstractOpenAMAuthenticator.java revision 073875d677d0cc89aa2cc1187c975225a2ead9d3
0N/A * DO NOT REMOVE COPYRIGHT NOTICES OR THIS HEADER. 0N/A * Copyright (c) 2012-2013 ForgeRock Inc. All rights reserved. 0N/A * The contents of this file are subject to the terms 0N/A * of the Common Development and Distribution License 0N/A * (the License). You may not use this file except in 0N/A * compliance with the License. 0N/A * You can obtain a copy of the License at 0N/A * See the License for the specific language governing 0N/A * permission and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL 0N/A * Header Notice in each file and include the License file 0N/A * If applicable, add the following below the CDDL Header, 0N/A * with the fields enclosed by brackets [] replaced by 0N/A * your own identifying information: 0N/A * "Portions copyright [year] [name of copyright owner]" 0N/A * Used to authenticate to OpenAM and redirect to its login page. 0N/A //ensure the prompt for login shows the login page atleast one time 0N/A //put the space separated prompts into a Set collection 0N/A // prompt has more than one value with none error 0N/A * TODO check for forward and do a forward vs a redirection See IDPSSOFederate.redirectAuthentication() for details 0N/A //check for forward or request 0N/A StringBuffer appliRootUrl = getAppliRootUrl(httpRequest); 0N/A boolean forward = false; 0N/A StringBuffer newURL; 0N/A // build newUrl to auth service and test if redirect or forward 0N/A if(FSUtils.isSameContainer(httpRequest, authURL)){ 0N/A String relativePath = getRelativePath(authURL, appliRootUrl. 0N/A newURL = new StringBuffer(relativePath); 0N/A // cannot forward so redirect 0N/A newURL = new StringBuffer(authURL); 0N/A //TODO investigate more options for the LOGIN servlett 0N/A /* TODO will be used when forward is implemented 0N/A private static StringBuffer getAppliRootUrl(HttpServletRequest request) { 0N/A StringBuffer result = new StringBuffer(); 0N/A String scheme = request.getScheme(); // http 0N/A String serverName = request.getServerName(); // hostname.com 0N/A int serverPort = request.getServerPort(); // 80 0N/A String contextPath = request.getContextPath(); // /mywebapp 0N/A result.append(scheme).append("://").append(serverName).append(":"). 0N/A result.append(contextPath); 0N/A private static String getRelativePath(String absUrl, String appliRootUrl) { 0N/A return absUrl.substring(appliRootUrl.length(), absUrl.length());