Class PasswordPolicy
java.lang.Object
cloud.opencode.base.crypto.password.PasswordPolicy
Password policy for validating password strength - Configurable rules for password complexity
密码策略用于验证密码强度 - 可配置的密码复杂度规则
Features | 主要功能:
- Minimum length and complexity rules - 最小长度和复杂度规则
- Character class requirements - 字符类别要求
Usage Examples | 使用示例:
PasswordPolicy policy = PasswordPolicy.defaultPolicy();
boolean valid = policy.validate("MyP@ssw0rd");
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-crypto V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for PasswordPolicy PasswordPolicy 构建器static final classValidation result containing validity and violations 验证结果,包含有效性和违规信息 -
Method Summary
Modifier and TypeMethodDescriptionstatic PasswordPolicybasic()Create a basic password policy 创建基本密码策略static PasswordPolicy.Builderbuilder()Create a new builder 创建新的构建器static PasswordPolicyCreate a default password policy (OWASP recommended) 创建默认密码策略(OWASP 推荐)intGet maximum length 获取最大长度intGet minimum length 获取最小长度booleanCheck if password is valid 检查密码是否有效static PasswordPolicystrong()Create a strong password policy 创建强密码策略Validate password against this policy 根据此策略验证密码
-
Method Details
-
defaultPolicy
Create a default password policy (OWASP recommended) 创建默认密码策略(OWASP 推荐)- Returns:
- default password policy
-
strong
Create a strong password policy 创建强密码策略- Returns:
- strong password policy
-
basic
Create a basic password policy 创建基本密码策略- Returns:
- basic password policy
-
builder
Create a new builder 创建新的构建器- Returns:
- builder instance
-
validate
Validate password against this policy 根据此策略验证密码- Parameters:
password- password to validate- Returns:
- validation result
-
isValid
Check if password is valid 检查密码是否有效- Parameters:
password- password to check- Returns:
- true if valid
-
getMinLength
public int getMinLength()Get minimum length 获取最小长度- Returns:
- minimum length
-
getMaxLength
public int getMaxLength()Get maximum length 获取最大长度- Returns:
- maximum length
-