| | |
| | | String passwordEncrypt = oldPwd; |
| | | String password = RSAUtil.decryptFront(passwordEncrypt, RSAUtil.fontSeparator)[0]; |
| | | String passwordDB = RSAUtil.decrypt(userInf.getUpassword(),RSAUtil.getPrivateKey()); |
| | | |
| | | if(passwordDB.equals(password)){ |
| | | return userService.updatePasswordByRSA(userInf,newPwd); |
| | | }else { |
| | |
| | | if(!ActionUtil.EncryptionMD5(newPwd).equals(passwordMD5)){ |
| | | throw new InvalidParameterException("参数校验失败"); |
| | | } |
| | | if(!ActionUtil.filterPwd(newPwd)){ |
| | | return new Response().set(0,false,"新密码验证不通过(最少8个字符,至少1个大写字母,1个小写字母,1个数字和1个特殊字符)"); |
| | | } |
| | | String pwd = RSAUtil.encrypt(newPwd,RSAUtil.getPublicKey()); |
| | | user.setUpassword(pwd); |
| | | user.setUSnId(pwd); |
| | |
| | | userInf.setUName("未登录的用户账号"); |
| | | userInf.setUId(0L); |
| | | userInf.setURole(0); |
| | | userInf.setUpassword("123456"); |
| | | }else{ |
| | | userInf=(UserInf) session.getAttribute("user"); |
| | | } |
| | |
| | | return FilenameUtils.getName(fileName); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 输入验证:路径遍历,防止恶意符号影响文件体系 |
| | | * 过滤掉特殊字符 ”/\" : | * ? < >” |
| | | */ |
| | | public static boolean filterPwd(String pwd){ |
| | | String regex="^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[!@#$%^&*()_+])[a-zA-Z\\d!@#$%^&*()_+]{8,}$"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Matcher matcher = pattern.matcher(pwd); |
| | | return matcher.matches(); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(filterPwd("Aa@123456")); |
| | | } |
| | | |
| | | } |