CookieReaderServlet.java revision 0fdab8904a8fe223f6934b878769fe45e7651c60
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: CookieReaderServlet.java,v 1.4 2009/03/26 19:41:29 madan_ranganath Exp $
*
*/
/**
* The Reader Service is used by the service provider. The service provider
* redirects the principal to this URL in order to find the preferred identity
* provider. Once found, the principal is redirected to the identity provider
* for single sign-on. The URL is defined as the value for the Reader Service
* URL attribute when an authentication domain is created. It is formatted as
* common-domain-host:port refers to the machine on which the Common Domain
* Services are installed and deployment-uri tells the web container where to
* look for information specific to the application (such as classes or JARs).
* The default URI is amcommon.
*/
public class CookieReaderServlet extends HttpServlet {
/**
* Gets handle to CookieUtils.debug.
* @param config the ServletConfig object that contains configutation
* information for this servlet.
* @exception ServletException if an exception occurs that interrupts
* the servlet's normal operation.
*/
throws ServletException {
}
}
/**
* Handles the HTTP GET request.
* @param request an HttpServletRequest object that contains the request
* the client has made of the servlet.
* @param response an HttpServletResponse object that contains the response
* the servlet sends to the client.
* @exception ServletException if an input or output error is detected when
* the servlet handles the GET request
* @exception IOException if the request for the GET could not be handled
*/
public void doGet(
throws ServletException, IOException
{
}
/**
* Handles the HTTP POST request.
* @param request an HttpServletRequest object that contains the request
* the client has made of the servlet.
* @param response an HttpServletResponse object that contains the response
* the servlet sends to the client.
* @exception ServletException if an input or output error is detected when
* the servlet handles the GET request
* @exception IOException if the request for the GET could not be handled
*/
public void doPost(
throws ServletException, IOException
{
}
/**
* Description : The QueryString will contain LRURL=URL to redirect with
* the _saml_idp cookie value
*
* @param request an HttpServletRequest object that contains the request
* the client has made of the servlet.
* @param response an HttpServletResponse object that contains the response
* the servlet sends to the client.
* @exception ServletException if an input or output error is detected when
* the servlet handles the GET request
* @exception IOException if the request for the GET could not be handled
*/
private void doGetPost(
throws ServletException, IOException
{
request.getRequestURI());
if (preferred_cookie_name == null) {
"The request uri is null.");
return;
"Cannot match the cookie name from " +
"the request uri.");
return;
}
try{
boolean isValidReturn = false;
// Redirect URL not specified. Do nothing
// Do not throw any error page to user as this operation is
// done behind the screens.
"Redirect URL not specified. "+
"Cannot send preferred idp in query string"
);
isValidReturn = false;
} else {
isValidReturn = true;
}
if (isValidReturn) {
if (cookieValue != null) {
classMethod + "preferred idp:" +
}
}
return;
} else {
return;
}
} catch(Exception e){
e.getMessage());
return;
}
}
/**
*
* This function is used to get the preferred IDP cookie from the request
* object
* @param request HTTP request
* @return string containing the space seperated base64 encoded preferred
* IDP cookie value
*/
private String getPreferredIdpCookie(
return CookieUtils.getCookieValueFromReq(
);
}
/**
* This function is used to append the preferred IDP cookie value to the
* redirect (LRURL) URL
* @param returnURL URL to redirect to (LRURL)
* @param cookieValue the _saml_idp cookie value
* @return String containing the redirect URL with the _saml_idp
* cookie
*/
private String appendCookieToReturnURL(
"CookieReaderServlet.appendCookieToReturnURL: ";
if (cookieValue == null ||
// Preferred IDP cookie not found
// Do not throw any error page to user as this operation is done
// behind the screens.
"Preferred IDPCookie not found"
);
}
// If the original returnURL already has some params, use
// AMPERSAND as a delimiter; else use a QUESTION_MARK.
char delimiter;
} else {
}
try {
} catch (Exception e) {
+ "appendCookieToReturnURL" + e.getMessage());
}
"Return URL = " +
);
}
return returnBuffer.toString();
}
}