Search in sources :

Example 1 with LocalizedURI

use of org.opensaml.saml.saml2.metadata.LocalizedURI 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)

Aggregations

lombok.val (lombok.val)1 XSString (org.opensaml.core.xml.schema.XSString)1 LocalizedName (org.opensaml.saml.saml2.metadata.LocalizedName)1 LocalizedURI (org.opensaml.saml.saml2.metadata.LocalizedURI)1