Interface Authentication

All Superinterfaces:
Principal, Serializable
All Known Implementing Classes:
AuthenticationJWTClaimsSetAdapter, ClientAuthentication, ServerAuthentication, X509Authentication

public interface Authentication extends Principal, Serializable
Represents the state of an authentication.
Since:
1.0
Author:
James Kleeh
  • Method Details

    • getAttributes

      @NonNull Map<String,Object> getAttributes()
      In order to correctly implement the Serializable specification, this map should be Map<String, Serializable>, however that would place a burden on those not requiring serialization, forcing their values to conform to that spec. This is left intentionally as Object in order to meet both use cases and those requiring serialization must ensure all values in the map implement Serializable.
      Returns:
      Any additional attributes in the authentication
    • getRoles

      default @NonNull Collection<String> getRoles()
      Returns:
      Any roles associated with the authentication
    • build

      static @NonNull Authentication build(@NonNull String username)
      Builds an Authentication instance for the user.
      Parameters:
      username - User's name
      Returns:
      An Authentication for the User
    • build

      static @NonNull Authentication build(@NonNull String username, @NonNull Collection<String> roles)
      Builds an Authentication instance for the user.
      Parameters:
      username - User's name
      roles - User's roles
      Returns:
      An Authentication for the User
    • build

      static @NonNull Authentication build(@NonNull String username, @NonNull Map<String,Object> attributes)
      Builds an Authentication instance for the user.
      Parameters:
      username - User's name
      attributes - User's attributes
      Returns:
      An Authentication for the User
    • build

      static @NonNull Authentication build(@NonNull String username, @Nullable Collection<String> roles, @Nullable Map<String,Object> attributes)
      Builds an Authentication instance for the user.
      Parameters:
      username - User's name
      roles - User's roles
      attributes - User's attributes
      Returns:
      An Authentication for the User
    • withAttributes

      default @NonNull Authentication withAttributes(@NonNull Map<String,Object> attributes, boolean append)
      Creates an authentication with the supplied attributes, optionally appending them to the current attributes.
      Parameters:
      attributes - User's attributes
      append - Whether to append the attributes to the current attributes
      Returns:
      An Authentication with the supplied attributes
      Since:
      5.1.0
    • withAttributes

      default @NonNull Authentication withAttributes(@NonNull Map<String,Object> attributes)
      Creates an authentication with the supplied attributes.
      Parameters:
      attributes - User's attributes
      Returns:
      An Authentication with the supplied attributes
      Since:
      5.1.0
    • withRoles

      default @NonNull Authentication withRoles(@NonNull Collection<String> roles, boolean append)
      Creates an authentication with the supplied roles, optionally appending them to the current roles.
      Parameters:
      roles - User's roles
      append - Whether to append the roles to the current roles
      Returns:
      An Authentication with the supplied roles
      Since:
      5.1.0
    • withRoles

      default @NonNull Authentication withRoles(@NonNull Collection<String> roles)
      Creates an authentication with the supplied roles.
      Parameters:
      roles - User's roles
      Returns:
      An Authentication with the supplied roles
      Since:
      5.1.0
    • withUsername

      default @NonNull Authentication withUsername(@NonNull String username)
      Creates an authentication with the supplied user name.
      Parameters:
      username - User's name
      Returns:
      An Authentication with the supplied user name
      Since:
      5.1.0