Class UserUtils

java.lang.Object
com.atlassian.jira.user.UserUtils

public class UserUtils extends Object
A static helper class for User operations.

Normally you should use dependency injection to get hold of a UserManager or a UserUtil instance.

Since:
v4.4
  • Constructor Details

    • UserUtils

      public UserUtils()
  • Method Details

    • userExists

      public static boolean userExists(String username)
      Checks if a user with given username exists. Returns true if such user exists, false otherwise.
      Parameters:
      username - username to look up
      Returns:
      true if user found, false otherwise
    • getUser

      public static ApplicationUser getUser(String username)
      Retrieves and returns the user by given username.
      Parameters:
      username - the username to get
      Returns:
      user or null if not found
    • getUserEvenWhenUnknown

      public static ApplicationUser getUserEvenWhenUnknown(String username)
      Returns a User based on user name.

      If a null username is passed, then a null User object is returned, but it is guaranteed to return a non-null User in all other cases.
      If the username is not null, but the User is not found then a proxy unknown immutable User object is returned.

      Parameters:
      username - the user name of the user
      Returns:
      the User object, or proxy unknown immutable User object (null iff the username is null).
      Since:
      v4.4
    • getUserByEmail

      public static ApplicationUser getUserByEmail(String emailAddress)
      Return the first user found that matches the given email address (or null if not found).

      The email address is matched case insensitive.

      Parameters:
      emailAddress - user email address
      Returns:
      The first user that matches the email address or null if not found or the given email address is null.
    • getUsersByEmail

      public static List<ApplicationUser> getUsersByEmail(String email)
      Finds the users by the given e-mail address. E-mail address look-up is done case insensitively. Leading or trailing spaces in the given e-mail address are trimmed before look up.
      Parameters:
      email - e-mail address
      Returns:
      always returns a list of users found (even if empty)
    • getUserManager

      public static UserManager getUserManager()