@Override
public String intercept(ActionInvocation invocation) throws Exception {
// Get the action context from the invocation so we can access the
// HttpServletRequest and HttpSession objects.
final ActionContext context = invocation.getInvocationContext ();
HttpServletRequest request = (HttpServletRequest) context.get(StrutsStatics.HTTP_REQUEST);
HttpSession session = request.getSession (true);
// Is there a "user" object stored in the user's HttpSession?
Object user = session.getAttribute (SessionConstants.USER_HANDLE);
if (user == null) {
// The user has not logged in yet.
// Is the user attempting to log in right now?
String loginAttempt = request.getParameter (LOGIN_ATTEMPT);
if (! StringUtils.isBlank (loginAttempt) ) { // The user is attempting to log in.
// Process the user's login attempt.
String loginError = processLoginAttempt (request, session);
if ("".equals(loginError) ) {
// The login succeeded send them the login-success page.
log.info(String.format("User %s login [%s]", request.getParameter(LOGIN_EMAIL), request.getRemoteAddr()));
// If they were originally going somewhere else, try and send them there again
String intendedUri = (String) session.getAttribute(SessionConstants.LOGIN_REDIRECT);
if( intendedUri != null)
{
session.removeAttribute(SessionConstants.LOGIN_REDIRECT);
((HttpServletResponse)context.get(StrutsStatics.HTTP_RESPONSE)).sendRedirect(intendedUri);
}
// Otherwise, go to the default
return "login-success";
} else {