Search in sources :

Example 1 with ChallengeValue

use of password.pwm.config.value.ChallengeValue in project pwm by pwm-project.

the class ChallengeProfile method valueToChallengeItemArray.

static List<ChallengeItemConfiguration> valueToChallengeItemArray(final StoredValue value, final Locale locale) {
    if (!(value instanceof ChallengeValue)) {
        throw new IllegalArgumentException("may not read ChallengeValue value");
    }
    final Map<String, List<ChallengeItemConfiguration>> storedValues = (Map<String, List<ChallengeItemConfiguration>>) value.toNativeObject();
    final Map<Locale, List<ChallengeItemConfiguration>> availableLocaleMap = new LinkedHashMap<>();
    for (final Map.Entry<String, List<ChallengeItemConfiguration>> entry : storedValues.entrySet()) {
        final String localeStr = entry.getKey();
        availableLocaleMap.put(LocaleHelper.parseLocaleString(localeStr), entry.getValue());
    }
    final Locale matchedLocale = LocaleHelper.localeResolver(locale, availableLocaleMap.keySet());
    return availableLocaleMap.get(matchedLocale);
}
Also used : Locale(java.util.Locale) ChallengeItemConfiguration(password.pwm.config.value.data.ChallengeItemConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) ChallengeValue(password.pwm.config.value.ChallengeValue) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 ChallengeValue (password.pwm.config.value.ChallengeValue)1 ChallengeItemConfiguration (password.pwm.config.value.data.ChallengeItemConfiguration)1