use of password.pwm.config.value.data.RemoteWebServiceConfiguration in project pwm by pwm-project.
the class RemoteWebServiceValue method toXmlValues.
public List<Element> toXmlValues(final String valueElementName, final PwmSecurityKey pwmSecurityKey) {
final List<Element> returnList = new ArrayList<>();
for (final RemoteWebServiceConfiguration value : values) {
final Element valueElement = new Element(valueElementName);
final RemoteWebServiceConfiguration clonedValue = JsonUtil.cloneUsingJson(value, RemoteWebServiceConfiguration.class);
try {
clonedValue.setPassword(encryptPwValue(clonedValue.getPassword(), pwmSecurityKey));
} catch (PwmOperationalException e) {
LOGGER.warn("error decoding stored pw value: " + e.getMessage());
}
valueElement.addContent(JsonUtil.serialize(clonedValue));
returnList.add(valueElement);
}
return returnList;
}
use of password.pwm.config.value.data.RemoteWebServiceConfiguration in project pwm by pwm-project.
the class RemoteWebServiceValue method factory.
public static StoredValueFactory factory() {
return new StoredValueFactory() {
public RemoteWebServiceValue fromJson(final String input) {
if (input == null) {
return new RemoteWebServiceValue(Collections.emptyList());
} else {
List<RemoteWebServiceConfiguration> srcList = JsonUtil.deserialize(input, new TypeToken<List<RemoteWebServiceConfiguration>>() {
});
srcList = srcList == null ? Collections.emptyList() : srcList;
srcList.removeIf(Objects::isNull);
return new RemoteWebServiceValue(Collections.unmodifiableList(srcList));
}
}
public RemoteWebServiceValue fromXmlElement(final Element settingElement, final PwmSecurityKey pwmSecurityKey) throws PwmOperationalException {
final List valueElements = settingElement.getChildren("value");
final List<RemoteWebServiceConfiguration> values = new ArrayList<>();
for (final Object loopValue : valueElements) {
final Element loopValueElement = (Element) loopValue;
final String value = loopValueElement.getText();
if (value != null && value.length() > 0) {
final RemoteWebServiceConfiguration parsedValue = JsonUtil.deserialize(value, RemoteWebServiceConfiguration.class);
parsedValue.setPassword(decryptPwValue(parsedValue.getPassword(), pwmSecurityKey));
values.add(parsedValue);
}
}
return new RemoteWebServiceValue(values);
}
};
}
use of password.pwm.config.value.data.RemoteWebServiceConfiguration in project pwm by pwm-project.
the class RemoteWebServiceValue method toDebugJsonObject.
@Override
public Serializable toDebugJsonObject(final Locale locale) {
final ArrayList<RemoteWebServiceConfiguration> output = new ArrayList<>();
for (final RemoteWebServiceConfiguration remoteWebServiceConfiguration : values) {
final RemoteWebServiceConfiguration clone = JsonUtil.cloneUsingJson(remoteWebServiceConfiguration, RemoteWebServiceConfiguration.class);
if (!StringUtil.isEmpty(clone.getPassword())) {
clone.setPassword(PwmConstants.LOG_REMOVED_VALUE_REPLACEMENT);
}
output.add(clone);
}
return output;
}
use of password.pwm.config.value.data.RemoteWebServiceConfiguration in project pwm by pwm-project.
the class RemoteWebServiceValue method toInfoMap.
public List<Map<String, Object>> toInfoMap() {
final String originalJson = JsonUtil.serializeCollection(values);
final List<Map<String, Object>> tempObj = JsonUtil.deserialize(originalJson, new TypeToken<List<Map<String, Object>>>() {
});
for (final Map<String, Object> mapObj : tempObj) {
final RemoteWebServiceConfiguration serviceConfig = forName((String) mapObj.get("name"));
if (serviceConfig != null && serviceConfig.getCertificates() != null) {
final List<Map<String, String>> certificateInfos = new ArrayList<>();
for (final X509Certificate certificate : serviceConfig.getCertificates()) {
certificateInfos.add(X509Utils.makeDebugInfoMap(certificate, X509Utils.DebugInfoFlag.IncludeCertificateDetail));
}
mapObj.put("certificateInfos", certificateInfos);
}
}
return tempObj;
}
use of password.pwm.config.value.data.RemoteWebServiceConfiguration in project pwm by pwm-project.
the class RemoteWebServiceCertImportFunction method store.
void store(final List<X509Certificate> certs, final StoredConfigurationImpl storedConfiguration, final PwmSetting pwmSetting, final String profile, final String extraData, final UserIdentity userIdentity) throws PwmOperationalException, PwmUnrecoverableException {
final RemoteWebServiceValue actionValue = (RemoteWebServiceValue) storedConfiguration.readSetting(pwmSetting, profile);
final String actionName = actionNameFromExtraData(extraData);
final List<RemoteWebServiceConfiguration> newList = new ArrayList<>();
for (final RemoteWebServiceConfiguration loopConfiguration : actionValue.toNativeObject()) {
if (actionName.equals(loopConfiguration.getName())) {
final RemoteWebServiceConfiguration newConfig = JsonUtil.cloneUsingJson(loopConfiguration, RemoteWebServiceConfiguration.class);
newConfig.setCertificates(certs);
newList.add(newConfig);
} else {
newList.add(JsonUtil.cloneUsingJson(loopConfiguration, RemoteWebServiceConfiguration.class));
}
}
final RemoteWebServiceValue newActionValue = new RemoteWebServiceValue(newList);
storedConfiguration.writeSetting(pwmSetting, profile, newActionValue, userIdentity);
}
Aggregations