All Implemented Interfaces:
Authorizable

public class User extends AbstractAuthorizable
Object which handles user actions
  • Field Details

    • ROOT_PATH

      public static final String ROOT_PATH
      See Also:
    • MAX_ASYNC_WAIT_MILLIS

      public static final int MAX_ASYNC_WAIT_MILLIS

      How many millisecond to wait before giving up on waiting for an async index to be updated.

      By default it will wait 6000ms but it can be fine tuned with, for example -Dgranite.it.maxasync=12000

    • profile

      protected UserProfile profile
  • Constructor Details

  • Method Details

    • getRootPath

      public String getRootPath()
      Description copied from interface: Authorizable
      Get root path of the authorizable (user/group) in repository
      Returns:
      root path
    • addImpersonators

      public <T extends User> org.apache.sling.testing.clients.SlingHttpResponse addImpersonators(T[] authorizables, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
      Adds impersonators to the user.
      Type Parameters:
      T - user type
      Parameters:
      authorizables - list of any User objects
      expectedStatus - list of allowed HTTP Status to be returned.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - if something fails during request/response cycle
      InterruptedException - if waiting was interrupted
    • removeImpersonators

      public <T extends User> org.apache.sling.testing.clients.SlingHttpResponse removeImpersonators(T[] authorizables, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException
      Remove impersonators from the user
      Type Parameters:
      T - user type
      Parameters:
      authorizables - list of any User objects
      expectedStatus - list of allowed HTTP Status to be returned.
      Returns:
      Sling response
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
    • getUserProfile

      public UserProfile getUserProfile() throws org.apache.sling.testing.clients.ClientException
      Get user profile
      Returns:
      UserProfile
      Throws:
      org.apache.sling.testing.clients.ClientException - if the request failed
    • initProfile

      protected void initProfile() throws org.apache.sling.testing.clients.ClientException
      Throws:
      org.apache.sling.testing.clients.ClientException
    • createUser

      public static <T extends SecurityClient> User createUser(T client, String userId, String password, String intermediatePath, Map<String,String> profileMap, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
      Creates a new user.
      Type Parameters:
      T - client type
      Parameters:
      client - any class implementing the SecurityClient.
      userId - the user ID for the new user.
      password - the password to be assigned.
      intermediatePath - the root path user will be created.
      profileMap - profile properties to be set for the new user.
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.
      Returns:
      User
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      InterruptedException - to mark this method as "waiting"
    • createUser

      @Deprecated public static <T extends SecurityClient> User createUser(T client, String userId, String password, String intermediatePath, Map<String,String> profileMap, boolean waitForIndex, int... expectedStatus) throws org.apache.sling.testing.clients.ClientException, InterruptedException
      Deprecated.
      waitForIndex parameter is not needed. Use createUser(SecurityClient, String, String, String, Map, int...)
      Creates a new user.
      Type Parameters:
      T - client type
      Parameters:
      client - any class implementing the SecurityClient.
      userId - the user ID for the new user.
      password - the password to be assigned.
      intermediatePath - the root path user will be created.
      profileMap - profile properties to be set for the new user.
      waitForIndex - Whether or not to wait for indexing to be complete before returning
      expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 201 (CREATED) is assumed.
      Returns:
      User
      Throws:
      org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      InterruptedException - to mark this method as "waiting"