| | |
| | | import com.nanometer.smartlab.util.FacesUtils; |
| | | import org.apache.log4j.Logger; |
| | | import org.apache.shiro.authc.DisabledAccountException; |
| | | import org.apache.shiro.authc.ExcessiveAttemptsException; |
| | | import org.apache.shiro.authc.UnknownAccountException; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.subject.Subject; |
| | |
| | | |
| | | private String loginAcct; |
| | | private String loginPwd; |
| | | private static Byte ischange = 0; |
| | | |
| | | public String login() { |
| | | UsernamePasswordToken token = new UsernamePasswordToken(loginAcct, loginPwd); |
| | |
| | | } catch (UnknownAccountException e) { |
| | | FacesUtils.warn("用户名不存在"); |
| | | return null; |
| | | } catch (ExcessiveAttemptsException e) { |
| | | FacesUtils.warn("登陆失败,密码连续输入错误超过8次,锁定1分钟!"); |
| | | return null; |
| | | } catch (Exception e) { |
| | | logger.error("登陆失败", e); |
| | | } |
| | |
| | | if (currentUser.isAuthenticated()) {//登录成功进入主页 |
| | | SysUser user = this.sysUserService.getSysUserByAccount(loginAcct); |
| | | currentUser.getSession(true).setAttribute(Constants.SESSION_USER, user); |
| | | |
| | | String PW_PATTERN = "(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[~!@#$%^&*_.]).{8,}"; |
| | | if (!loginPwd.matches(PW_PATTERN)) { |
| | | ischange = 1; |
| | | }else { |
| | | ischange = 0; |
| | | } |
| | | |
| | | this.menuController.initPage(); |
| | | return Constants.PAGE_INDEX + Constants.REDIRECT; |
| | |
| | | public void setLoginPwd(String loginPwd) { |
| | | this.loginPwd = loginPwd; |
| | | } |
| | | |
| | | |
| | | public Byte getIschange() { |
| | | return ischange; |
| | | } |
| | | |
| | | public void setIschange(Byte ischange) { |
| | | this.ischange = ischange; |
| | | } |
| | | } |