“djh”
2024-12-05 eee41a5fb58e6547a43929430f4b72908119db6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package com.gkhy.testFourierSpecialGasMonitor.utils;
 
import com.gkhy.testFourierSpecialGasMonitor.commons.enums.ResultCode;
import com.gkhy.testFourierSpecialGasMonitor.commons.exception.BusinessException;
 
/**
 * @author Mr.huang
 * @decription
 * @date 2024/1/4 10:44
 */
public class PasswordCheckUtil {
 
    public static void passwordIsValid(String pwd){
        if (pwd.length() < 8){
            throw new BusinessException(PasswordCheckUtil.class, ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码长度不够");
        }
        if (!pwd.matches(".*[A-Z].*")){
            throw new BusinessException(PasswordCheckUtil.class,ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码至少包含大小写字母、数字、特殊字符");
        }
        if (!pwd.matches(".*[a-z].*")){
            throw new BusinessException(PasswordCheckUtil.class,ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码至少包含大小写字母、数字、特殊字符");
        }
        if (!pwd.matches(".*\\d.*")){
            throw new BusinessException(PasswordCheckUtil.class,ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码至少包含大小写字母、数字、特殊字符");
        }
        if (!pwd.matches(".*[!@#$%^&*.()?+`~<>,-].*")){
            throw new BusinessException(PasswordCheckUtil.class,ResultCode.PARAM_ERROR_ILLEGAL.getCode(),"密码至少包含大小写字母、数字、特殊字符");
        }
    }
 
}