package in.co.sunrays.proj1.action;
import in.co.sunrays.proj1.dto.RoleDTO; import in.co.sunrays.proj1.dto.UserDTO; import in.co.sunrays.proj1.exception.ApplicationException; import in.co.sunrays.proj1.service.RoleServiceInt; import in.co.sunrays.proj1.service.UserServiceInt; import org.apache.log4j.Logger; /** * Login functionality Action. Performs operation for Login * * @author SUNRAYS Technologies * @version 1.0 * @Copyright (c) SUNRAYS Technologies */ public class LoginAction extends BaseAction { private static Logger log = Logger.getLogger(LoginAction.class); private String login; private String password; private UserServiceInt service; private RoleServiceInt roleService; public void setService(UserServiceInt service) { this.service = service; } public String getLogin() { return login; } public void setLogin(String login) { this.login = login; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public RoleServiceInt getRoleService() { return roleService; } public void setRoleService(RoleServiceInt roleService) { this.roleService = roleService; } /** * Performs display operations for LoginAction * * @return type String * @return INPUT */ @Override public String input() { log.debug("LoginAction.input() Start"); log.debug("LoginAction.input() End"); return INPUT; } /** * Performs submit operations for LoginAction * * @return type String * @return SUCCESS */ @Override public String execute() { log.debug("LoginAction.execute() Start"); UserDTO dto = new UserDTO(); dto.setLogin(login); dto.setPassword(password); dto.setLastLoginIP(request.getRemoteAddr()); try { if (OP_SIGNIN.equalsIgnoreCase(operation)) { dto = service.authenticate(dto); session.put("user", dto); // Getting Role of User RoleDTO roleDTO = roleService.findByPK(dto.getRoleId()); session.put("role", roleDTO.getValue()); } } catch (ApplicationException e) { log.error("Critical Issue ", e); addActionError(e.getMessage()); return INPUT; } log.debug("LoginAction.execute() End " + operation); return operation; } } |