Class AttributeUtils

java.lang.Object
se.swedenconnect.opensaml.saml2.attribute.AttributeUtils

public class AttributeUtils extends Object
Helper methods for accessing attribute values. See also AttributeBuilder.
Author:
Martin Lindström (martin@idsec.se)
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.opensaml.saml.saml2.core.Attribute
    getAttribute(String name, List<org.opensaml.saml.saml2.core.Attribute> attributes)
    Returns an attribute with a given name from an attribute list.
    static String
    getAttributeStringValue(org.opensaml.saml.saml2.core.Attribute attribute)
    Given a single-valued string attribute, this method returns its string value.
    static List<String>
    getAttributeStringValues(org.opensaml.saml.saml2.core.Attribute attribute)
    Given an attribute holding string values this method will return a list of these values.
    static <T extends org.opensaml.core.xml.XMLObject>
    T
    getAttributeValue(org.opensaml.saml.saml2.core.Attribute attribute, Class<T> type)
    Given a single-valued attribute, this method returns its value (of the given type).
    static <T extends org.opensaml.core.xml.XMLObject>
    List<T>
    getAttributeValues(org.opensaml.saml.saml2.core.Attribute attribute, Class<T> type)
    Returns the attribute values of the given type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getAttributeStringValues

      public static List<String> getAttributeStringValues(org.opensaml.saml.saml2.core.Attribute attribute)
      Given an attribute holding string values this method will return a list of these values.
      Parameters:
      attribute - the attribute
      Returns:
      a (possibly empty) list of string values
    • getAttributeStringValue

      public static String getAttributeStringValue(org.opensaml.saml.saml2.core.Attribute attribute)
      Given a single-valued string attribute, this method returns its string value.
      Parameters:
      attribute - the attribute
      Returns:
      the value, or null if no value is stored
    • getAttributeValues

      public static <T extends org.opensaml.core.xml.XMLObject> List<T> getAttributeValues(org.opensaml.saml.saml2.core.Attribute attribute, Class<T> type)
      Returns the attribute values of the given type.
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      type - the type to match
      Returns:
      a (possibly empty) list of values.
    • getAttributeValue

      public static <T extends org.opensaml.core.xml.XMLObject> T getAttributeValue(org.opensaml.saml.saml2.core.Attribute attribute, Class<T> type)
      Given a single-valued attribute, this method returns its value (of the given type).
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      type - the type to match
      Returns:
      the value, or null
    • getAttribute

      public static org.opensaml.saml.saml2.core.Attribute getAttribute(String name, List<org.opensaml.saml.saml2.core.Attribute> attributes)
      Returns an attribute with a given name from an attribute list.
      Parameters:
      name - the attribute name
      attributes - the list of attributes
      Returns:
      the attribute or null