Search in sources :

Example 1 with PwmSettingTemplateSet

use of password.pwm.config.PwmSettingTemplateSet 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);
}
Also used : PwmSetting(password.pwm.config.PwmSetting) PwmSettingCategory(password.pwm.config.PwmSettingCategory) PwmSettingTemplateSet(password.pwm.config.PwmSettingTemplateSet) PwmLocaleBundle(password.pwm.i18n.PwmLocaleBundle) MacroMachine(password.pwm.util.macro.MacroMachine) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with PwmSettingTemplateSet

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

the class LDAPPermissionCalculator method figureStaticRecords.

private Collection<PermissionRecord> figureStaticRecords() {
    final Set<PwmSettingTemplate> edirInterestedTemplates = Collections.unmodifiableSet(new HashSet<>(Arrays.asList(PwmSettingTemplate.NOVL, PwmSettingTemplate.NOVL_IDM)));
    final List<PermissionRecord> permissionRecords = new ArrayList<>();
    final PwmSettingTemplateSet templateSet = storedConfiguration.getTemplateSet();
    {
        // edir specific attributes
        if (!Collections.disjoint(templateSet.getTemplates(), edirInterestedTemplates)) {
            final Map<String, LDAPPermissionInfo.Access> ldapAttributes = new LinkedHashMap<>();
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_LOCKED_BY_INTRUDER, LDAPPermissionInfo.Access.write);
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_LOGIN_INTRUDER_ATTEMPTS, LDAPPermissionInfo.Access.write);
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_LOGIN_INTRUDER_RESET_TIME, LDAPPermissionInfo.Access.write);
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_LOGIN_GRACE_LIMIT, LDAPPermissionInfo.Access.write);
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_LOGIN_GRACE_REMAINING, LDAPPermissionInfo.Access.write);
            ldapAttributes.put(ChaiConstant.ATTR_LDAP_PASSWORD_EXPIRE_TIME, LDAPPermissionInfo.Access.read);
            for (final Map.Entry<String, LDAPPermissionInfo.Access> entry : ldapAttributes.entrySet()) {
                final String ldapAttribute = entry.getKey();
                permissionRecords.add(new PermissionRecord(ldapAttribute, null, null, entry.getValue(), LDAPPermissionInfo.Actor.proxy));
            }
        }
    }
    if (configuration.getLdapProfiles() != null && !configuration.getLdapProfiles().isEmpty()) {
        for (final LdapProfile ldapProfile : configuration.getLdapProfiles().values()) {
            final List<String> autoAddObjectClasses = ldapProfile.readSettingAsStringArray(PwmSetting.AUTO_ADD_OBJECT_CLASSES);
            if (autoAddObjectClasses != null && !autoAddObjectClasses.isEmpty()) {
                permissionRecords.add(new PermissionRecord(ChaiConstant.ATTR_LDAP_OBJECTCLASS, PwmSetting.AUTO_ADD_OBJECT_CLASSES, ldapProfile.getIdentifier(), LDAPPermissionInfo.Access.write, LDAPPermissionInfo.Actor.proxy));
            }
        }
    }
    return permissionRecords;
}
Also used : PwmSettingTemplate(password.pwm.config.PwmSettingTemplate) ArrayList(java.util.ArrayList) LdapProfile(password.pwm.config.profile.LdapProfile) PwmSettingTemplateSet(password.pwm.config.PwmSettingTemplateSet) LDAPPermissionInfo(password.pwm.config.LDAPPermissionInfo) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 PwmSettingTemplateSet (password.pwm.config.PwmSettingTemplateSet)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 LDAPPermissionInfo (password.pwm.config.LDAPPermissionInfo)1 PwmSetting (password.pwm.config.PwmSetting)1 PwmSettingCategory (password.pwm.config.PwmSettingCategory)1 PwmSettingTemplate (password.pwm.config.PwmSettingTemplate)1 LdapProfile (password.pwm.config.profile.LdapProfile)1 PwmLocaleBundle (password.pwm.i18n.PwmLocaleBundle)1 MacroMachine (password.pwm.util.macro.MacroMachine)1