Interface UserContext

All Superinterfaces:
RenderingContext
All Known Implementing Classes:
DefaultUserContext, JiraUserContext

public interface UserContext extends RenderingContext

Represents current user context.

User context is unique by means of the username and locale and those values can be used to cache evaluations of methods that take this class as parameter (along with other parameters).

Given an unauthenticated request, all methods of this interface except for RenderingContext.getRequest() will return null

Since:
v5.0
  • Method Summary

    Modifier and Type
    Method
    Description
    com.atlassian.sal.api.message.I18nResolver
    Get I18n resolver associated with the current user.
    Get locale associated with the current user.
    Name of the current user.
    boolean
    Check whether there is an authenticated user.

    Methods inherited from interface com.atlassian.administration.quicksearch.spi.RenderingContext

    getContextMap, getRequest
  • Method Details

    • getUsername

      @Nullable String getUsername()
      Name of the current user. If there is no authenticated user associated with the executing request, return null.
      Returns:
      current user, or null if no user authenticated
    • isAuthenticated

      boolean isAuthenticated()
      Check whether there is an authenticated user.
      Returns:
      true, if there is an authenticated user associated with the current request.
    • getLocale

      @Nonnull Locale getLocale()
      Get locale associated with the current user. Default locale if isAuthenticated() returns false.
      Returns:
      get user locale
    • getI18nResolver

      @Nonnull com.atlassian.sal.api.message.I18nResolver getI18nResolver()
      Get I18n resolver associated with the current user. Default language resolver if no user associated with this context (isAuthenticated() returns false).
      Returns:
      i18n resolver