Class UserContext

java.lang.Object
io.vertx.mutiny.ext.web.UserContext
All Implemented Interfaces:
MutinyDelegate

public class UserContext extends Object implements MutinyDelegate
A web user is extended user coupled to the context and is used to perform verifications and actions on behalf of the user. Actions can be:
  • refresh() - Require a re-authentication to confirm the user is present
  • impersonate() - Require a re-authentication to switch user identities
  • restore() - De-escalate a previous impersonate call
  • logout() - Logout the user from this application and redirect to a uri
  • clear() - Same as logout, without requirind a redirect

NOTE: This class has been automatically generated from the original non Mutiny-ified interface.

See Also:
  • UserContext
  • Field Details

  • Constructor Details

    • UserContext

      public UserContext(io.vertx.ext.web.UserContext delegate)
      Create a new instance of UserContext delegating to the given (non-null) instance of UserContext.
    • UserContext

      public UserContext(Object delegate)
  • Method Details

    • getDelegate

      public io.vertx.ext.web.UserContext getDelegate()
      Get the delegate instance.

      This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.

      Specified by:
      getDelegate in interface MutinyDelegate
      Returns:
      the delegate instance
    • refresh

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> refresh()
      Forces the current user to re-authenticate. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.refresh()
    • refreshAndAwait

      public void refreshAndAwait()
      Forces the current user to re-authenticate. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • UserContext.refresh()
    • refreshAndForget

      public UserContext refreshAndForget()
      Forces the current user to re-authenticate. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.refresh()
    • refresh

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> refresh(String redirectUri)
      Forces the current user to re-authenticate. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      redirectUri - the uri to redirect the user to after the re-authentication.
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.refresh(String)
    • refreshAndAwait

      public void refreshAndAwait(String redirectUri)
      Forces the current user to re-authenticate. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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:
      redirectUri - the uri to redirect the user to after the re-authentication.
      See Also:
      • UserContext.refresh(String)
    • refreshAndForget

      public UserContext refreshAndForget(String redirectUri)
      Forces the current user to re-authenticate. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      redirectUri - the uri to redirect the user to after the re-authentication.
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.refresh(String)
    • impersonate

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> impersonate()
      Impersonates a second identity. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.impersonate()
    • impersonateAndAwait

      public void impersonateAndAwait()
      Impersonates a second identity. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • UserContext.impersonate()
    • impersonateAndForget

      public UserContext impersonateAndForget()
      Impersonates a second identity. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.impersonate()
    • impersonate

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> impersonate(String redirectUri)
      Impersonates a second identity. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      redirectUri - the uri to redirect the user to after the authentication.
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.impersonate(String)
    • impersonateAndAwait

      public void impersonateAndAwait(String redirectUri)
      Impersonates a second identity. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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:
      redirectUri - the uri to redirect the user to after the authentication.
      See Also:
      • UserContext.impersonate(String)
    • impersonateAndForget

      public UserContext impersonateAndForget(String redirectUri)
      Impersonates a second identity. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      redirectUri - the uri to redirect the user to after the authentication.
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.impersonate(String)
    • restore

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> restore()
      Undo a previous call to a impersonation. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.restore()
    • restoreAndAwait

      public void restoreAndAwait()
      Undo a previous call to a impersonation. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • UserContext.restore()
    • restoreAndForget

      public UserContext restoreAndForget()
      Undo a previous call to a impersonation. The user will be redirected to the same origin where this call was made. It is important to notice that the redirect will only allow sources originating from a HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.restore()
    • restore

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> restore(String redirectUri)
      Undo a previous call to an impersonation. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      redirectUri - the uri to redirect the user to after the re-authentication.
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.restore(String)
    • restoreAndAwait

      public void restoreAndAwait(String redirectUri)
      Undo a previous call to an impersonation. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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:
      redirectUri - the uri to redirect the user to after the re-authentication.
      See Also:
      • UserContext.restore(String)
    • restoreAndForget

      public UserContext restoreAndForget(String redirectUri)
      Undo a previous call to an impersonation. The user will be redirected to the given uri. It is important to notice that the redirect will only allow targets using an HTTP GET request.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      redirectUri - the uri to redirect the user to after the re-authentication.
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.restore(String)
    • logout

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> logout(String redirectUri)
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to the given uri.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Parameters:
      redirectUri - the uri to redirect the user to after the logout.
      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.logout(String)
    • logoutAndAwait

      public void logoutAndAwait(String redirectUri)
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to the given uri.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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:
      redirectUri - the uri to redirect the user to after the logout.
      See Also:
      • UserContext.logout(String)
    • logoutAndForget

      public UserContext logoutAndForget(String redirectUri)
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to the given uri.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Parameters:
      redirectUri - the uri to redirect the user to after the logout.
      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.logout(String)
    • logout

      @CheckReturnValue public io.smallrye.mutiny.Uni<Void> logout()
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to /.

      Unlike the bare Vert.x variant, this method returns a Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.

      Don't forget to subscribe on it to trigger the operation.

      Returns:
      A Uni representing the asynchronous result of this operation.
      See Also:
      • UserContext.logout()
    • logoutAndAwait

      public void logoutAndAwait()
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to /.

      Unlike the bare Vert.x variant, this method returns a Void. This method awaits indefinitely 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).

      See Also:
      • UserContext.logout()
    • logoutAndForget

      public UserContext logoutAndForget()
      Logout can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Followed by a redirect to /.

      Unlike the bare Vert.x variant, this method ignores the Void result or any failure.

      Returns:
      The current instance to chain operations if needed.
      See Also:
      • UserContext.logout()
    • get

      public User get()
      Get the authenticated user (if any). This will usually be injected by an auth handler if authentication if successful.
      Returns:
      the user, or null if the current user is not authenticated.
    • authenticated

      public boolean authenticated()
    • loginHint

      public UserContext loginHint(String loginHint)
      When performing a web identity operation, hint if possible to the identity provider to use the given login.
      Parameters:
      loginHint - the desired login name, for example: admin.
      Returns:
      fluent self
    • clear

      public void clear()
      Clear can be called from any route handler which needs to terminate a login session. Invoking logout will remove the User and clear the Session (if any) in the current context. Unlike logout() no redirect will be performed.
    • newInstance

      public static UserContext newInstance(io.vertx.ext.web.UserContext delegate)
      Creates a new instance of the UserContext.
    • hashCode

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object