Search in sources :

Example 1 with PwmSettingCategory

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

the class StoredConfigurationImpl method modifiedSettings.

public List<SettingValueRecord> modifiedSettings() {
    final List<SettingValueRecord> returnObj = new ArrayList<>();
    domModifyLock.readLock().lock();
    try {
        for (final PwmSetting setting : PwmSetting.values()) {
            if (setting.getSyntax() != PwmSettingSyntax.PROFILE && !setting.getCategory().hasProfiles()) {
                if (!isDefaultValue(setting, null)) {
                    final StoredValue value = readSetting(setting);
                    if (value != null) {
                        returnObj.add(new SettingValueRecord(setting, null, value));
                    }
                }
            }
        }
        for (final PwmSettingCategory category : PwmSettingCategory.values()) {
            if (category.hasProfiles()) {
                for (final String profileID : this.profilesForSetting(category.getProfileSetting())) {
                    for (final PwmSetting profileSetting : category.getSettings()) {
                        if (!isDefaultValue(profileSetting, profileID)) {
                            final StoredValue value = readSetting(profileSetting, profileID);
                            if (value != null) {
                                returnObj.add(new SettingValueRecord(profileSetting, profileID, value));
                            }
                        }
                    }
                }
            }
        }
        return returnObj;
    } finally {
        domModifyLock.readLock().unlock();
    }
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList) StoredValue(password.pwm.config.StoredValue)

Example 2 with PwmSettingCategory

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

the class StoredConfigurationImpl method toJsonDebugObject.

public Serializable toJsonDebugObject() {
    domModifyLock.readLock().lock();
    try {
        final TreeMap<String, Object> outputObject = new TreeMap<>();
        for (final PwmSetting setting : PwmSetting.values()) {
            if (setting.getSyntax() != PwmSettingSyntax.PROFILE && !setting.getCategory().hasProfiles()) {
                if (!isDefaultValue(setting, null)) {
                    final StoredValue value = readSetting(setting);
                    outputObject.put(setting.getKey(), value.toDebugJsonObject(null));
                }
            }
        }
        for (final PwmSettingCategory category : PwmSettingCategory.values()) {
            if (category.hasProfiles()) {
                final TreeMap<String, Object> profiles = new TreeMap<>();
                for (final String profileID : this.profilesForSetting(category.getProfileSetting())) {
                    final TreeMap<String, Object> profileObject = new TreeMap<>();
                    for (final PwmSetting profileSetting : category.getSettings()) {
                        if (!isDefaultValue(profileSetting, profileID)) {
                            final StoredValue value = readSetting(profileSetting, profileID);
                            profileObject.put(profileSetting.getKey(), value.toDebugJsonObject(null));
                        }
                    }
                    profiles.put(profileID, profileObject);
                }
                outputObject.put(category.getProfileSetting().getKey(), profiles);
            }
        }
        return outputObject;
    } finally {
        domModifyLock.readLock().unlock();
    }
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) TreeMap(java.util.TreeMap) StoredValue(password.pwm.config.StoredValue)

Example 3 with PwmSettingCategory

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

the class StoredConfigurationUtil method modifiedSettings.

public static List<StoredConfigReference> modifiedSettings(final StoredConfiguration storedConfiguration) {
    final List<StoredConfigReference> returnObj = new ArrayList<>();
    for (final PwmSetting setting : PwmSetting.values()) {
        if (setting.getSyntax() != PwmSettingSyntax.PROFILE && !setting.getCategory().hasProfiles()) {
            if (!storedConfiguration.isDefaultValue(setting, null)) {
                final StoredConfigReference storedConfigReference = new StoredConfigReferenceBean(StoredConfigReference.RecordType.SETTING, setting.getKey(), null);
                returnObj.add(storedConfigReference);
            }
        }
    }
    for (final PwmSettingCategory category : PwmSettingCategory.values()) {
        if (category.hasProfiles()) {
            for (final String profileID : profilesForSetting(category.getProfileSetting(), storedConfiguration)) {
                for (final PwmSetting setting : category.getSettings()) {
                    if (!storedConfiguration.isDefaultValue(setting, profileID)) {
                        final StoredConfigReference storedConfigReference = new StoredConfigReferenceBean(StoredConfigReference.RecordType.SETTING, setting.getKey(), profileID);
                        returnObj.add(storedConfigReference);
                    }
                }
            }
        }
    }
    return returnObj;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList)

