Search in sources :

Example 1 with PwmSettingTemplate

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

the class ConfigEditorServlet method setOptions.

@ActionHandler(action = "setOption")
private ProcessStatus setOptions(final PwmRequest pwmRequest) throws IOException, PwmUnrecoverableException {
    final ConfigManagerBean configManagerBean = getBean(pwmRequest);
    {
        final String updateDescriptionTextCmd = pwmRequest.readParameterAsString("updateNotesText");
        if (updateDescriptionTextCmd != null && "true".equalsIgnoreCase(updateDescriptionTextCmd)) {
            try {
                final String bodyString = pwmRequest.readRequestBodyAsString();
                final String value = JsonUtil.deserialize(bodyString, String.class);
                configManagerBean.getStoredConfiguration().writeConfigProperty(ConfigurationProperty.NOTES, value);
                LOGGER.trace("updated notesText");
            } catch (Exception e) {
                LOGGER.error("error updating notesText: " + e.getMessage());
            }
        }
        {
            final String requestedTemplate = pwmRequest.readParameterAsString("template");
            if (requestedTemplate != null && requestedTemplate.length() > 0) {
                try {
                    final PwmSettingTemplate template = PwmSettingTemplate.valueOf(requestedTemplate);
                    configManagerBean.getStoredConfiguration().writeConfigProperty(ConfigurationProperty.LDAP_TEMPLATE, template.toString());
                    LOGGER.trace("setting template to: " + requestedTemplate);
                } catch (IllegalArgumentException e) {
                    configManagerBean.getStoredConfiguration().writeConfigProperty(ConfigurationProperty.LDAP_TEMPLATE, PwmSettingTemplate.DEFAULT.toString());
                    LOGGER.error("unknown template set request: " + requestedTemplate);
                }
            }
        }
    }
    return ProcessStatus.Halt;
}
Also used : ConfigManagerBean(password.pwm.http.bean.ConfigManagerBean) PwmSettingTemplate(password.pwm.config.PwmSettingTemplate) ServletException(javax.servlet.ServletException) PwmUnrecoverableException(password.pwm.error.PwmUnrecoverableException) PwmOperationalException(password.pwm.error.PwmOperationalException) ChaiUnavailableException(com.novell.ldapchai.exception.ChaiUnavailableException) PwmException(password.pwm.error.PwmException) IOException(java.io.IOException)

Example 2 with PwmSettingTemplate

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

Example 3 with PwmSettingTemplate

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

the class ConfigGuideForm method updateStoredConfigTemplateValue.

private static void updateStoredConfigTemplateValue(final Map<ConfigGuideFormField, String> formData, final StoredConfigurationImpl storedConfiguration, final PwmSetting pwmSetting, final ConfigGuideFormField formField, final PwmSettingTemplate.Type type) throws PwmUnrecoverableException {
    final String formValue = formData.get(formField);
    if (!StringUtil.isEmpty(formValue)) {
        final PwmSettingTemplate template = PwmSettingTemplate.templateForString(formValue, type);
        storedConfiguration.writeSetting(pwmSetting, null, new StringValue(template.toString()), null);
    }
}
Also used : PwmSettingTemplate(password.pwm.config.PwmSettingTemplate) StringValue(password.pwm.config.value.StringValue)

Aggregations

PwmSettingTemplate (password.pwm.config.PwmSettingTemplate)3 ChaiUnavailableException (com.novell.ldapchai.exception.ChaiUnavailableException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 ServletException (javax.servlet.ServletException)1 LDAPPermissionInfo (password.pwm.config.LDAPPermissionInfo)1 PwmSettingTemplateSet (password.pwm.config.PwmSettingTemplateSet)1 LdapProfile (password.pwm.config.profile.LdapProfile)1 StringValue (password.pwm.config.value.StringValue)1 PwmException (password.pwm.error.PwmException)1 PwmOperationalException (password.pwm.error.PwmOperationalException)1 PwmUnrecoverableException (password.pwm.error.PwmUnrecoverableException)1 ConfigManagerBean (password.pwm.http.bean.ConfigManagerBean)1