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