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