Search in sources :

Example 1 with RemoteWebServiceConfiguration

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;
}
Also used : RemoteWebServiceConfiguration(password.pwm.config.value.data.RemoteWebServiceConfiguration) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) PwmOperationalException(password.pwm.error.PwmOperationalException)

Example 2 with RemoteWebServiceConfiguration

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);
        }
    };
}
Also used : RemoteWebServiceConfiguration(password.pwm.config.value.data.RemoteWebServiceConfiguration) PwmSecurityKey(password.pwm.util.secure.PwmSecurityKey) Element(org.jdom2.Element) Objects(java.util.Objects) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with RemoteWebServiceConfiguration

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;
}
Also used : RemoteWebServiceConfiguration(password.pwm.config.value.data.RemoteWebServiceConfiguration) ArrayList(java.util.ArrayList)

Example 4 with RemoteWebServiceConfiguration

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;
}
Also used : RemoteWebServiceConfiguration(password.pwm.config.value.data.RemoteWebServiceConfiguration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) X509Certificate(java.security.cert.X509Certificate)

Example 5 with RemoteWebServiceConfiguration

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);
}
Also used : RemoteWebServiceConfiguration(password.pwm.config.value.data.RemoteWebServiceConfiguration) RemoteWebServiceValue(password.pwm.config.value.RemoteWebServiceValue) ArrayList(java.util.ArrayList)

Aggregations

RemoteWebServiceConfiguration (password.pwm.config.value.data.RemoteWebServiceConfiguration)6 ArrayList (java.util.ArrayList)5 List (java.util.List)2 Element (org.jdom2.Element)2 RemoteWebServiceValue (password.pwm.config.value.RemoteWebServiceValue)2 PwmOperationalException (password.pwm.error.PwmOperationalException)2 X509Certificate (java.security.cert.X509Certificate)1 Map (java.util.Map)1 Objects (java.util.Objects)1 ErrorInformation (password.pwm.error.ErrorInformation)1 PwmSecurityKey (password.pwm.util.secure.PwmSecurityKey)1