io.vertx.reactivex.ext.auth

## Class User

- java.lang.Object
- - io.vertx.reactivex.ext.auth.User

-     public class User
      extends Object

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

  Please consult the documentation for a detailed explanation.

  NOTE: This class has been automatically generated from the `original` non RX-ified interface using Vert.x codegen.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static io.vertx.lang.rx.TypeArg<User>` | `__TYPE_ARG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `User(Object delegate)`
    `User(User delegate)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonObject` | `attributes()` Gets extra attributes of the user.
    `Authorizations` | `authorizations()` Returns user's authorizations that have been previously loaded by the providers.
    `User` | `clearCache()` Deprecated.
    `boolean` | `containsKey(String key)` Checks if a value exists on the user object.
    `static User` | `create(JsonObject principal)` Factory for user instances that are free form.
    `static User` | `create(JsonObject principal, JsonObject attributes)` Factory for user instances that are free form.
    `boolean` | `equals(Object o)`
    `boolean` | `expired()` Flags this user object to be expired.
    `boolean` | `expired(int leeway)` Flags this user object to be expired.
    `static User` | `fromName(String username)` Factory for user instances that are single string.
    `static User` | `fromToken(String token)` Factory for user instances that are single string.
    `<T> T` | `get(String key)` Get a value from the user object.
    `User` | `getDelegate()`
    `int` | `hashCode()`
    `User` | `isAuthorized(Authorization authority)` Deprecated.
    `User` | `isAuthorized(Authorization authority, Handler<AsyncResult<Boolean>> resultHandler)` Deprecated.
    `User` | `isAuthorized(String authority)` Deprecated.
    `User` | `isAuthorized(String authority, Handler<AsyncResult<Boolean>> resultHandler)` Deprecated.
    `User` | `merge(User other)` Merge the principal and attributes of a second user into this object properties.
    `static User` | `newInstance(User arg)`
    `JsonObject` | `principal()` Get the underlying principal for the User.
    `Single<Boolean>` | `rxIsAuthorized(Authorization authority)` Deprecated.
    `Single<Boolean>` | `rxIsAuthorized(String authority)` Deprecated.
    `void` | `setAuthProvider(AuthProvider authProvider)` Deprecated.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### __TYPE_ARG

          public static final io.vertx.lang.rx.TypeArg<User> __TYPE_ARG

  - ### Constructor Detail

    - #### User

          public User(User delegate)

    - #### User

          public User(Object delegate)

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getDelegate

          public User getDelegate()

    - #### fromName

          public static User fromName(String username)

      Factory for user instances that are single string. The credentials will be added to the principal of this instance. As nothing can be said about the credentials no validation will be done. Will create a principal with a property `"username"` with the name as value.
      Parameters:
        `username` - the value for this user
      Returns:
        user instance

    - #### fromToken

          public static User fromToken(String token)

      Factory for user instances that are single string. The credentials will be added to the principal of this instance. As nothing can be said about the credentials no validation will be done. Will create a principal with a property `"access_token"` with the name as value.
      Parameters:
        `token` - the value for this user
      Returns:
        user instance

    - #### create

          public static User create(JsonObject principal)

      Factory for user instances that are free form. The credentials will be added to the principal of this instance. As nothing can be said about the credentials no validation will be done.
      Parameters:
        `principal` - the free form json principal
      Returns:
        user instance

    - #### create

          public static User create(JsonObject principal,
                                    JsonObject attributes)

      Factory for user instances that are free form. The credentials will be added to the principal of this instance. As nothing can be said about the credentials no validation will be done.
      Parameters:
        `principal` - the free form json principal
        `attributes` - the free form json attributes that further describe the principal
      Returns:
        user instance

    - #### attributes

          public 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

          public 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

          public 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 `attributes()` do not contain a key then `principal()` properties 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

    - #### get

          public <T> T get(String key)

      Get a value from the user object. This method will perform lookups on several places before returning a value.
      1. If there is a `rootClaim` the look up will happen in the `attributes[rootClaim]`
      2. If exists the value will be returned from the `attributes()`
      3. If exists the value will be returned from the `principal()`
      4. Otherwise it will be `null`
      Parameters:
        `key` - the key to look up
      Returns:
        the value or null if missing

    - #### containsKey

          public boolean containsKey(String key)

      Checks if a value exists on the user object. This method will perform lookups on several places before returning.
      1. If there is a `rootClaim` the look up will happen in the `attributes[rootClaim]`
      2. If exists the value will be returned from the `attributes()`
      3. If exists the value will be returned from the `principal()`
      4. Otherwise it will be `null`
      Parameters:
        `key` - the key to look up
      Returns:
        the value or null if missing

    - #### authorizations

          public Authorizations authorizations()

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

    - #### isAuthorized

          @Deprecated
          public 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
          public User 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:
        the User to enable fluent use

    - #### rxIsAuthorized

          @Deprecated
          public Single<Boolean> rxIsAuthorized(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:
        the User to enable fluent use

    - #### isAuthorized

          @Deprecated
          public User isAuthorized(String 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
          public User isAuthorized(String 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:
        the User to enable fluent use

    - #### rxIsAuthorized

          @Deprecated
          public Single<Boolean> rxIsAuthorized(String 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:
        the User to enable fluent use

    - #### clearCache

          @Deprecated
          public User clearCache()

      Deprecated.
      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

          public 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
          public 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

    - #### merge

          public User merge(User other)

      Merge the principal and attributes of a second user into this object properties. It is important to notice that the principal merges by replacing existing keys with the new values, while the attributes (as they represent decoded data) are accumulated at the root level. This means that given:

          userA = {
             attributes: {
               roles: [ 'read' ]
           }

           userB = {
             attributes: {
               roles: [ 'write' ]
             }
           }
           }

      When performing a merge of `userA` with `userB`, you will get:

          userA.merge(userB);
           // results in
           {
             attributes: {
               roles: [ 'read', 'write' ]
           }
           }

      Parameters:
        `other` - the other user to merge
      Returns:
        fluent self

    - #### newInstance

          public static User newInstance(User arg)

Copyright © 2022 Eclipse. All rights reserved.