|
@@ -7,6 +7,9 @@ import org.springframework.security.core.Authentication;
|
|
|
import org.springframework.security.core.context.SecurityContextHolder;
|
|
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
/**
|
|
|
* 安全服务工具类
|
|
|
*
|
|
@@ -83,6 +86,12 @@ public class SecurityUtils {
|
|
|
* @return 加密字符串
|
|
|
*/
|
|
|
public static String encryptPassword(String password) {
|
|
|
+ //密码强度校验
|
|
|
+ Pattern p = Pattern.compile("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?!.*([a-zA-Z0-9])\\1{2}).{8,16}$");
|
|
|
+ Matcher m = p.matcher(password);
|
|
|
+ if(!m.find()){
|
|
|
+ throw new ServiceException("密码需要包含 非连续的 大写英文字母 小写英文字母 数字");
|
|
|
+ }
|
|
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
|
|
|
return passwordEncoder.encode(password);
|
|
|
}
|