LoginServlet.java revision b5d806442d0311234a3612ec0e1a04ed70a4e8e2
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: LoginServlet.java,v 1.9 2009/02/18 03:38:42 222713 Exp $
*
* Portions Copyrighted 2011-2014 ForgeRock AS.
*/
/**
* This is the front controller of authentication UI
*/
public class LoginServlet
/**
* Creates <code>LoginServlet</code> object.
*/
public LoginServlet() {
super();
}
/**
*
*
*/
// Set a view bean manager in the request context. This must be
// done at the module level because the view bean manager is
// module specifc.
// Check whether to detect the browser capability to support cookies
// by redirecting the response with dummy cookie.
throw new CompleteRequestException();
}
// Check content length
try {
} catch (L10NMessageImpl e) {
if (debug.messageEnabled()) {
}
throw new CompleteRequestException();
}
// Check if the hostname in the URL is an FQDN else
// redirect to the fqdn
if (debug.messageEnabled()) {
}
try {
if (debug.messageEnabled()) {
}
} else {
if (debug.messageEnabled()) {
}
}
} catch (Exception e) {
// came here continue
}
throw new CompleteRequestException();
}
return;
}
// Check whether this is the correct server to accept the client
// response.
//if cookie server does not match to this local server then
//send Auth request to cookie (original) server
try {
} catch (Exception e) {
if (debug.messageEnabled()) {
+ e.toString());
}
}
if (debug.messageEnabled()) {
}
if (isLoginRequest && cookieURL != null && !cookieURL.isEmpty() && !AuthUtils.isLocalServer(cookieURL,true)
}
}
}
private void rerouteRequest(HttpServletRequest request, HttpServletResponse response, String cookieURL) {
try {
throw fwdEx;
}
if (!origRequestData.isEmpty()) {
}
if (debug.messageEnabled()) {
}
if (debug.warningEnabled()) {
+ "while forwarding request, throwing CompleteRequestException");
}
throw new CompleteRequestException();
}
}
if (contentType != null) {
if (debug.messageEnabled()) {
}
} else {
if (debug.messageEnabled()) {
}
}
}
if (debug.messageEnabled()) {
+ " No Response from original Auth server");
}
if (pos != -1) {
}
} else {
+ request.getQueryString();
}
}
if (debug.messageEnabled()) {
+ " referer domain is " + refererDomain);
}
//remove amAuthCookie and amLBCookie cookies
if (debug.messageEnabled()) {
+ "initializeRequestContext removing"
}
if (debug.messageEnabled()) {
+ "initializeRequestContext"
+ " removing cookie "
+ domain);
}
} //end for
} else {
//using domain name from referer
if (refererDomain != null) {
}
}
}
}
}
if (debug.messageEnabled()) {
+ "redirecting to: " + refererURL);
}
}
} catch (Exception e) {
if (debug.warningEnabled()) {
}
} else {
if (debug.messageEnabled()) {
}
}
}
}
throw new CompleteRequestException();
}
// Checks whether the browser supports or has enabled cookie
// Returns "true" if browser has no cookies and need to redirect to
// the Login URL with dummy cookie in order to detect the browser
// capability to support cookies.
// Returns "false" if there is no redirection required, which could be
// enable cookies in the browser or to proceed with normal Login process.
// this is another way of enable cookie check, send this
}
if (debug.messageEnabled()) {
" amCookieCheck: " + amCookieCheck +
" agentOrder: " + agentOrder);
}
int numCookies = 0;
if (allCookies != null) {
}
try {
"?AMTESTCOOKIE=amtestcookie");
} else {
}
} catch (Exception e) {
" error in Request Routing : " + e.toString());
}
return true;
}
"This browser does not support cookie");
}
}
return false;
}
/**
* Returns url for auth module.
* @return url for auth module.
*/
public String getModuleURL() {
// The superclass can be configured from init params specified at
// deployment time. If the superclass has been configured with
// a different module URL, it will return a non-null value here.
// If it has not been configured with a different URL, we use our
// (hopefully) sensible default.
return result;
else
return DEFAULT_MODULE_URL;
}
/**
*
*
*/
throws ServletException {
// Do nothing
}
////////////////////////////////////////////////////////////////////////////
// Class variables
////////////////////////////////////////////////////////////////////////////
private final String amCookieCheck =
/** Default module uri. */
/** Confiured page name for configured servlet */
public static String PACKAGE_NAME=
private static final String DEFAULT_CONTENT_TYPE = "text/html; charset=" + G11NSettings.CDM_DEFAULT_CHARSET;
// the debug file
}