Search in sources :

Example 1 with CustomLinkConfiguration

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

the class CustomLinkValue method toDebugString.

public String toDebugString(final Locale locale) {
    if (values != null && !values.isEmpty()) {
        final StringBuilder sb = new StringBuilder();
        for (final CustomLinkConfiguration formRow : values) {
            sb.append("Link Name:").append(formRow.getName()).append("\n");
            sb.append(" Type:").append(formRow.getType());
            sb.append("\n");
            sb.append(" Description:").append(JsonUtil.serializeMap(formRow.getLabels())).append("\n");
            sb.append(" New Window:").append(formRow.isCustomLinkNewWindow()).append("\n");
            sb.append(" Url:").append(formRow.getCustomLinkUrl()).append("\n");
        }
        return sb.toString();
    } else {
        return "";
    }
}
Also used : CustomLinkConfiguration(password.pwm.config.CustomLinkConfiguration)

Example 2 with CustomLinkConfiguration

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

the class CustomLinkValue method toXmlValues.

public List<Element> toXmlValues(final String valueElementName, final PwmSecurityKey pwmSecurityKey) {
    final List<Element> returnList = new ArrayList<>();
    for (final CustomLinkConfiguration value : values) {
        final Element valueElement = new Element(valueElementName);
        valueElement.addContent(JsonUtil.serialize(value));
        returnList.add(valueElement);
    }
    return returnList;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) CustomLinkConfiguration(password.pwm.config.CustomLinkConfiguration)

Example 3 with CustomLinkConfiguration

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

the class CustomLinkValue method factory.

public static StoredValueFactory factory() {
    return new StoredValueFactory() {

        public CustomLinkValue fromJson(final String input) {
            if (input == null) {
                return new CustomLinkValue(Collections.emptyList());
            } else {
                List<CustomLinkConfiguration> srcList = JsonUtil.deserialize(input, new TypeToken<List<CustomLinkConfiguration>>() {
                });
                srcList = srcList == null ? Collections.emptyList() : srcList;
                while (srcList.contains(null)) {
                    srcList.remove(null);
                }
                return new CustomLinkValue(Collections.unmodifiableList(srcList));
            }
        }

        public CustomLinkValue fromXmlElement(final Element settingElement, final PwmSecurityKey key) throws PwmOperationalException {
            final List valueElements = settingElement.getChildren("value");
            final List<CustomLinkConfiguration> values = new ArrayList<>();
            for (final Object loopValue : valueElements) {
                final Element loopValueElement = (Element) loopValue;
                final String value = loopValueElement.getText();
                if (value != null && value.length() > 0 && loopValueElement.getAttribute("locale") == null) {
                    values.add(JsonUtil.deserialize(value, CustomLinkConfiguration.class));
                }
            }
            return new CustomLinkValue(values);
        }
    };
}
Also used : PwmSecurityKey(password.pwm.util.secure.PwmSecurityKey) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) CustomLinkConfiguration(password.pwm.config.CustomLinkConfiguration) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

CustomLinkConfiguration (password.pwm.config.CustomLinkConfiguration)3 ArrayList (java.util.ArrayList)2 Element (org.jdom2.Element)2 List (java.util.List)1 PwmSecurityKey (password.pwm.util.secure.PwmSecurityKey)1