|
@@ -35,6 +35,10 @@ import java.util.Set;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.regex.PatternSyntaxException;
|
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+
|
|
|
+import password.pwm.PwmApplication;
|
|
|
+import password.pwm.config.PwmSetting;
|
|
|
import password.pwm.config.UserPermission;
|
|
|
import password.pwm.config.option.ADPolicyComplexity;
|
|
|
import password.pwm.health.HealthMessage;
|
|
@@ -194,6 +198,7 @@ public class PwmPasswordPolicy implements Profile,Serializable {
|
|
|
for (final PwmPasswordRule rule : PwmPasswordRule.values()) {
|
|
|
final String ruleKey = rule.getKey();
|
|
|
if (this.policyMap.containsKey(ruleKey) || otherPolicy.policyMap.containsKey(ruleKey)) {
|
|
|
+
|
|
|
switch (rule) {
|
|
|
case DisallowedValues:
|
|
|
case DisallowedAttributes:
|
|
@@ -217,26 +222,33 @@ public class PwmPasswordPolicy implements Profile,Serializable {
|
|
|
break;
|
|
|
|
|
|
case ExpirationInterval:
|
|
|
- newPasswordPolicies.put(ruleKey, mergeMin(policyMap.get(ruleKey), otherPolicy.policyMap.get(ruleKey)));
|
|
|
+ final String expirationIntervalLocalValue = StringUtils.defaultString(policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+ final String expirationIntervalOtherValue = StringUtils.defaultString(otherPolicy.policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+ newPasswordPolicies.put(ruleKey, mergeMin(expirationIntervalLocalValue, expirationIntervalOtherValue));
|
|
|
break;
|
|
|
|
|
|
case MinimumLifetime:
|
|
|
- newPasswordPolicies.put(ruleKey, mergeMin(policyMap.get(ruleKey), otherPolicy.policyMap.get(ruleKey)));
|
|
|
+ final String minimumLifetimeLocalValue = StringUtils.defaultString(policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+ final String minimumLifetimeOtherValue = StringUtils.defaultString(otherPolicy.policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+ newPasswordPolicies.put(ruleKey, mergeMin(minimumLifetimeLocalValue, minimumLifetimeOtherValue));
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
+ final String localValueString = StringUtils.defaultString(policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+ final String otherValueString = StringUtils.defaultString(otherPolicy.policyMap.get(ruleKey), rule.getDefaultValue());
|
|
|
+
|
|
|
switch (rule.getRuleType()) {
|
|
|
case MIN:
|
|
|
- newPasswordPolicies.put(ruleKey, mergeMin(policyMap.get(ruleKey), otherPolicy.policyMap.get(ruleKey)));
|
|
|
+ newPasswordPolicies.put(ruleKey, mergeMin(localValueString, otherValueString));
|
|
|
break;
|
|
|
|
|
|
case MAX:
|
|
|
- newPasswordPolicies.put(ruleKey, mergeMax(policyMap.get(ruleKey), otherPolicy.policyMap.get(ruleKey)));
|
|
|
+ newPasswordPolicies.put(ruleKey, mergeMax(localValueString, otherValueString));
|
|
|
break;
|
|
|
|
|
|
case BOOLEAN:
|
|
|
- final boolean localValue = StringHelper.convertStrToBoolean(policyMap.get(ruleKey));
|
|
|
- final boolean otherValue = StringHelper.convertStrToBoolean(otherPolicy.policyMap.get(ruleKey));
|
|
|
+ final boolean localValue = StringHelper.convertStrToBoolean(localValueString);
|
|
|
+ final boolean otherValue = StringHelper.convertStrToBoolean(otherValueString);
|
|
|
|
|
|
if (rule.isPositiveBooleanMerge()) {
|
|
|
newPasswordPolicies.put(ruleKey, String.valueOf(localValue || otherValue));
|
|
@@ -372,7 +384,7 @@ public class PwmPasswordPolicy implements Profile,Serializable {
|
|
|
return readRegExSetting(rule, macroMachine, input);
|
|
|
}
|
|
|
|
|
|
- static List<Pattern> readRegExSetting(final PwmPasswordRule rule, final MacroMachine macroMachine, final String input) {
|
|
|
+ List<Pattern> readRegExSetting(final PwmPasswordRule rule, final MacroMachine macroMachine, final String input) {
|
|
|
if (input == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
@@ -383,7 +395,11 @@ public class PwmPasswordPolicy implements Profile,Serializable {
|
|
|
|
|
|
for (final String value : values) {
|
|
|
if (value != null && value.length() > 0) {
|
|
|
- final String valueToCompile = (macroMachine == null) ? value : macroMachine.expandMacros(value);
|
|
|
+ String valueToCompile = value;
|
|
|
+
|
|
|
+ if (macroMachine != null && readBooleanValue(PwmPasswordRule.AllowMacroInRegExSetting)) {
|
|
|
+ valueToCompile = macroMachine.expandMacros(value);
|
|
|
+ }
|
|
|
|
|
|
try {
|
|
|
final Pattern loopPattern = Pattern.compile(valueToCompile);
|