Enum Class AuthenticatedUserImpersonator

java.lang.Object
java.lang.Enum<AuthenticatedUserImpersonator>
com.atlassian.confluence.user.AuthenticatedUserImpersonator
All Implemented Interfaces:
Serializable, Comparable<AuthenticatedUserImpersonator>, Constable

public enum AuthenticatedUserImpersonator extends Enum<AuthenticatedUserImpersonator>
Impersonates an authenticated user during the execution of the given callback.

The authenticated user is stored on a thread local variable for the HTTP workers. This variable is, amongst other things, used to

invalid reference
determine the locale
for
invalid reference
i18n
.

This behaviour makes sense for most cases. But if you want to e.g. render a Soy template for an email (on an HTTP worker) ahead of being sent, you'd want to set the locale to the recipient's locale. If the recipient is unknown to Confluence, you'd want the lookup to default to the site's locale instead of the sender's locale.

Since:
5.1.5
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static AuthenticatedUserImpersonator[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static AuthenticatedUserImpersonator valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • asAnonymousUser

      public <T> T asAnonymousUser(Callable<T> callback)
    • asUser

      public <T> T asUser(Callable<T> callback, @Nullable ConfluenceUser user)
      Impersonates the given user during the execution of the given callback.
      Parameters:
      callback - the callback to be executed
      user - the user to be impersonated
      Returns:
      the return value of the given callback
    • asUser

      @Deprecated(forRemoval=true) public <T> T asUser(Callable<T> callback, @Nullable com.atlassian.user.User user)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Impersonates the given user during the execution of the given callback.
      Parameters:
      callback - the callback to be executed
      user - the user to be impersonated
      Returns:
      the return value of the given callback
    • wrapCallback

      protected <T> Callable<T> wrapCallback(Callable<T> callback)