Class ContextAttributes

Object
se.curity.identityserver.sdk.attribute.MapAttributeValue
se.curity.identityserver.sdk.attribute.ContextAttributes
All Implemented Interfaces:
Iterable<Attribute>, AttributeContainer<MapAttributeValue>, AttributeOrAttributeValue<AttributeValue>, AttributeValue

public final class ContextAttributes extends MapAttributeValue
  • Field Details

  • Method Details

    • empty

      public static ContextAttributes empty()
    • of

      public static ContextAttributes of(Iterable<Attribute> attributes)
      Creates a new ContextAttributes object that contains attributes about a context (i.e., environment), including the authentication time.

      If attributes does not contain the authentication time (i.e., an Attribute with a name of AUTH_TIME), it will be added as the current time (in seconds since Epoch). If the authentication time is contained in attributes, that value will not be modified.

      Parameters:
      attributes - the attributes that represent the context
      Returns:
      a new ContextAttributes object which will always contain an authentication time
      See Also:
    • of

      public static ContextAttributes of(Iterable<Attribute> attributes, boolean addAuthTimeIfNotProvided)
      Creates a new ContextAttributes object that contains attributes about a context (i.e., environment), optionally including the authentication time

      If attributes does not contain the authentication time (i.e., an Attribute with a name of AUTH_TIME), it will only be added if addAuthTimeIfNotProvided is true; otherwise, it will not be added to the resulting ContextAttributes. If it is added, the value will be the number of seconds since Epoch. If the authentication time is contained in attributes, that value will not be modified regardless of the value of addAuthTimeIfNotProvided.

      Parameters:
      attributes - the attributes that represent the context which may or may not contain the authentication time
      addAuthTimeIfNotProvided - whether or not the authentication time should be added if attributes does not include it
      Returns:
      the new ContextAttributes object
      See Also:
    • of

      public static ContextAttributes of(Map<?,?> map)
      Creates a new ContextAttributes object that contains attributes about a context (i.e., environment).

      If attributes does not contain the authentication time (i.e., an entry with a name of AUTH_TIME), it will be added as the current time (in seconds since Epoch). If the authentication time is contained in map, that value will not be modified.

      Parameters:
      map - the map of entries that will be represented with attributes in the new context
      Returns:
      a new ContextAttributes object
    • append

      public ContextAttributes append(Iterable<Attribute> attributes)
      Description copied from interface: AttributeContainer
      Appends the given attribute to a copy of this, returning the result.
      Specified by:
      append in interface AttributeContainer<MapAttributeValue>
      Overrides:
      append in class MapAttributeValue
      Parameters:
      attributes - to append
      Returns:
      copy of this with the provided attribute appended to it
    • with

      public ContextAttributes with(Attribute attribute)
      Description copied from interface: AttributeContainer
      Add the given attribute if not present, or replace the attribute if it already exists. Note that two attributes with the same name and different authorities are considered distinct.
      Specified by:
      with in interface AttributeContainer<MapAttributeValue>
      Overrides:
      with in class MapAttributeValue
      Parameters:
      attribute - attribute to add or to override
      Returns:
      a copy of this which contains the given Attribute
    • getAuthTime

      public long getAuthTime()
    • getAcr

      @Nullable public @Nullable String getAcr()
      Get the ACR-value of the context-attributes, or null if it doesn't exist.

      Type safe getter, as a non-String ACR-value is ignored.

      Returns:
      ACR of the ContextAttributes, or null if it doesn't exist
    • getExpiresAt

      public long getExpiresAt()
    • getScope

      public String getScope()
    • getScopes

      public Set<String> getScopes()
    • getSid

      @Nullable public @Nullable String getSid()
      Get optional value of the sid attribute.
      Returns:
      sid value, or null if ContextAttributes did not contain a `sid` attribute
      Since:
      5.1.0
    • getAuthenticationSessionAttribute

      @Nullable public @Nullable AuthenticationSessionAttribute getAuthenticationSessionAttribute()
      Get the authentication session data, including the profile ID and service provider ID as well as session ID.
      Returns:
      the authentication data if any; null otherwise.
      Since:
      5.1.0