io.vertx.ext.auth

## Interface User

- All Known Subinterfaces:
    AccessToken
  All Known Implementing Classes:
    AbstractUser

      public interface User

  Represents an authenticates User and contains operations to authorise the user.

  Please consult the documentation for a detailed explanation.

  Author:
    Tim Fox

- - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonObject` | `attributes()` Gets extra attributes of the user.
    `default Authorizations` | `authorizations()` Returns user's authorizations that have been previously loaded by the providers.
    `default User` | `clearCache()` Deprecated. This method will be removed. Use `Authorizations.clear()`
    `static User` | `create(JsonObject principal)`
    `static User` | `create(JsonObject principal, JsonObject attributes)`
    `default boolean` | `expired()` Flags this user object to be expired.
    `default boolean` | `expired(int leeway)` Flags this user object to be expired.
    `default Future<Boolean>` | `isAuthorized(Authorization authority)` Deprecated.
    `User` | `isAuthorized(Authorization authority, Handler<AsyncResult<Boolean>> resultHandler)` Deprecated.
    `default Future<Boolean>` | `isAuthorized(String authority)` Deprecated. Use typed alternative `isAuthorized(Authorization)`
    `default User` | `isAuthorized(String authority, Handler<AsyncResult<Boolean>> resultHandler)` Deprecated. Use typed alternative `isAuthorized(Authorization, Handler)`
    `JsonObject` | `principal()` Get the underlying principal for the User.
    `void` | `setAuthProvider(AuthProvider authProvider)` Deprecated.

- - ### Method Detail

    - #### create

          static User create(JsonObject principal)

    - #### create

          static User create(JsonObject principal,
                             JsonObject attributes)

    - #### attributes

          JsonObject attributes()

      Gets extra attributes of the user. Attributes contains any attributes related to the outcome of authenticating a user (e.g.: issued date, metadata, etc...)
      Returns:
        a json object with any relevant attribute.

    - #### expired

          default boolean expired()

      Flags this user object to be expired. A User is considered expired if it contains an expiration time and the current clock time is post the expiration date.
      Returns:
        `true` if expired

    - #### expired

          default boolean expired(int leeway)

      Flags this user object to be expired. Expiration takes 3 values in account:
      1. `exp` "expiration" timestamp in seconds.
      2. `iat` "issued at" in seconds.
      3. `nbf` "not before" in seconds.
      A User is considered expired if it contains any of the above and the current clock time does not agree with the parameter value. If the `principal()` do not contain a key then `attributes()` are checked.

      If all of the properties are not available the user will not expire.

      Implementations of this interface might relax this rule to account for a leeway to safeguard against clock drifting.

      Parameters:
        `leeway` - a greater than zero leeway value.
      Returns:
        `true` if expired

    - #### authorizations

          default Authorizations authorizations()

      Returns user's authorizations that have been previously loaded by the providers.
      Returns:
        authorizations holder for the user.

    - #### isAuthorized

          @Deprecated
          User isAuthorized(Authorization authority,
                                        Handler<AsyncResult<Boolean>> resultHandler)

      Deprecated.
      Is the user authorised to
      Parameters:
        `authority` - the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
        `resultHandler` - handler that will be called with an `AsyncResult` containing the value `true` if the they has the authority or `false` otherwise.
      Returns:
        the User to enable fluent use

    - #### isAuthorized

          @Deprecated
          default User isAuthorized(String authority,
                                                Handler<AsyncResult<Boolean>> resultHandler)

      Deprecated. Use typed alternative `isAuthorized(Authorization, Handler)`
      Is the user authorised to
      Parameters:
        `authority` - the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
        `resultHandler` - handler that will be called with an `AsyncResult` containing the value `true` if the they has the authority or `false` otherwise.
      Returns:
        the User to enable fluent use

    - #### isAuthorized

          @Deprecated
          default Future<Boolean> isAuthorized(Authorization authority)

      Deprecated.
      Is the user authorised to
      Parameters:
        `authority` - the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
      Returns:
        Future handler that will be called with an `AsyncResult` containing the value `true` if the they has the authority or `false` otherwise.
      See Also:
        `isAuthorized(Authorization, Handler)`

    - #### isAuthorized

          @Deprecated
          default Future<Boolean> isAuthorized(String authority)

      Deprecated. Use typed alternative `isAuthorized(Authorization)`
      Is the user authorised to
      Parameters:
        `authority` - the authority - what this really means is determined by the specific implementation. It might represent a permission to access a resource e.g. `printers:printer34` or it might represent authority to a role in a roles based model, e.g. `role:admin`.
      Returns:
        Future handler that will be called with an `AsyncResult` containing the value `true` if the they has the authority or `false` otherwise.
      See Also:
        `isAuthorized(String, Handler)`

    - #### clearCache

          @Deprecated
          default User clearCache()

      Deprecated. This method will be removed. Use `Authorizations.clear()`
      The User object will cache any authorities that it knows it has to avoid hitting the underlying auth provider each time. Use this method if you want to clear this cache.
      Returns:
        the User to enable fluent use

    - #### principal

          JsonObject principal()

      Get the underlying principal for the User. What this actually returns depends on the implementation. For a simple user/password based auth, it's likely to contain a JSON object with the following structure:

             {
               "username", "tim"
             }

      Returns:
        JSON representation of the Principal

    - #### setAuthProvider

          @Deprecated
          void setAuthProvider(AuthProvider authProvider)

      Deprecated.
      Set the auth provider for the User. This is typically used to reattach a detached User with an AuthProvider, e.g. after it has been deserialized.
      Parameters:
        `authProvider` - the AuthProvider - this must be the same type of AuthProvider that originally created the User

Copyright © 2020 Eclipse. All rights reserved.