Search in sources :

Example 11 with XSString

use of org.opensaml.core.xml.schema.XSString in project cas by apereo.

the class SamlMetadataUIInfo method getStringValues.

/**
 * Gets string values from the list of mdui objects.
 *
 * @param items the items
 * @return the string values
 */
private static Collection<String> getStringValues(final List<?> items) {
    val list = new ArrayList<String>(items.size());
    items.forEach(d -> {
        if (d instanceof XSURI) {
            list.add(((XSURI) d).getURI());
        } else if (d instanceof XSString) {
            list.add(((XSString) d).getValue());
        }
    });
    return list;
}
Also used : lombok.val(lombok.val) ArrayList(java.util.ArrayList) XSString(org.opensaml.core.xml.schema.XSString) XSURI(org.opensaml.core.xml.schema.XSURI)

Example 12 with XSString

use of org.opensaml.core.xml.schema.XSString in project cas by apereo.

the class SamlMetadataUIInfo method getLocalizedValues.

/**
 * Gets localized values.
 *
 * @param locale browser preferred language
 * @param items  the items
 * @return the string value
 */
private static String getLocalizedValues(final String locale, final List<?> items) {
    val foundLocale = findLocale(StringUtils.defaultString(locale, "en"), items);
    if (foundLocale.isPresent()) {
        return foundLocale.get();
    }
    if (!items.isEmpty()) {
        val item = items.get(0);
        var value = StringUtils.EMPTY;
        if (item instanceof LocalizedName) {
            value = ((LocalizedName) item).getValue();
        }
        if (item instanceof LocalizedURI) {
            value = ((LocalizedURI) item).getURI();
        }
        if (item instanceof XSString) {
            value = ((XSString) item).getValue();
        }
        LOGGER.trace("Loading first available locale [{}]", value);
        return value;
    }
    return null;
}
Also used : lombok.val(lombok.val) LocalizedURI(org.opensaml.saml.saml2.metadata.LocalizedURI) LocalizedName(org.opensaml.saml.saml2.metadata.LocalizedName) XSString(org.opensaml.core.xml.schema.XSString)

Example 13 with XSString

use of org.opensaml.core.xml.schema.XSString in project spring-security by spring-projects.

the class TestOpenSamlObjects method attribute.

static Attribute attribute(String name, String value) {
    Attribute attribute = build(Attribute.DEFAULT_ELEMENT_NAME);
    attribute.setName(name);
    XSString xsValue = new XSStringBuilder().buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
    xsValue.setValue(value);
    attribute.getAttributeValues().add(xsValue);
    return attribute;
}
Also used : Attribute(org.opensaml.saml.saml2.core.Attribute) EncryptedAttribute(org.opensaml.saml.saml2.core.EncryptedAttribute) XSString(org.opensaml.core.xml.schema.XSString) XSStringBuilder(org.opensaml.core.xml.schema.impl.XSStringBuilder)

Aggregations

XSString (org.opensaml.core.xml.schema.XSString)13 Attribute (org.opensaml.saml.saml2.core.Attribute)5 lombok.val (lombok.val)4 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 XSURI (org.opensaml.core.xml.schema.XSURI)3 GuestPrincipal (ddf.security.principal.GuestPrincipal)2 Principal (java.security.Principal)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 KerberosPrincipal (javax.security.auth.kerberos.KerberosPrincipal)2 X500Principal (javax.security.auth.x500.X500Principal)2 StringUtils (org.apache.commons.lang3.StringUtils)2 XMLObject (org.opensaml.core.xml.XMLObject)2 EncryptedAttribute (org.opensaml.saml.saml2.core.EncryptedAttribute)2 Generators (com.fasterxml.uuid.Generators)1 RandomBasedGenerator (com.fasterxml.uuid.impl.RandomBasedGenerator)1