Interface Authentication

All Superinterfaces:
Serializable

public interface Authentication extends Serializable

The Authentication object represents a successful authentication request. It contains the principal that the authentication request was made for as well as the additional meta information such as the authenticated date and a map of attributes.

An Authentication object must be serializable to permit persistence and clustering.

Implementing classes must take care to ensure that the Map returned by getAttributes is serializable by using a Serializable map such as HashMap.

Since:
3.0.0
  • Method Details

    • getPrincipal

      Principal getPrincipal()
      Method to obtain the Principal.
      Returns:
      a Principal implementation
    • getAuthenticationDate

      ZonedDateTime getAuthenticationDate()
      Method to retrieve the timestamp of when this Authentication object was created.
      Returns:
      the date/time the authentication occurred.
    • getAttributes

      Map<String,List<Object>> getAttributes()
      Attributes of the authentication (not the Principal).
      Returns:
      the map of attributes.
    • addAttribute

      void addAttribute(String name, Object value)
      Add attribute to the authentication object and update the instance.
      Parameters:
      name - the name
      value - the value
    • containsAttribute

      boolean containsAttribute(String name)
      Contains attribute?
      Parameters:
      name - the name
      Returns:
      true
    • getCredentials

      List<Credential> getCredentials()
      Gets a list of metadata about the credentials supplied at authentication time.
      Returns:
      Non -null list of supplied credentials represented as metadata that should be considered safe for long-term storage (e.g. serializable and secure with respect to credential disclosure). The order of items in the returned list SHOULD be the same as the order in which the source credentials were presented and subsequently processed.
    • getWarnings

      List<MessageDescriptor> getWarnings()
      Get a list of authentication warnings that may be considered global and applicable to the entire authentication event.
      Returns:
      list of authentication attempts.
    • getSuccesses

      Gets a map describing successful authentications produced by AuthenticationHandler components.
      Returns:
      Map of handler names to successful authentication result produced by that handler.
    • getFailures

      Map<String,Throwable> getFailures()
      Gets a map describing failed authentications. By definition the failures here were not sufficient to prevent authentication.
      Returns:
      Map of authentication handler names to the authentication errors produced on attempted authentication.
    • updateAttributes

      void updateAttributes(Authentication authn)
      Updates the authentication object with what's passed. Does not override current keys if there are clashes
      Parameters:
      authn - the authn object
    • replaceAttributes

      void replaceAttributes(Authentication authn)
      Updates the authentication object with what's passed. Does override current keys if there are clashes. Clears the existing attributes and starts over.
      Parameters:
      authn - the authn object
    • isEqualTo

      boolean isEqualTo(Authentication auth2)
      Determines if two authentication objects are effectively the same attempt by comparing key aspects/fields of each attempt. This is not pure object equality; equality here may eventually determine if an SSO session should be renewed, or if the newer attempt is so very different from the current, that the current SSO session should be destroyed first.
      Parameters:
      auth2 - the second auth
      Returns:
      true/false
    • getSingleValuedAttribute

      <T> T getSingleValuedAttribute(String name, Class<T> expectedType)
      Gets attribute.
      Type Parameters:
      T - the type parameter
      Parameters:
      name - the name
      expectedType - the expected type
      Returns:
      the attribute
    • getSingleValuedAttribute

      default Object getSingleValuedAttribute(String name)
      Gets single valued attribute.
      Parameters:
      name - the name
      Returns:
      the single valued attribute