View Javadoc

1   /**
2    * Copyright 2005-2008 the original author or authors.
3    *
4    * Licensed under the Gnu General Pubic License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with
6    * the License. You may obtain a copy of the License at
7    *
8    *      http://www.opensource.org/licenses/gpl-license.php
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13   * See the Gnu General Public License for more details.
14   */
15  package org.figure8.join.businessfacades.security;
16  
17  import org.figure8.join.core.DuplicateEntityException;
18  import org.figure8.join.businessobjects.security.User;
19  import org.figure8.join.services.security.PasswordEncoder;
20  import org.figure8.join.services.security.InvalidLoginException;
21  import org.figure8.join.view.UserView;
22  
23  import java.util.List;
24  /**
25   * Provides methods that the Join application users management service must
26   * implements. These methods define how a user must be registered, logged on
27   * Join application and so on ...
28   * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
29   * @version $Revision: 1.2 $
30   */
31  public interface UserManager{
32  
33     // Public -------------------------------------------------------------------
34  
35     /**
36      * The setPasswordEncoder() method must be called during the implementation
37      * initialization phase. It must allowed the registration of a PasswordEncoder
38      * for the deployed Join application.
39      * @param encoder Implementation of PaswordEncoder to check and encode users password
40      */
41     public abstract void setPasswordEncoder(PasswordEncoder encoder);
42  
43     /**
44      * The setPermissionManager() method must be called during the implementation
45      * initilization phase. It must allowed the registration of a PermissionManager
46      * useful for retrieving security permissions acquired by a user.
47      * @param manager Implementation of PermissionManager to retrieve security rights
48      */
49     public abstract void setPermissionManager(PermissionManager manager);
50  
51     /**
52      * The login method is called when a user wishes to login to the Join application.
53      * This method <code>should</code> use the PasswordEncoder validatePassword() method for
54      * user's credential validation.
55      * @param userId The user identifier.
56      * @param userCredential The user credential.
57      * @return A ValueHolder object representing the user's view (data + permissions).
58      * @throws InvalidLoginException if the credentials are invalid.
59      */
60     public abstract UserView login(String userId, String userCredential) throws InvalidLoginException;
61  
62     /**
63      * Save or update a given <b>user</b> into datastore.<br/>
64      * Warning: this method should be used when first creating a user or
65      * when updating a user. In this 2 use-cases, password validation is required
66      * so password should be in clear text within the User object.
67      * @param user User object to save within datastore
68      * @throws DuplicateEntityException if a user with this login already exists.
69      */
70     public abstract void saveUser(User user) throws DuplicateEntityException;
71  
72     /**
73      * Retrieves a specific User using its login identifier
74      * @param login The user to retrieve unique login
75      * @return The user having this specified login
76      */
77     public abstract User getUser(String login);
78  
79     /**
80      * The getUsers method must be used when you want to list all users.
81      * @return List of <code>org.figure8.join.businessobjects.security.User</code>.
82      */
83     public abstract List getUsers();
84  
85     /**
86      * The getUsers method must be used when you want to list users using lastname
87      * criterion. Users have their lastname "LIKE" given arguments.
88      * @param lastname The lastname to use as search criteria
89      * @return List of <code>org.figure8.join.businessobjects.security.User</code>.
90      */
91     public abstract List getUsers(String lastname);
92  
93  }