WSO2 IS 产品目前不提供此功能,但我们可以使用核心用户管理系统中可用的扩展轻松满足此要求。可用的密码历史功能具有更改密码日期时间的历史记录,我们可以使用这些数据来强制执行此要求。
创建一个新的身份连接器以配置最短密码期限和抽象事件处理程序以在密码更改事件期间强制验证。
公共类 PasswordMinAgeValidationHandler 扩展 AbstractEventHandler 实现 IdentityConnectorConfig {
private static final Log log = LogFactory.getLog(PasswordMinAgeValidationHandler.class);
@Override
public void handleEvent(Event event) throws IdentityEventException {
// Validate the password age with min age configured
}
@Override
public String getName() {
return "passwordMinAge";
}
@Override
public String getFriendlyName() {
return "Password Minimum Age";
}
@Override
public String getCategory() {
return "Password Policies";
}
@Override
public Map<String, String> getPropertyNameMapping() {
Map<String, String> nameMapping = new HashMap<>();
nameMapping.put(PasswordMinAgeConstants.PM_MIN_AGE_ENABLE, "Enable Password Minimum Age Feature");
nameMapping.put(PasswordMinAgeConstants.PW_MIN_AGE_COUNT, "Password Minimum Age (Days)");
return nameMapping;
}
@Override
public void init(InitConfig configuration) throws IdentityRuntimeException {
super.init(configuration);
IdentityPasswordMinAgeServiceDataHolder.getInstance().getBundleContext().registerService
(IdentityConnectorConfig.class.getName(), this, null);
}
public Properties getDefaultPropertyValues(String tenantDomain) throws IdentityGovernanceException {
Map<String, String> defaultProperties = new HashMap<>();
defaultProperties.put(PasswordMinAgeConstants.PM_MIN_AGE_ENABLE, configs.getModuleProperties()
.getProperty(PasswordMinAgeConstants.PM_MIN_AGE_ENABLE));
defaultProperties.put(PasswordMinAgeConstants.PW_MIN_AGE_COUNT, configs.getModuleProperties()
.getProperty(PasswordMinAgeConstants.PM_MIN_AGE_ENABLE));
Properties properties = new Properties();
properties.putAll(defaultProperties);
return properties;
}
}
使此类成为OSGi 包并将 PasswordMinAgeValidationHandler 注册为 AbstractEventHandler
protected void activate(ComponentContext context) {
try {
BundleContext bundleContext = context.getBundleContext();
IdentityPasswordMinAgeServiceDataHolder.getInstance().setBundleContext(bundleContext);
PasswordMinAgeValidationHandler handler = new PasswordMinAgeValidationHandler();
context.getBundleContext().registerService(AbstractEventHandler.class.getName(), handler, null);
} catch (Exception e) {
log.error("Error while activating identity governance password min age component.", e);
}
}
- 在 IS_HOME/repository/components/dropins 中部署 jar
在 IS_HOME/repository/conf/identity/identity-event.properties 中添加如下配置
module.name.13=passwordMinAge
passwordMinAge.subscription.1=PRE_UPDATE_CREDENTIAL
passwordMinAge.subscription.2=PRE_UPDATE_CREDENTIAL_BY_ADMIN
passwordMinAge.enable=false
passwordMinAge.count=5
重启 IS 服务器
- 在 Resident Identity Provider 配置 -> 密码策略中,同时启用
Password History
和Password Minimum Age
功能。

在这里你可以找到完整的源代码