diff --git a/cloud-common/src/main/java/com/cm/common/component/SecurityComponent.java b/cloud-common/src/main/java/com/cm/common/component/SecurityComponent.java index 6c8479d..bc213da 100644 --- a/cloud-common/src/main/java/com/cm/common/component/SecurityComponent.java +++ b/cloud-common/src/main/java/com/cm/common/component/SecurityComponent.java @@ -66,7 +66,6 @@ public class SecurityComponent { List roleIds = new ArrayList<>(); for (GrantedAuthority grantedAuthority : grantedAuthorities) { RoleGrantedAuthority roleGrantedAuthority = (RoleGrantedAuthority) grantedAuthority; - ; roleIds.add(roleGrantedAuthority.getRoleId()); } return roleIds; diff --git a/cloud-common/src/main/java/com/cm/common/utils/RegexUtil.java b/cloud-common/src/main/java/com/cm/common/utils/RegexUtil.java index 720d54f..9cadf14 100644 --- a/cloud-common/src/main/java/com/cm/common/utils/RegexUtil.java +++ b/cloud-common/src/main/java/com/cm/common/utils/RegexUtil.java @@ -15,6 +15,18 @@ import java.util.regex.Pattern; **/ public class RegexUtil { + /** + * 特殊字符 + */ + public static final String SPECIAL_CHARACTERS = "#?!@$%^&*-_"; + /** + * 密码最小长度 + */ + public static final int PASSWORD_LENGTH_MIN = 6; + /** + * 密码最大长度 + */ + public static final int PASSWORD_LENGTH_MAX = 16; /** * 手机 */ @@ -35,6 +47,48 @@ public class RegexUtil { * 身份证 */ private static final Pattern PATTERN_IDENTITY = Pattern.compile("(^\\d{15}$)|(^\\d{17}(x|X|\\d)$)"); + /** + * 弱密码 + */ + private static final Pattern PASSWORD_WEEK = Pattern.compile(String.format("(?=.*[A-Za-z0-9%s]).{%d,%d}", SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX)); + /** + * 中密码 + */ + private static final Pattern PASSWORD_MIDDLE = Pattern.compile(String.format("((?=.*[A-Za-z])(?=.*[0-9]))|((?=.*[A-Za-z])(?=.*[%s]))|((?=.*[0-9])(?=.*[%s])).{%d,%d}", SPECIAL_CHARACTERS, SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX)); + /** + * 强密码 + */ + private static final Pattern PASSWORD_STRONG = Pattern.compile(String.format("(?=.*[A-Za-z])(?=.*[0-9])(?=.*[%s]).{%d,%d}", SPECIAL_CHARACTERS, PASSWORD_LENGTH_MIN, PASSWORD_LENGTH_MAX)); + + /** + * 判断弱密码强度 + * + * @param input + * @return + */ + public static boolean isPasswordWeek(String input) { + return PASSWORD_WEEK.matcher(input).matches(); + } + + /** + * 判断中密码强度 + * + * @param input + * @return + */ + public static boolean isPasswordMiddle(String input) { + return PASSWORD_MIDDLE.matcher(input).matches(); + } + + /** + * 判断强密码强度 + * + * @param input + * @return + */ + public static boolean isPasswordStrong(String input) { + return PASSWORD_STRONG.matcher(input).matches(); + } /** * 判断电话