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();
}
}
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();
}
}
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;
}
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);
}
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;
}
Aggregations