View Javadoc

1   package com.atlassian.user;
2   
3   import com.atlassian.user.search.page.Pager;
4   import com.atlassian.user.security.password.PasswordEncryptor;
5   import com.atlassian.user.impl.DuplicateEntityException;
6   
7   public interface UserManager extends EntityManager
8   {
9       /**
10       * @return a {@link Pager} holding all users being managed.
11       * @throws EntityException
12       */
13      Pager<User> getUsers()  throws EntityException;
14  
15      /**
16       * @return a {@link Pager} holding the names of all users being managed.
17       * @throws EntityException
18       */
19      Pager<String> getUserNames() throws EntityException;
20  
21      /**
22       * @return a <code>null</code> or a {@link User} if one could be found.
23       */
24      User getUser(String username) throws EntityException;
25  
26      /**
27       * Creates a new user with the username provided. Returns the newly created user.
28       *
29       * @return a {@link User} object representing the new user.
30       * @throws DuplicateEntityException if a user with the username already exists.
31       * @throws UnsupportedOperationException - if {@link UserManager#isCreative()} returns <code>false</code>.
32       */
33      User createUser(String username) throws EntityException;
34  
35      /**
36       * Encrypts the plain password, sets it on the user, and saves the user.
37       * Implementations supporting this will usually have an internal {@link PasswordEncryptor}.
38       *
39       * @throws UnsupportedOperationException - if {@link UserManager#isCreative()} returns <code>false</code>.
40       */
41      void alterPassword(User user, String plainTextPass) throws EntityException;
42  
43      /**
44       * Persists any changes made to the user to the storage system used by this user manager.
45       * <p/>
46       * To ensure consistent behaviour across all repository types, clients must call this method after
47       * using {@link User#setEmail(String)}, {@link User#setFullName(String)} or {@link User#setPassword(String)}.
48       *
49       * @throws UnsupportedOperationException - if {@link UserManager#isCreative()} returns <code>false</code>
50       * @throws IllegalArgumentException if the user is null or not managed by this repository
51       */
52      void saveUser(User user) throws EntityException, IllegalArgumentException;
53  
54      /**
55       * Removes the specified user from the repository.
56       *
57       * @throws UnsupportedOperationException if {@link UserManager#isReadOnly(User)} returns <code>true</code>.
58       * @throws IllegalArgumentException if the user is null or not managed by this repository
59       */
60      void removeUser(User user) throws EntityException, IllegalArgumentException;
61  
62      /**
63       * @return true indicates that information on the user object cannot be altered in the storage system
64       * (see {@link com.atlassian.user.repository.RepositoryIdentifier}),
65       * false indicates that the storage system will save changes or that this {@link UserManager} does not 
66       * know about the {@link User}.
67       */
68      boolean isReadOnly(User user) throws EntityException;
69  }
70