| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | |
| | | return new Response<>().set(1,false,"密码错误"); |
| | | } |
| | | |
| | | public Response loginByRSA(String userName, String pwd,String deliveredCode, HttpServletRequest request) { |
| | | public Response loginByRSA(String userName, String pwd, String deliveredCode, HttpServletRequest request, Integer validCode) { |
| | | Response<Object> response = new Response<>(); |
| | | //默认赋值0 |
| | | response.setData3(0); |
| | | //Locale.setDefault(Locale.ENGLISH); |
| | | deliveredCode = deliveredCode.toUpperCase(Locale.ENGLISH); |
| | | if(YamlProperties.fontDynamicCodeSwitch.toLowerCase(Locale.ENGLISH).equals("true")) { |
| | | String fontDynamicCode = (String) ActionUtil.getSession().getAttribute("fontDynamicCode"); |
| | | if (fontDynamicCode == null || "".equals(fontDynamicCode)) { |
| | | return response.set(1, false, MessageUtils.getMessage("RefreshVerification")); |
| | | } |
| | | if (!deliveredCode.equals(fontDynamicCode.toUpperCase(Locale.ENGLISH))) { |
| | | return response.set(1, false, MessageUtils.getMessage("VerificationError")); |
| | | if(validCode ==null ) { //属性不存在,则进行验证码校验;属性存在,则不进行验证码校验 |
| | | if (YamlProperties.fontDynamicCodeSwitch.toLowerCase(Locale.ENGLISH).equals("true")) { |
| | | String fontDynamicCode = (String) ActionUtil.getSession().getAttribute("fontDynamicCode"); |
| | | if (fontDynamicCode == null || "".equals(fontDynamicCode)) { |
| | | return response.set(1, false, MessageUtils.getMessage("RefreshVerification")); |
| | | } |
| | | if (!deliveredCode.equals(fontDynamicCode.toUpperCase(Locale.ENGLISH))) { |
| | | return response.set(1, false, MessageUtils.getMessage("VerificationError")); |
| | | } |
| | | } |
| | | } |
| | | //验证正确,清除验证码 |
| | |
| | | } |
| | | |
| | | if (subject.isAuthenticated()) { |
| | | |
| | | //验证密码时效性 |
| | | int flag=userService.checkPasswordValidity(userInf); |
| | | if(flag==-1){ |
| | | return response.set(1, false, "密码长期未修改已失效,请修改密码"); |
| | | } |
| | | //登录成功 |
| | | servletContext.setAttribute(userName, request.getSession().getId()); |
| | | //日登录用户统计 |