Interface Authentication

  • All Superinterfaces:
    java.security.Principal, java.io.Serializable
    All Known Implementing Classes:
    ClientAuthentication, ServerAuthentication, X509Authentication

    public interface Authentication
    extends java.security.Principal, java.io.Serializable
    Represents the state of an authentication.
    Since:
    1.0
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      static Authentication build​(java.lang.String username)
      Builds an Authentication instance for the user.
      static Authentication build​(java.lang.String username, java.util.Collection<java.lang.String> roles)
      Builds an Authentication instance for the user.
      static Authentication build​(java.lang.String username, java.util.Collection<java.lang.String> roles, java.util.Map<java.lang.String,​java.lang.Object> attributes)
      Builds an Authentication instance for the user.
      static Authentication build​(java.lang.String username, java.util.Map<java.lang.String,​java.lang.Object> attributes)
      Builds an Authentication instance for the user.
      java.util.Map<java.lang.String,​java.lang.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.
      default java.util.Collection<java.lang.String> getRoles()  
      • Methods inherited from interface java.security.Principal

        equals, getName, hashCode, implies, toString
    • Method Detail

      • getAttributes

        @NonNull
        java.util.Map<java.lang.String,​java.lang.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

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

        @NonNull
        static Authentication build​(@NonNull
                                    java.lang.String username,
                                    @NonNull
                                    java.util.Collection<java.lang.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

        @NonNull
        static Authentication build​(@NonNull
                                    java.lang.String username,
                                    @NonNull
                                    java.util.Map<java.lang.String,​java.lang.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

        @NonNull
        static Authentication build​(@NonNull
                                    java.lang.String username,
                                    @Nullable
                                    java.util.Collection<java.lang.String> roles,
                                    @Nullable
                                    java.util.Map<java.lang.String,​java.lang.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