Search in sources :

Example 6 with PwmSetting

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;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) TreeMap(java.util.TreeMap) StoredValue(password.pwm.config.StoredValue)

Example 7 with PwmSetting

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;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) ArrayList(java.util.ArrayList)

Example 8 with PwmSetting

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;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmException(password.pwm.error.PwmException) PasswordData(password.pwm.util.PasswordData) ArrayList(java.util.ArrayList) LdapProfile(password.pwm.config.profile.LdapProfile) URISyntaxException(java.net.URISyntaxException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmException(password.pwm.error.PwmException)

Example 9 with PwmSetting

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;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) Permission(password.pwm.Permission) UserPermission(password.pwm.config.value.data.UserPermission) UserPermission(password.pwm.config.value.data.UserPermission)

Example 10 with PwmSetting

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;
}
Also used : PwmSetting(password.pwm.config.PwmSetting) FormConfiguration(password.pwm.config.value.data.FormConfiguration) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

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