Search in sources :

Example 1 with PwmSetting

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

the class LDAPStatusChecker method checkLdapDNSyntaxValues.

private static List<HealthRecord> checkLdapDNSyntaxValues(final PwmApplication pwmApplication) {
    final List<HealthRecord> returnList = new ArrayList<>();
    final Configuration config = pwmApplication.getConfig();
    try {
        for (final PwmSetting pwmSetting : PwmSetting.values()) {
            if (!pwmSetting.isHidden() && pwmSetting.getCategory() == PwmSettingCategory.LDAP_PROFILE && pwmSetting.getFlags().contains(PwmSettingFlag.ldapDNsyntax)) {
                for (final String profile : config.getLdapProfiles().keySet()) {
                    if (pwmSetting.getSyntax() == PwmSettingSyntax.STRING) {
                        final String value = config.getLdapProfiles().get(profile).readSettingAsString(pwmSetting);
                        if (value != null && !value.isEmpty()) {
                            final String errorMsg = validateDN(pwmApplication, value, profile);
                            if (errorMsg != null) {
                                returnList.add(HealthRecord.forMessage(HealthMessage.Config_DNValueValidity, pwmSetting.toMenuLocationDebug(profile, PwmConstants.DEFAULT_LOCALE), errorMsg));
                            }
                        }
                    } else if (pwmSetting.getSyntax() == PwmSettingSyntax.STRING_ARRAY) {
                        final List<String> values = config.getLdapProfiles().get(profile).readSettingAsStringArray(pwmSetting);
                        if (values != null) {
                            for (final String value : values) {
                                final String errorMsg = validateDN(pwmApplication, value, profile);
                                if (errorMsg != null) {
                                    returnList.add(HealthRecord.forMessage(HealthMessage.Config_DNValueValidity, pwmSetting.toMenuLocationDebug(profile, PwmConstants.DEFAULT_LOCALE), errorMsg));
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (PwmUnrecoverableException e) {
        LOGGER.warn("error while checking DN ldap syntax values: " + e.getMessage());
    }
    return returnList;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) Configuration(password.pwm.config.Configuration) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException)

Example 2 with PwmSetting

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

the class LDAPStatusChecker method checkUserPermissionValues.

private static List<HealthRecord> checkUserPermissionValues(final PwmApplication pwmApplication) {
    final List<HealthRecord> returnList = new ArrayList<>();
    final Configuration config = pwmApplication.getConfig();
    for (final PwmSetting pwmSetting : PwmSetting.values()) {
        if (!pwmSetting.isHidden() && pwmSetting.getSyntax() == PwmSettingSyntax.USER_PERMISSION) {
            if (!pwmSetting.getCategory().hasProfiles()) {
                final List<UserPermission> userPermissions = config.readSettingAsUserPermission(pwmSetting);
                for (final UserPermission userPermission : userPermissions) {
                    try {
                        returnList.addAll(checkUserPermission(pwmApplication, userPermission, pwmSetting));
                    } catch (PwmUnrecoverableException e) {
                        LOGGER.error("error checking configured permission settings:" + e.getMessage());
                    }
                }
            }
        }
    }
    return returnList;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) Configuration(password.pwm.config.Configuration) ChaiConfiguration(com.novell.ldapchai.provider.ChaiConfiguration) ArrayList(java.util.ArrayList) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) UserPermission(password.pwm.config.value.data.UserPermission)

Example 3 with PwmSetting

use of password.pwm.config.PwmSetting 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 4 with PwmSetting

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

the class StoredConfigurationImpl method matchSetting.

private boolean matchSetting(final ConfigRecordID configRecordID, final String searchTerm, final Locale locale) {
    final PwmSetting pwmSetting = (PwmSetting) configRecordID.getRecordID();
    final StoredValue value = readSetting(pwmSetting, configRecordID.getProfileID());
    return StringUtil.whitespaceSplit(searchTerm).parallelStream().allMatch(s -> matchSetting(pwmSetting, value, s, locale));
}
Also used : PwmSetting(password.pwm.config.PwmSetting) StoredValue(password.pwm.config.StoredValue)

Example 5 with PwmSetting

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

Aggregations

PwmSetting (password.pwm.config.PwmSetting)32 ArrayList (java.util.ArrayList)15 StoredValue (password.pwm.config.StoredValue)12 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)11 LinkedHashMap (java.util.LinkedHashMap)9 StoredConfigurationImpl (password.pwm.config.stored.StoredConfigurationImpl)9 PwmSettingCategory (password.pwm.config.PwmSettingCategory)8 PwmException (password.pwm.error.PwmException)8 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)7 IOException (java.io.IOException)6 TreeMap (java.util.TreeMap)6 PwmOperationalException (password.pwm.error.PwmOperationalException)5 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)5 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)4 List (java.util.List)4 StringTokenizer (java.util.StringTokenizer)4 ServletException (javax.servlet.ServletException)4 UserIdentity (password.pwm.bean.UserIdentity)4 Configuration (password.pwm.config.Configuration)4 ErrorInformation (password.pwm.error.ErrorInformation)4