Class 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 Mutiny-ified interface using Vert.x codegen.

    • Field Detail

      • __TYPE_ARG

        public static final TypeArg<User> __TYPE_ARG
    • Constructor Detail

      • User

        public User​(io.vertx.ext.auth.User delegate)
      • User

        public User​(Object delegate)
    • Method Detail

      • getDelegate

        public io.vertx.ext.auth.User getDelegate()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • fromName

        public static User fromName​(String username)
        Parameters:
        username - the value for this user
        Returns:
        user instance
      • fromToken

        public static User fromToken​(String token)
        Parameters:
        token - the value for this user
        Returns:
        user instance
      • create

        public static User create​(io.vertx.core.json.JsonObject principal)
        Parameters:
        principal - the free form json principal
        Returns:
        user instance
      • create

        public static User create​(io.vertx.core.json.JsonObject principal,
                                  io.vertx.core.json.JsonObject attributes)
        Parameters:
        principal - the free form json principal
        attributes - the free form json attributes that further describe the principal
        Returns:
        user instance
      • subject

        public String subject()
        Returns:
        the subject for this user or null.
      • attributes

        public io.vertx.core.json.JsonObject attributes()
        Returns:
        a json object with any relevant attribute.
      • expired

        public boolean expired()
        Returns:
        true if expired
      • expired

        public boolean expired​(int leeway)
        Parameters:
        leeway - a greater than zero leeway value.
        Returns:
        true if expired
      • get

        public <T> T get​(String key)
        Parameters:
        key - the key to look up
        Returns:
        the value or null if missing
      • getOrDefault

        public <T> T getOrDefault​(String key,
                                  T defaultValue)
        Parameters:
        key - the key to look up
        defaultValue - default value to return if missing
        Returns:
        the value or null if missing
      • containsKey

        public boolean containsKey​(String key)
        Parameters:
        key - the key to look up
        Returns:
        the value or null if missing
      • authorizations

        public Authorizations authorizations()
        Returns:
        authorizations holder for the user.
      • isAuthorized

        @CheckReturnValue
        @Deprecated
        public io.smallrye.mutiny.Uni<Boolean> isAuthorized​(Authorization authority)
        Deprecated.
        Is the user authorised to

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        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 uni firing the result of the operation when completed, or a failure if the operation failed.
      • isAuthorizedAndAwait

        @Deprecated
        public Boolean isAuthorizedAndAwait​(Authorization authority)
        Deprecated.
        Blocking variant of isAuthorized(io.vertx.mutiny.ext.auth.authorization.Authorization).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        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 Boolean instance produced by the operation.
      • isAuthorized

        @CheckReturnValue
        @Deprecated
        public io.smallrye.mutiny.Uni<Boolean> isAuthorized​(String authority)
        Deprecated.
        Use typed alternative #isAuthorized(Authorization, Handler)
        Is the user authorised to

        Unlike the bare Vert.x variant, this method returns a Uni. Don't forget to subscribe on it to trigger the operation.

        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 uni firing the result of the operation when completed, or a failure if the operation failed.
      • isAuthorizedAndAwait

        @Deprecated
        public Boolean isAuthorizedAndAwait​(String authority)
        Deprecated.
        Use typed alternative #isAuthorized(Authorization, Handler)
        Blocking variant of isAuthorized(String).

        This method waits for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in a RuntimeException).

        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 Boolean instance produced by the operation.
      • isAuthorizedAndForget

        @Deprecated
        public User isAuthorizedAndForget​(String authority)
        Deprecated.
        Use typed alternative #isAuthorized(Authorization, Handler)
        Variant of isAuthorized(String) that ignores the result of the operation.

        This method subscribes on the result of isAuthorized(String), but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation from isAuthorized(String) but you don't need to compose it with other operations.

        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 instance of User to chain method calls.
      • clearCache

        @Deprecated
        public User clearCache()
        Deprecated.
        This method will be removed. Use Authorizations#clear()
        Returns:
        the User to enable fluent use
      • principal

        public io.vertx.core.json.JsonObject principal()
        Returns:
        JSON representation of the Principal
      • setAuthProvider

        @Deprecated
        public void setAuthProvider​(AuthProvider authProvider)
        Deprecated.
        Parameters:
        authProvider - the AuthProvider - this must be the same type of AuthProvider that originally created the User
      • merge

        public User merge​(User other)
        Parameters:
        other - the other user to merge
        Returns:
        fluent self
      • hasAmr

        public boolean hasAmr​(String value)
        Parameters:
        value -
        Returns:
        true if claim is present in the principal.
      • newInstance

        public static User newInstance​(io.vertx.ext.auth.User arg)