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 Details

    • getAttributeStringValues

      public static List<String> getAttributeStringValues(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(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 XMLObject> List<T> getAttributeValues(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 XMLObject> T getAttributeValue(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 Attribute getAttribute(String name, List<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