Example 4 with PwmSettingCategory

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

the class ConfigEditorServlet method generateSettingData.

public static Map<String, Object> generateSettingData(final PwmApplication pwmApplication, final StoredConfigurationImpl storedConfiguration, final SessionLabel sessionLabel, final Locale locale) throws PwmUnrecoverableException {
    final LinkedHashMap<String, Object> returnMap = new LinkedHashMap<>();
    final MacroMachine macroMachine = MacroMachine.forNonUserSpecific(pwmApplication, sessionLabel);
    final PwmSettingTemplateSet template = storedConfiguration.getTemplateSet();
    {
        final LinkedHashMap<String, Object> settingMap = new LinkedHashMap<>();
        for (final PwmSetting setting : PwmSetting.values()) {
            settingMap.put(setting.getKey(), SettingInfo.forSetting(setting, template, macroMachine, locale));
        }
        returnMap.put("settings", settingMap);
    }
    {
        final LinkedHashMap<String, Object> categoryMap = new LinkedHashMap<>();
        for (final PwmSettingCategory category : PwmSettingCategory.values()) {
            categoryMap.put(category.getKey(), CategoryInfo.forCategory(category, macroMachine, locale));
        }
        returnMap.put("categories", categoryMap);
    }
    {
        final LinkedHashMap<String, Object> labelMap = new LinkedHashMap<>();
        for (final PwmLocaleBundle localeBundle : PwmLocaleBundle.values()) {
            final LocaleInfo localeInfo = new LocaleInfo();
            localeInfo.description = localeBundle.getTheClass().getSimpleName();
            localeInfo.key = localeBundle.toString();
            localeInfo.adminOnly = localeBundle.isAdminOnly();
            labelMap.put(localeBundle.getTheClass().getSimpleName(), localeInfo);
        }
        returnMap.put("locales", labelMap);
    }
    {
        final LinkedHashMap<String, Object> varMap = new LinkedHashMap<>();
        varMap.put("ldapProfileIds", storedConfiguration.readSetting(PwmSetting.LDAP_PROFILE_LIST).toNativeObject());
        varMap.put("currentTemplate", storedConfiguration.getTemplateSet());
        varMap.put("configurationNotes", storedConfiguration.readConfigProperty(ConfigurationProperty.NOTES));
        returnMap.put("var", varMap);
    }
    return Collections.unmodifiableMap(returnMap);
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) PwmSettingTemplateSet(password.pwm.config.PwmSettingTemplateSet) PwmLocaleBundle(password.pwm.i18n.PwmLocaleBundle) MacroMachine(password.pwm.util.macro.MacroMachine) LinkedHashMap(java.util.LinkedHashMap)

Example 5 with PwmSettingCategory

use of password.pwm.config.PwmSettingCategory 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)

Aggregations

PwmSettingCategory (password.pwm.config.PwmSettingCategory)8 PwmSetting (password.pwm.config.PwmSetting)7 ArrayList (java.util.ArrayList)5 StoredValue (password.pwm.config.StoredValue)4 LinkedHashMap (java.util.LinkedHashMap)2 Collection (java.util.Collection)1 TreeMap (java.util.TreeMap)1 PwmSettingTemplateSet (password.pwm.config.PwmSettingTemplateSet)1 StringArrayValue (password.pwm.config.value.StringArrayValue)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)1 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)1 MacroMachine (password.pwm.util.macro.MacroMachine)1