Search in sources :

Example 11 with StoredValue

use of password.pwm.config.StoredValue in project pwm by pwm-project.

the class AbstractProfile method readVerificationMethods.

Set<IdentityVerificationMethod> readVerificationMethods(final PwmSetting pwmSetting, final VerificationMethodValue.EnabledState enabledState) {
    final Set<IdentityVerificationMethod> result = new LinkedHashSet<>();
    final StoredValue configValue = storedValueMap.get(pwmSetting);
    final VerificationMethodValue.VerificationMethodSettings verificationMethodSettings = (VerificationMethodValue.VerificationMethodSettings) configValue.toNativeObject();
    for (final IdentityVerificationMethod recoveryVerificationMethods : IdentityVerificationMethod.availableValues()) {
        if (verificationMethodSettings.getMethodSettings().containsKey(recoveryVerificationMethods)) {
            if (verificationMethodSettings.getMethodSettings().get(recoveryVerificationMethods).getEnabledState() == enabledState) {
                result.add(recoveryVerificationMethods);
            }
        }
    }
    return result;
}
Also used : IdentityVerificationMethod(password.pwm.config.option.IdentityVerificationMethod) LinkedHashSet(java.util.LinkedHashSet) VerificationMethodValue(password.pwm.config.value.VerificationMethodValue) StoredValue(password.pwm.config.StoredValue)

Example 12 with StoredValue

use of password.pwm.config.StoredValue in project pwm by pwm-project.

the class AbstractProfile method readSettingAsEnum.

@Override
public <E extends Enum<E>> E readSettingAsEnum(final PwmSetting setting, final Class<E> enumClass) {
    final StoredValue value = storedValueMap.get(setting);
    final E returnValue = Configuration.JavaTypeConverter.valueToEnum(setting, value, enumClass);
    if (MessageSendMethod.class.equals(enumClass)) {
        Configuration.deprecatedSettingException(setting, this.getIdentifier(), (MessageSendMethod) returnValue);
    }
    return returnValue;
}
Also used : StoredValue(password.pwm.config.StoredValue)

Example 13 with StoredValue

use of password.pwm.config.StoredValue in project pwm by pwm-project.

the class AbstractProfile method makeValueMap.

static Map<PwmSetting, StoredValue> makeValueMap(final StoredConfiguration storedConfiguration, final String identifier, final PwmSettingCategory pwmSettingCategory) {
    final Map<PwmSetting, StoredValue> valueMap = new LinkedHashMap<>();
    final List<PwmSettingCategory> categories = new ArrayList<>();
    categories.add(pwmSettingCategory);
    categories.addAll(pwmSettingCategory.getChildCategories());
    for (final PwmSettingCategory category : categories) {
        for (final PwmSetting setting : category.getSettings()) {
            final StoredValue value = storedConfiguration.readSetting(setting, identifier);
            valueMap.put(setting, value);
        }
    }
    return valueMap;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList) StoredValue(password.pwm.config.StoredValue) LinkedHashMap(java.util.LinkedHashMap)

Example 14 with StoredValue

use of password.pwm.config.StoredValue in project pwm by pwm-project.

the class LocaleHelper method getConfigLocaleStats.

