James Moger
2012-09-10 fabe060d3a435f116128851f828e35c2af5fde67
commit | author | age
f13c4c 1 /*
JM 2  * Copyright 2011 gitblit.com.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
fc948c 16 package com.gitblit;
JM 17
f98825 18 import java.util.List;
JM 19
fe24a0 20 import com.gitblit.models.TeamModel;
1f9dae 21 import com.gitblit.models.UserModel;
fc948c 22
892570 23 /**
JM 24  * Implementations of IUserService control all aspects of UserModel objects and
25  * user authentication.
26  * 
27  * @author James Moger
28  * 
29  */
85c2e6 30 public interface IUserService {
JM 31
892570 32     /**
63ee41 33      * Setup the user service. This method allows custom implementations to
JM 34      * retrieve settings from gitblit.properties or the web.xml file without
35      * relying on the GitBlit static singleton.
36      * 
37      * @param settings
4c6dab 38      * @since 0.7.0
63ee41 39      */
JM 40     void setup(IStoredSettings settings);
41
42     /**
6cca86 43      * Does the user service support changes to credentials?
JM 44      * 
45      * @return true or false
46      * @since 1.0.0
47      */    
48     boolean supportsCredentialChanges();
0aa8cf 49
JM 50     /**
51      * Does the user service support changes to user display name?
52      * 
53      * @return true or false
54      * @since 1.0.0
55      */    
56     boolean supportsDisplayNameChanges();
57
58     /**
59      * Does the user service support changes to user email address?
60      * 
61      * @return true or false
62      * @since 1.0.0
63      */    
64     boolean supportsEmailAddressChanges();
6cca86 65     
JM 66     /**
67      * Does the user service support changes to team memberships?
68      * 
69      * @return true or false
70      * @since 1.0.0
71      */    
72     boolean supportsTeamMembershipChanges();
73     
74     /**
892570 75      * Does the user service support cookie authentication?
JM 76      * 
77      * @return true or false
78      */
85c2e6 79     boolean supportsCookies();
JM 80
892570 81     /**
JM 82      * Returns the cookie value for the specified user.
83      * 
84      * @param model
85      * @return cookie value
86      */
62aeb9 87     String getCookie(UserModel model);
85c2e6 88
892570 89     /**
JM 90      * Authenticate a user based on their cookie.
91      * 
92      * @param cookie
93      * @return a user object or null
94      */
85c2e6 95     UserModel authenticate(char[] cookie);
fc948c 96
892570 97     /**
JM 98      * Authenticate a user based on a username and password.
99      * 
100      * @param username
101      * @param password
102      * @return a user object or null
103      */
511554 104     UserModel authenticate(String username, char[] password);
155bf7 105
892570 106     /**
ea094a 107      * Logout a user.
JM 108      * 
109      * @param user
110      */
111     void logout(UserModel user);
112     
113     /**
892570 114      * Retrieve the user object for the specified username.
JM 115      * 
116      * @param username
117      * @return a user object or null
118      */
511554 119     UserModel getUserModel(String username);
2a7306 120
892570 121     /**
JM 122      * Updates/writes a complete user object.
123      * 
124      * @param model
125      * @return true if update is successful
126      */
511554 127     boolean updateUserModel(UserModel model);
2a7306 128
892570 129     /**
JM 130      * Adds/updates a user object keyed by username. This method allows for
131      * renaming a user.
132      * 
133      * @param username
134      *            the old username
135      * @param model
136      *            the user object to use for username
137      * @return true if update is successful
138      */
8a2e9c 139     boolean updateUserModel(String username, UserModel model);
2a7306 140
892570 141     /**
JM 142      * Deletes the user object from the user service.
143      * 
144      * @param model
145      * @return true if successful
146      */
511554 147     boolean deleteUserModel(UserModel model);
2a7306 148
892570 149     /**
JM 150      * Delete the user object with the specified username
151      * 
152      * @param username
153      * @return true if successful
154      */
8a2e9c 155     boolean deleteUser(String username);
2a7306 156
892570 157     /**
JM 158      * Returns the list of all users available to the login service.
159      * 
160      * @return list of all usernames
161      */
f98825 162     List<String> getAllUsernames();
abeaaf 163     
JM 164     /**
165      * Returns the list of all users available to the login service.
166      * 
167      * @return list of all users
168      * @since 0.8.0
169      */
170     List<UserModel> getAllUsers();
2a7306 171
892570 172     /**
fe24a0 173      * Returns the list of all teams available to the login service.
JM 174      * 
175      * @return list of all teams
176      * @since 0.8.0
177      */    
178     List<String> getAllTeamNames();
179     
180     /**
abeaaf 181      * Returns the list of all teams available to the login service.
JM 182      * 
183      * @return list of all teams
184      * @since 0.8.0
185      */    
186     List<TeamModel> getAllTeams();
187     
188     /**
fe24a0 189      * Returns the list of all users who are allowed to bypass the access
JM 190      * restriction placed on the specified repository.
191      * 
192      * @param role
193      *            the repository name
194      * @return list of all usernames that can bypass the access restriction
abeaaf 195      * @since 0.8.0
fe24a0 196      */    
JM 197     List<String> getTeamnamesForRepositoryRole(String role);
198
199     /**
200      * Sets the list of all teams who are allowed to bypass the access
201      * restriction placed on the specified repository.
202      * 
203      * @param role
204      *            the repository name
205      * @param teamnames
206      * @return true if successful
abeaaf 207      * @since 0.8.0
fe24a0 208      */    
JM 209     boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames);
210     
211     /**
212      * Retrieve the team object for the specified team name.
213      * 
214      * @param teamname
215      * @return a team object or null
216      * @since 0.8.0
217      */    
218     TeamModel getTeamModel(String teamname);
219
220     /**
221      * Updates/writes a complete team object.
222      * 
223      * @param model
224      * @return true if update is successful
225      * @since 0.8.0
226      */    
227     boolean updateTeamModel(TeamModel model);
228
229     /**
230      * Updates/writes and replaces a complete team object keyed by teamname.
231      * This method allows for renaming a team.
232      * 
233      * @param teamname
234      *            the old teamname
235      * @param model
236      *            the team object to use for teamname
237      * @return true if update is successful
238      * @since 0.8.0
239      */
240     boolean updateTeamModel(String teamname, TeamModel model);
241
242     /**
243      * Deletes the team object from the user service.
244      * 
245      * @param model
246      * @return true if successful
247      * @since 0.8.0
248      */
249     boolean deleteTeamModel(TeamModel model);
250
251     /**
252      * Delete the team object with the specified teamname
253      * 
254      * @param teamname
255      * @return true if successful
256      * @since 0.8.0
257      */    
258     boolean deleteTeam(String teamname);
259
260     /**
892570 261      * Returns the list of all users who are allowed to bypass the access
JM 262      * restriction placed on the specified repository.
263      * 
264      * @param role
265      *            the repository name
266      * @return list of all usernames that can bypass the access restriction
abeaaf 267      * @since 0.8.0
892570 268      */
JM 269     List<String> getUsernamesForRepositoryRole(String role);
2a7306 270
892570 271     /**
JM 272      * Sets the list of all uses who are allowed to bypass the access
273      * restriction placed on the specified repository.
274      * 
275      * @param role
276      *            the repository name
277      * @param usernames
278      * @return true if successful
279      */
280     boolean setUsernamesForRepositoryRole(String role, List<String> usernames);
2a7306 281
892570 282     /**
JM 283      * Renames a repository role.
284      * 
285      * @param oldRole
286      * @param newRole
287      * @return true if successful
288      */
85c2e6 289     boolean renameRepositoryRole(String oldRole, String newRole);
2a7306 290
892570 291     /**
JM 292      * Removes a repository role from all users.
293      * 
294      * @param role
295      * @return true if successful
296      */
85c2e6 297     boolean deleteRepositoryRole(String role);
JM 298
892570 299     /**
JM 300      * @See java.lang.Object.toString();
301      * @return string representation of the login service
302      */
5450d0 303     String toString();
fc948c 304 }