use of password.pwm.config.value.NamedSecretValue in project pwm by pwm-project.
the class StoredConfigurationImpl method writeSetting.
public void writeSetting(final PwmSetting setting, final String profileID, final StoredValue value, final UserIdentity userIdentity) throws PwmUnrecoverableException {
if (profileID == null && setting.getCategory().hasProfiles()) {
throw new IllegalArgumentException("reading of setting " + setting.getKey() + " requires a non-null profileID");
}
if (profileID != null && !setting.getCategory().hasProfiles()) {
throw new IllegalArgumentException("cannot specify profile for non-profile setting");
}
preModifyActions();
changeLog.updateChangeLog(setting, profileID, value);
domModifyLock.writeLock().lock();
try {
final Element settingElement = createOrGetSettingElement(document, setting, profileID);
settingElement.removeContent();
settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX, setting.getSyntax().toString());
settingElement.setAttribute(XML_ATTRIBUTE_SYNTAX_VERSION, Integer.toString(value.currentSyntaxVersion()));
if (setting_writeLabels) {
final Element labelElement = new Element("label");
labelElement.addContent(setting.getLabel(PwmConstants.DEFAULT_LOCALE));
settingElement.addContent(labelElement);
}
if (setting.getSyntax() == PwmSettingSyntax.PASSWORD) {
final List<Element> valueElements = ((PasswordValue) value).toXmlValues("value", getKey());
settingElement.addContent(new Comment("Note: This value is encrypted and can not be edited directly."));
settingElement.addContent(new Comment("Please use the Configuration Manager GUI to modify this value."));
settingElement.addContent(valueElements);
} else if (setting.getSyntax() == PwmSettingSyntax.PRIVATE_KEY) {
final List<Element> valueElements = ((PrivateKeyValue) value).toXmlValues("value", getKey());
settingElement.addContent(valueElements);
} else if (setting.getSyntax() == PwmSettingSyntax.NAMED_SECRET) {
final List<Element> valueElements = ((NamedSecretValue) value).toXmlValues("value", getKey());
settingElement.addContent(valueElements);
} else {
settingElement.addContent(value.toXmlValues("value", getKey()));
}
updateMetaData(settingElement, userIdentity);
} finally {
domModifyLock.writeLock().unlock();
}
}
Aggregations