public static ConfigLocaleStats getConfigLocaleStats() throws PwmUnrecoverableException, PwmOperationalException {
    final ConfigLocaleStats configLocaleStats = new ConfigLocaleStats();
    {
        final StoredValue storedValue = PwmSetting.CHALLENGE_RANDOM_CHALLENGES.getDefaultValue(PwmSettingTemplateSet.getDefault());
        final Map<String, List<ChallengeItemConfiguration>> value = ((ChallengeValue) storedValue).toNativeObject();
        for (final String localeStr : value.keySet()) {
            final Locale loopLocale = LocaleHelper.parseLocaleString(localeStr);
            configLocaleStats.getDefaultChallenges().add(loopLocale);
        }
    }
    for (final Locale locale : LocaleInfoGenerator.knownLocales()) {
        configLocaleStats.descriptionPresentLocalizations.put(locale, 0);
        configLocaleStats.descriptionMissingLocalizations.put(locale, 0);
    }
    for (final PwmSetting pwmSetting : PwmSetting.values()) {
        final String defaultValue = pwmSetting.getDescription(PwmConstants.DEFAULT_LOCALE);
        configLocaleStats.descriptionPresentLocalizations.put(PwmConstants.DEFAULT_LOCALE, configLocaleStats.descriptionPresentLocalizations.get(PwmConstants.DEFAULT_LOCALE) + 1);
        for (final Locale locale : LocaleInfoGenerator.knownLocales()) {
            if (!PwmConstants.DEFAULT_LOCALE.equals(locale)) {
                final String localeValue = pwmSetting.getDescription(locale);
                if (defaultValue.equals(localeValue)) {
                    configLocaleStats.descriptionMissingLocalizations.put(PwmConstants.DEFAULT_LOCALE, configLocaleStats.descriptionMissingLocalizations.get(locale) + 1);
                } else {
                    configLocaleStats.descriptionPresentLocalizations.put(PwmConstants.DEFAULT_LOCALE, configLocaleStats.descriptionPresentLocalizations.get(locale) + 1);
                }
            }
        }
    }
    for (final Locale locale : LocaleInfoGenerator.knownLocales()) {
        final int totalCount = PwmSetting.values().length;
        final int presentCount = configLocaleStats.getDescriptionPresentLocalizations().get(locale);
        final Percent percent = new Percent(presentCount, totalCount);
        configLocaleStats.getDescriptionPercentLocalizations().put(locale, percent.pretty());
    }
    return configLocaleStats;
}
Also used : Locale(java.util.Locale) PwmSetting(password.pwm.config.PwmSetting) Percent(password.pwm.util.java.Percent) ChallengeItemConfiguration(password.pwm.config.value.data.ChallengeItemConfiguration) StoredValue(password.pwm.config.StoredValue) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 15 with StoredValue

use of password.pwm.config.StoredValue in project pwm by pwm-project.

the class StoredConfigurationImpl method copyProfileID.

public void copyProfileID(final PwmSettingCategory category, final String sourceID, final String destinationID, final UserIdentity userIdentity) throws PwmUnrecoverableException {
    if (!category.hasProfiles()) {
        throw PwmUnrecoverableException.newException(PwmError.ERROR_INVALID_CONFIG, "can not copy profile ID for category " + category + ", category does not have profiles");
    }
    final List<String> existingProfiles = this.profilesForSetting(category.getProfileSetting());
    if (!existingProfiles.contains(sourceID)) {
        throw PwmUnrecoverableException.newException(PwmError.ERROR_INVALID_CONFIG, "can not copy profile ID for category, source profileID '" + sourceID + "' does not exist");
    }
    if (existingProfiles.contains(destinationID)) {
        throw PwmUnrecoverableException.newException(PwmError.ERROR_INVALID_CONFIG, "can not copy profile ID for category, destination profileID '" + destinationID + "' already exists");
    }
    {
        final Collection<PwmSettingCategory> interestedCategories = PwmSettingCategory.associatedProfileCategories(category);
        for (final PwmSettingCategory interestedCategory : interestedCategories) {
            for (final PwmSetting pwmSetting : interestedCategory.getSettings()) {
                if (!isDefaultValue(pwmSetting, sourceID)) {
                    final StoredValue value = readSetting(pwmSetting, sourceID);
                    writeSetting(pwmSetting, destinationID, value, userIdentity);
                }
            }
        }
    }
    final List<String> newProfileIDList = new ArrayList<>();
    newProfileIDList.addAll(existingProfiles);
    newProfileIDList.add(destinationID);
    writeSetting(category.getProfileSetting(), new StringArrayValue(newProfileIDList), userIdentity);
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList) Collection(java.util.Collection) StoredValue(password.pwm.config.StoredValue) StringArrayValue(password.pwm.config.value.StringArrayValue)

Aggregations

StoredValue (password.pwm.config.StoredValue)21 PwmSetting (password.pwm.config.PwmSetting)11 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)4 LinkedHashMap (java.util.LinkedHashMap)4 PwmSettingCategory (password.pwm.config.PwmSettingCategory)4 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)4 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)4 List (java.util.List)3 TreeMap (java.util.TreeMap)3 StringValue (password.pwm.config.value.StringValue)3 PwmException (password.pwm.error.PwmException)3 PwmOperationalException (password.pwm.error.PwmOperationalException)3 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)2 X509Certificate (java.security.cert.X509Certificate)2 ServletException (javax.servlet.ServletException)2 StringArrayValue (password.pwm.config.value.StringArrayValue)2 VerificationMethodValue (password.pwm.config.value.VerificationMethodValue)2 Serializable (java.io.Serializable)1 URISyntaxException (java.net.URISyntaxException)1