if(user == null || (!user.getIsAdministrator() && !hasAuthorizedRole(user)))
{
//throw new Exception("This user is not authorized to log in...");
httpServletResponse.sendRedirect("unauthorizedLogin.jsp");
NotificationMessage notificationMessage = new NotificationMessage("Authorization failed:", "Authorization", authenticatedUserName, NotificationMessage.AUTHORIZATION_FAILED, "" + authenticatedUserName, "name");
TransactionHistoryController.getController().create(notificationMessage);
return;
}
//TODO - we must fix so these caches are individual to the person - now a login will slow down for all
//CacheController.clearCache("authorizationCache");
//CacheController.clearCache("personalAuthorizationCache", user.getName());
CacheController.clearCacheForGroup("personalAuthorizationCache", user.getName());
// Store the authenticated user in the session
if(session != null)
{
session.setAttribute(INFOGLUE_FILTER_USER, user);
setUserProperties(session, user);
}
//TEST - transferring auth to deliverworking
try
{
if(userName != null && password != null)
{
DesEncryptionHelper encHelper = new DesEncryptionHelper();
String encryptedName = encHelper.encrypt(userName);
String encryptedPassword = encHelper.encrypt(password);
String encryptedNameAsBase64 = Base64.encodeBase64URLSafeString(encryptedName.getBytes("utf-8"));
String encryptedPasswordAsBase64 = Base64.encodeBase64URLSafeString(encryptedPassword.getBytes("utf-8"));
String deliverBaseUrl = CmsPropertyHandler.getComponentRendererUrl();
String[] parts = deliverBaseUrl.split("/");
deliverBaseUrl = "/" + parts[parts.length -1];
//logger.info("used cmsBaseUrl:" + cmsBaseUrl);
ServletContext servletContext = filterConfig.getServletContext().getContext(deliverBaseUrl);
if (servletContext == null)
{
logger.error("Could not autologin to " + deliverBaseUrl + ". Set cross context = true in Tomcat config.");
}
else
{
logger.info("Added encryptedName:" + encryptedName + " = " + user.getName() + " to deliver context");
servletContext.setAttribute(encryptedName, user.getName());
}
int cmsCookieTimeout = 1800; //30 minutes default
String cmsCookieTimeoutString = null; //CmsPropertyHandler.getCmsCookieTimeout();
if(cmsCookieTimeoutString != null)
{
try
{
cmsCookieTimeout = Integer.parseInt(cmsCookieTimeoutString.trim());
}
catch(Exception e) {}
}
//Cookie cookie_iguserid = new Cookie("iguserid", encryptedName.replaceAll("=", "IGEQ"));
Cookie cookie_iguserid = new Cookie("iguserid", encryptedNameAsBase64);
cookie_iguserid.setPath("/");
cookie_iguserid.setMaxAge(cmsCookieTimeout);
httpServletResponse.addCookie(cookie_iguserid);
//Cookie cookie_igpassword = new Cookie ("igpassword", encryptedPassword.replaceAll("=", "IGEQ"));
Cookie cookie_igpassword = new Cookie ("igpassword", encryptedPasswordAsBase64);
cookie_igpassword.setPath("/");
cookie_igpassword.setMaxAge(cmsCookieTimeout);
httpServletResponse.addCookie(cookie_igpassword);
//logger.info(encryptedName + "=" + userName);
//logger.info("After attribute:" + servletContext.getAttribute(encryptedName));
}
}
catch (Exception e)
{
logger.error("Error: " + e.getMessage(), e);
}
//END TEST
String logUserName = userName;
if(logUserName == null || logUserName.equals("") && user != null)
logUserName = user.getName();
if(logUserName == null || logUserName.equals(""))
logUserName = authenticatedUserName;
if(logUserName == null || logUserName.equals(""))
logUserName = "Unknown";
NotificationMessage notificationMessage = new NotificationMessage("Login success:", "Authentication", logUserName, NotificationMessage.AUTHENTICATION_SUCCESS, "" + authenticatedUserName, "name");
TransactionHistoryController.getController().create(notificationMessage);
logger.info("URI:" + httpServletRequest.getRequestURI() + ":" + httpServletRequest.getParameter("ticket"));
if(httpServletRequest.getMethod().equalsIgnoreCase("get") && httpServletRequest.getParameter("ticket") != null && httpServletRequest.getParameter("ticket").length() > 0)
{
String remainingQueryString = HttpUtilities.removeParameter(httpServletRequest.getQueryString(), "ticket");
logger.info("Redirecting to login without ticket");
httpServletResponse.sendRedirect(URI + (remainingQueryString != null && !remainingQueryString.equals("") ? "?" + remainingQueryString : ""));
return;
}
if(successLoginBaseUrl != null && !URL.startsWith(successLoginBaseUrl))
{
logger.info("Redirecting to successLoginBaseUrl: " + successLoginBaseUrl);
checkSuccessRedirect(request, response, URL);
}
else
{
fc.doFilter(request, response);
return;
}
}
else
{
if(userName != null && !userName.equals(""))
{
NotificationMessage notificationMessage = new NotificationMessage("Login failed:", "Authentication", userName, NotificationMessage.AUTHENTICATION_FAILED, "" + userName, "name");
TransactionHistoryController.getController().create(notificationMessage);
}
}
}
catch(Exception e)