|
@@ -62,7 +62,6 @@ import java.io.StringWriter;
|
|
|
import java.security.cert.X509Certificate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
@@ -85,7 +84,8 @@ public class DomainConfig implements SettingReader
|
|
|
|
|
|
private final ConfigurationSuppliers configurationSuppliers = new ConfigurationSuppliers();
|
|
|
|
|
|
- private final DataCache dataCache = new DataCache();
|
|
|
+ private final Map<String, PwmPasswordPolicy> cachedPasswordPolicy;
|
|
|
+ private final Map<String, Map<Locale, ChallengeProfile>> cachedChallengeProfiles;
|
|
|
private final StoredSettingReader settingReader;
|
|
|
|
|
|
public DomainConfig( final AppConfig appConfig, final DomainID domainID )
|
|
@@ -94,8 +94,25 @@ public class DomainConfig implements SettingReader
|
|
|
this.storedConfiguration = appConfig.getStoredConfiguration();
|
|
|
this.domainID = Objects.requireNonNull( domainID );
|
|
|
this.settingReader = new StoredSettingReader( storedConfiguration, null, domainID );
|
|
|
- }
|
|
|
|
|
|
+ this.cachedPasswordPolicy = Map.copyOf( getPasswordProfileIDs().stream()
|
|
|
+ .map( profile -> PwmPasswordPolicy.createPwmPasswordPolicy( this, profile ) )
|
|
|
+ .collect( Collectors.toMap(
|
|
|
+ PwmPasswordPolicy::getIdentifier,
|
|
|
+ pwmPasswordPolicy -> pwmPasswordPolicy
|
|
|
+ ) ) );
|
|
|
+
|
|
|
+ this.cachedChallengeProfiles = Map.copyOf( getChallengeProfileIDs().stream()
|
|
|
+ .collect( Collectors.toMap(
|
|
|
+ profileId -> profileId,
|
|
|
+ profileId -> Map.copyOf( appConfig.getKnownLocales().stream()
|
|
|
+ .collect( Collectors.toMap(
|
|
|
+ locale -> locale,
|
|
|
+ locale -> ChallengeProfile.readChallengeProfileFromConfig( domainID, profileId, locale, storedConfiguration )
|
|
|
+ ) ) )
|
|
|
+ ) ) );
|
|
|
+ }
|
|
|
+
|
|
|
public AppConfig getAppConfig()
|
|
|
{
|
|
|
return appConfig;
|
|
@@ -184,7 +201,7 @@ public class DomainConfig implements SettingReader
|
|
|
throw new IllegalArgumentException( "unknown challenge profileID specified: " + profile );
|
|
|
}
|
|
|
|
|
|
- return ChallengeProfile.readChallengeProfileFromConfig( getDomainID(), profile, locale, storedConfiguration );
|
|
|
+ return cachedChallengeProfiles.get( profile ).get( locale );
|
|
|
}
|
|
|
|
|
|
public long readSettingAsLong( final PwmSetting setting )
|
|
@@ -194,8 +211,7 @@ public class DomainConfig implements SettingReader
|
|
|
|
|
|
public PwmPasswordPolicy getPasswordPolicy( final String profile )
|
|
|
{
|
|
|
- return dataCache.cachedPasswordPolicy
|
|
|
- .computeIfAbsent( profile, s -> PwmPasswordPolicy.createPwmPasswordPolicy( this, profile ) );
|
|
|
+ return cachedPasswordPolicy.get( profile );
|
|
|
}
|
|
|
|
|
|
public List<String> getPasswordProfileIDs( )
|
|
@@ -263,7 +279,7 @@ public class DomainConfig implements SettingReader
|
|
|
{
|
|
|
return appConfig.readAppProperty( property );
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
public DomainID getDomainID()
|
|
|
{
|
|
|
return domainID;
|
|
@@ -302,11 +318,6 @@ public class DomainConfig implements SettingReader
|
|
|
} );
|
|
|
}
|
|
|
|
|
|
- private static class DataCache
|
|
|
- {
|
|
|
- private final Map<String, PwmPasswordPolicy> cachedPasswordPolicy = new LinkedHashMap<>();
|
|
|
- }
|
|
|
-
|
|
|
/* generic profile stuff */
|
|
|
public Map<String, NewUserProfile> getNewUserProfiles( )
|
|
|
{
|