use of com.sun.identity.shared.locale.L10NMessageImpl in project OpenAM by OpenRock.
the class LoginServlet method initializeRequestContext.
/**
*
*
*/
protected void initializeRequestContext(RequestContext requestContext) {
super.initializeRequestContext(requestContext);
// 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.
ViewBeanManager viewBeanManager = new ViewBeanManager(requestContext, PACKAGE_NAME);
((RequestContextImpl) requestContext).setViewBeanManager(viewBeanManager);
HttpServletRequest request = requestContext.getRequest();
HttpServletResponse response = requestContext.getResponse();
// by redirecting the response with dummy cookie.
if (checkForCookiesInBrowser(request, response, debug)) {
throw new CompleteRequestException();
}
// Check content length
try {
RequestUtils.checkContentLength(request);
} catch (L10NMessageImpl e) {
if (debug.messageEnabled()) {
ISLocaleContext localeContext = new ISLocaleContext();
localeContext.setLocale(request);
java.util.Locale locale = localeContext.getLocale();
debug.message("LoginServlet: " + e.getL10NMessage(locale));
}
AuthExceptionViewBean vb = (AuthExceptionViewBean) viewBeanManager.getViewBean(com.sun.identity.authentication.UI.AuthExceptionViewBean.class);
vb.forwardTo(requestContext);
throw new CompleteRequestException();
}
// Check if the hostname in the URL is an FQDN else
// redirect to the fqdn
String client_type = AuthUtils.getClientType(request);
if (debug.messageEnabled()) {
debug.message("Client Type = " + client_type);
}
String hostName = AuthUtils.getHostName(request);
if (!AuthUtils.isValidFQDNRequest(hostName)) {
try {
String newHN = AuthUtils.getValidFQDNResource(hostName, request);
if (debug.messageEnabled()) {
debug.message("FQDN = " + newHN);
}
if (AuthUtils.isGenericHTMLClient(client_type)) {
debug.message("This is HTML");
response.sendRedirect(newHN);
} else {
String fileName = AuthUtils.getDefaultFileName(request, REDIRECT_JSP);
if (debug.messageEnabled()) {
debug.message("Forward to : " + fileName);
}
RequestDispatcher dispatcher = request.getRequestDispatcher(fileName);
dispatcher.forward(request, response);
}
} catch (Exception e) {
// came here continue
}
throw new CompleteRequestException();
}
final boolean isLoginRequest = LOGIN_PAGE_NAME.equals(getPageName(request));
String cookieURL = AuthUtils.getCookieURLForSessionUpgrade(request);
if (cookieURL != null && isLoginRequest) {
rerouteRequest(request, response, cookieURL);
return;
}
// Check whether this is the correct server to accept the client
// response.
String authCookieValue = AuthUtils.getAuthCookieValue(request);
if ((authCookieValue != null) && (authCookieValue.length() != 0) && (!authCookieValue.equalsIgnoreCase("LOGOUT"))) {
//send Auth request to cookie (original) server
try {
SessionID sessionID = new SessionID(authCookieValue);
cookieURL = AuthUtils.getCookieURL(sessionID);
} catch (Exception e) {
if (debug.messageEnabled()) {
debug.message("LoginServlet error in Session : " + e.toString());
}
}
if (debug.messageEnabled()) {
debug.message("cookieURL : " + cookieURL);
}
if (isLoginRequest && cookieURL != null && !cookieURL.isEmpty() && !AuthUtils.isLocalServer(cookieURL, true) && !AuthUtils.isSessionUpgradeOrForceAuth(request)) {
rerouteRequest(request, response, cookieURL);
}
}
}
Aggregations