Class AttributeList

java.lang.Object
com.ibm.oauth.core.api.attributes.AttributeList

public class AttributeList extends Object
An ordered list of attributes used throughout the component to communicate full state and information in OAuth request and response. An attribute will be uniquely identified in the list by its name and type. Therefore an attribute list cannot have two attributes with the same name and type.
  • Constructor Details

    • AttributeList

      public AttributeList()
      One and only constructor which builds a new empty list of attributes.
  • Method Details

    • getAttributeValueByNameAndType

      public String getAttributeValueByNameAndType(String name, String type)
      Returns the first string value of an attribute from the attribute list identified by its name and type. Name and type checking are done as string comparisons. If the type of an attribute is not defined (null) then it will ONLY match if the requested type is also null. Similarly if the requested type is null, only attributes with a null (undefined) type will be matched.
      Parameters:
      name - name of attribute
      type - type of attribute
      Returns:
      first string value of a matching attribute from the attribute list or null if no matching attribute
    • getAttributeValueByName

      public String getAttributeValueByName(String name)
      Returns the first string value of an attribute from the attribute list identified by its name only. If more than one attribute in the attribute list has the same name (and different types), the first value of the first matching attribute will be returned.
      Parameters:
      name - name of attribute
      Returns:
      first string value of a matching attribute from the attribute list or null if no matching attribute
    • getAttributeValuesByNameAndType

      public String[] getAttributeValuesByNameAndType(String name, String type)
      Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name and type. Name and type checking are done as string comparisons. If the type of an attribute is not defined (null) then it will ONLY match if the requested type is also null. Similarly if the requested type is null, only attributes with a null (undefined) type will be matched.
      Parameters:
      name - name of attribute
      type - type of attribute
      Returns:
      string array of values of a matching attribute from the attribute list or null if no matching attribute
    • getAttributeValuesByName

      public String[] getAttributeValuesByName(String name)
      Returns the list of string values (as a string array) of an attribute from the attribute list identified by its name only. If more than one attribute in the attribute list has the same name (and different types), the values of the first matching attribute will be returned.
      Parameters:
      name - name of attribute
      Returns:
      string array of values of a matching attribute from the attribute list or null if no matching attribute
    • setAttribute

      public void setAttribute(String name, String type, String[] values)
      Set the values of an attribute in the attribute list identified by name and type. If an existing attribute with that name and type already appears in the attribute list its values will be replaced otherwise a new attribute will be appended to the list.
      Parameters:
      name - - name of attribute to update/add
      type - - type of attribute to update/add
      values - - array of string values of attribute to update/add
    • getAttributeByNameAndType

      public Attribute getAttributeByNameAndType(String name, String type)
      Returns a reference to an attribute within the attribute list identified by its name and type. If the attribute is modified, it will be modified in the list. If no attribute with that name and type exists in the list, returns null.
      Parameters:
      name - - name of attribute
      type - - type of attribute
      Returns:
      reference to the attribute in the list, or null if an attribute with that name and type cannot be located.
    • getAttributesByType

      public Attribute[] getAttributesByType(String type)
      Returns an array of attributes from the list that match a given type. Each attribute is a reference so any modifications to attributes returned in the array will be reflected in the attribute list.
      Parameters:
      type - type of attribute to match
      Returns:
      an array of attributes that match the given type, or null if there are no attributes with that type in the list.
    • getAllAttributes

      public List<Attribute> getAllAttributes()
      Gets all attributes in the attribute list.
      Returns:
      a list of attributes
    • toString

      public String toString()
      String representation of the attribute list useful for debug tracing.
      Overrides:
      toString in class Object