package com.gkhy.fourierSpecialGasMonitor.utils; import com.gkhy.fourierSpecialGasMonitor.commons.enums.ResultCode; import com.gkhy.fourierSpecialGasMonitor.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(),"密码至少包含大小写字母、数字、特殊字符"); } } }