username = getAuthCommon().getUsernameFromPrincipal(name);
}
this._log.trace("Request From User with Username: " + username + " - info: AuthType " + req.getAuthType() + " " + req.getProtocol() + " " + req.getRemoteAddr() + " " + req.getRemoteHost());
if (username != null) {
this._log.trace("jpcasclient: user is " + username);
UserDetails userOnSession = (UserDetails) session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER);
if (userOnSession == null || (userOnSession != null && !username.equals(userOnSession.getUsername()))) {
UserDetails user = this.getAuthenticationProvider().getUser(username);
if (user != null) {
if (!user.isAccountNotExpired()) {
req.setAttribute("accountExpired", new Boolean(true));
} else {
if (userOnSession != null && !userOnSession.getUsername().equals(SystemConstants.GUEST_USER_NAME)) {
((AbstractUser) user).setPassword(userOnSession.getPassword());
}
session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, user);
this._log.trace("jpcasclient: new user: " + user.getUsername());
}
} else {
// req.setAttribute("wrongAccountCredential", new Boolean(true));
/* create user on the fly */
user = new User();
((User) user).setUsername(username);
((User) user).setPassword(CasClientPluginSystemCostants.JPCAS_RUNTIME_USER);
((User) user).setLastAccess(new Date());
/* put in the session */
session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, user);
this._log.trace("jpcasclient: new user created on the fly: " + user.getUsername());
}
}
}
}
//Punto 2
String userName = req.getParameter("username");
String password = req.getParameter("password");
if (userName != null && password != null) {
_log.trace("user " + userName + " - password ******** ");
UserDetails user = this.getAuthenticationProvider().getUser(userName, password);
if (user != null) {
if (!user.isAccountNotExpired()) {
req.setAttribute("accountExpired", new Boolean(true));
} else {
session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, user);
_log.trace("Nuovo User: " + user.getUsername());
}
} else {
req.setAttribute("wrongAccountCredential", new Boolean(true));
}
}
//Punto 3
if (session.getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER) == null) {
UserDetails guestUser = this.getUserManager().getGuestUser();
session.setAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER, guestUser);
}
retStatus = ControllerManager.CONTINUE;
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "service", "Error in processing the request");