use of password.pwm.config.PwmSetting in project pwm by pwm-project.
the class StoredConfigurationUtil method toJsonDebugObject.
public static Serializable toJsonDebugObject(final StoredConfiguration storedConfiguration) {
final TreeMap<String, Object> outputObject = new TreeMap<>();
for (final StoredConfigReference storedConfigReference : modifiedSettings(storedConfiguration)) {
final PwmSetting setting = PwmSetting.forKey(storedConfigReference.getRecordID());
if (setting != null) {
final StoredValue value = storedConfiguration.readSetting(setting, storedConfigReference.getProfileID());
outputObject.put(setting.getKey(), value.toDebugJsonObject(null));
}
}
return outputObject;
}
use of password.pwm.config.PwmSetting 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.PwmSetting in project pwm by pwm-project.
the class ConfigurationChecker method passwordStrengthChecks.
private List<HealthRecord> passwordStrengthChecks(final Configuration config, final Locale locale) {
final List<HealthRecord> records = new ArrayList<>();
for (final PwmSetting setting : PwmSetting.values()) {
if (setting.getSyntax() == PwmSettingSyntax.PASSWORD) {
if (!setting.getCategory().hasProfiles()) {
if (!config.isDefaultValue(setting)) {
try {
final PasswordData passwordValue = config.readSettingAsPassword(setting);
final int strength = PasswordUtility.judgePasswordStrength(config, passwordValue.getStringValue());
if (strength < 50) {
records.add(HealthRecord.forMessage(HealthMessage.Config_WeakPassword, setting.toMenuLocationDebug(null, locale), String.valueOf(strength)));
}
} catch (Exception e) {
LOGGER.error(SessionLabel.HEALTH_SESSION_LABEL, "error while inspecting setting " + setting.toMenuLocationDebug(null, locale) + ", error: " + e.getMessage());
}
}
}
}
}
for (final LdapProfile profile : config.getLdapProfiles().values()) {
final PwmSetting setting = PwmSetting.LDAP_PROXY_USER_PASSWORD;
try {
final PasswordData passwordValue = profile.readSettingAsPassword(setting);
final int strength = PasswordUtility.judgePasswordStrength(config, passwordValue == null ? null : passwordValue.getStringValue());
if (strength < 50) {
records.add(HealthRecord.forMessage(HealthMessage.Config_WeakPassword, setting.toMenuLocationDebug(profile.getIdentifier(), locale), String.valueOf(strength)));
}
} catch (PwmException e) {
LOGGER.error(SessionLabel.HEALTH_SESSION_LABEL, "error while inspecting setting " + setting.toMenuLocationDebug(profile.getIdentifier(), locale) + ", error: " + e.getMessage());
}
}
return records;
}
use of password.pwm.config.PwmSetting in project pwm by pwm-project.
the class SessionManager method checkPermission.
public boolean checkPermission(final PwmApplication pwmApplication, final Permission permission) throws PwmUnrecoverableException {
final boolean devDebugMode = pwmApplication.getConfig().isDevDebugMode();
if (devDebugMode) {
LOGGER.trace(pwmSession.getLabel(), String.format("entering checkPermission(%s, %s, %s)", permission, pwmSession, pwmApplication));
}
if (!pwmSession.isAuthenticated()) {
if (devDebugMode) {
LOGGER.trace(pwmSession.getLabel(), "user is not authenticated, returning false for permission check");
}
return false;
}
Permission.PermissionStatus status = pwmSession.getUserSessionDataCacheBean().getPermission(permission);
if (status == Permission.PermissionStatus.UNCHECKED) {
if (devDebugMode) {
LOGGER.debug(pwmSession.getLabel(), String.format("checking permission %s for user %s", permission.toString(), pwmSession.getUserInfo().getUserIdentity().toDelimitedKey()));
}
final PwmSetting setting = permission.getPwmSetting();
final List<UserPermission> userPermission = pwmApplication.getConfig().readSettingAsUserPermission(setting);
final boolean result = LdapPermissionTester.testUserPermissions(pwmApplication, pwmSession.getLabel(), pwmSession.getUserInfo().getUserIdentity(), userPermission);
status = result ? Permission.PermissionStatus.GRANTED : Permission.PermissionStatus.DENIED;
pwmSession.getUserSessionDataCacheBean().setPermission(permission, status);
LOGGER.debug(pwmSession.getLabel(), String.format("permission %s for user %s is %s", permission.toString(), pwmSession.getUserInfo().getUserIdentity().toDelimitedKey(), status.toString()));
}
return status == Permission.PermissionStatus.GRANTED;
}
use of password.pwm.config.PwmSetting in project pwm by pwm-project.
the class FormUtility method identifyFormItemsNeedingPotentialTokenValidation.
public static Map<String, TokenDestinationItem.Type> identifyFormItemsNeedingPotentialTokenValidation(final LdapProfile ldapProfile, final Collection<FormConfiguration> formConfigurations) {
final Map<PwmSetting, TokenDestinationItem.Type> settingTypeMap = TokenDestinationItem.getSettingToDestTypeMap();
final Map<String, TokenDestinationItem.Type> returnObj = new LinkedHashMap<>();
for (final Map.Entry<PwmSetting, TokenDestinationItem.Type> entry : settingTypeMap.entrySet()) {
final String attrName = ldapProfile.readSettingAsString(entry.getKey());
if (!StringUtil.isEmpty(attrName)) {
for (final FormConfiguration formConfiguration : formConfigurations) {
if (attrName.equalsIgnoreCase(formConfiguration.getName())) {
returnObj.put(attrName, entry.getValue());
}
}
}
}
return returnObj;
}
Aggregations