Files
springboot-template/src/main/java/com/aisi/template/annotation/StrongPassword.java
shenjianZ 40c85c3c1f feat: 实现完整的 RBAC 权限管理系统与基础设施增强
在初始认证基础上,新增完整的 RBAC 权限模型(角色、权限、菜单三级管理),
  集成审计日志、接口限流、登录失败锁定、Refresh Token 机制、Redis 分布式缓存与锁、
  RocketMQ 消息队列,并引入 Flyway 数据库版本管理,同时补充项目文档与使用示例
2026-04-10 10:58:22 +08:00

88 lines
2.0 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package com.aisi.template.annotation;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 强密码验证注解
* 验证密码是否符合安全要求
*
* 默认要求:
* - 至少 8 个字符
* - 包含至少一个大写字母
* - 包含至少一个小写字母
* - 包含至少一个数字
* - 包含至少一个特殊字符
*
* 使用示例:
* <pre>
* &#64;StrongPassword(
* minLength = 10,
* requireUppercase = true,
* requireLowercase = true,
* requireDigit = true,
* requireSpecialChar = true
* )
* private String password;
* </pre>
*
* @author Claude
* @since 2024-04-09
*/
@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = PasswordValidator.class)
public @interface StrongPassword {
/**
* 错误消息
* - 默认:"密码必须至少8个字符包含大小写字母、数字和特殊字符"
*/
String message() default "密码必须至少8个字符包含大小写字母、数字和特殊字符";
/**
* 分组
*/
Class<?>[] groups() default {};
/**
* 负载
*/
Class<? extends Payload>[] payload() default {};
/**
* 最小密码长度
* - 默认8
*/
int minLength() default 8;
/**
* 是否需要大写字母
* - 默认true
*/
boolean requireUppercase() default true;
/**
* 是否需要小写字母
* - 默认true
*/
boolean requireLowercase() default true;
/**
* 是否需要数字
* - 默认true
*/
boolean requireDigit() default true;
/**
* 是否需要特殊字符
* - 默认true
* - 特殊字符包括:!@#$%^&*()_+-=[]{}|;:,.<>?
*/
boolean requireSpecialChar() default true;
}