/**
* 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: CookieWriterServlet.java,v 1.7 2009/11/03 00:50:34 madan_ranganath Exp $
*
*/
/**
* The Writer Service is used by the identity provider. After successful
* authentication, the common domain cookie is appended with the query parameter
* _saml_idp=entity-ID-of-identity-provider. This parameter is used to redirect
* the principal to the Writer Service URL defined for the identity provider.
* The URL is configured as the value for the Writer Service URL attribute when
* an authentication domain is created. Use the format
* 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.
*/
/**
* Gets handle to 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
*/
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
*/
throws ServletException, IOException {
}
/**
* Description : The QueryString will contain providerid=<URL encoded URI>,
* LRURL=URL to redirect to after setting the preferred IDP cookie
*
* @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
*/
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;
}
"Preferred Cookie Name is " + preferred_cookie_name);
}
try {
if (INTRODUCTION_COOKIE_TYPE == null ||
"Cookie type is null, set to persistent."
);
}
}
if (INTRODUCTION_URL_SCHEME == null ||
"URL Scheme is null, set to https."
);
}
}
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 reset Preferred IDP cookie.");
isValidReturn = false;
} else {
isValidReturn = true;
}
);
if (providerId == null ||
// Nothing to reset in preferred IDP cookie. Do nothing
// Do not throw any error page to user as this operation is
// done behind the screens.
"Provider Id not in request, "+
"Cannot reset preferred idp."
);
if (isValidReturn) {
} else {
}
return;
}
);
if (cookieValue == null ||
// Preferred IDP Cookie does not exist.
// Create a new cookie with this provider id as the only
// value
"Preferred IDP Cookie Not found"
);
}
);
} else {
);
}
"Cookie Type is " +
);
"Cookie value is " +
);
"Preferred Cookie Name " +
);
}
int maxAge;
if (!(INTRODUCTION_COOKIE_DOMAIN == null ||
}
} else {
}
"/",
);
if(isValidReturn) {
"Redirect to " +
);
}
} else {
"No return URL. " +
"Set preferred IDP cookie and "+
"return error page"
);
}
}
return;
} catch(IOException e) {
}
}
/**
* This function is used to reset the preferred IDP cookie based on the
* present value and the providerId of the IDP that calls this service
* @param existing cookie value
* @param current IDP provider ID that will be added to the top of the list
* @return cookie value that needs to be set as the preferred IDP cookie
*/
boolean bIsSAML2) {
// Steps
// 1. Check if existingCookieValue has toAddCookieValue
// 2. If yes remove that value from existingCookieValue
// 3. append toAddCookieValue to existingCookieValue at end and return
);
new StringTokenizer(
);
while (st.hasMoreTokens()) {
continue;
} else {
}
}
return returnCookie.toString();
}
if (providerURL == null ||
return null;
}
if (bIsSAML2) {
byte[] returnBytes = null;
try {
} catch (Exception e) {
"CookieWriterServlet.generateSuccinctID: ", e);
returnBytes = null;
}
return returnBytes;
} else {
try {
} catch (Exception e) {
"CookieWriterServlet.generateSuccinctID: ", e);
return null;
}
}
}
}
}