James Moger
2012-04-25 ea094a45b9a31076919ca23ba17e8ad27e90ebce
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();
49     
50     /**
51      * Does the user service support changes to team memberships?
52      * 
53      * @return true or false
54      * @since 1.0.0
55      */    
56     boolean supportsTeamMembershipChanges();
57     
58     /**
892570 59      * Does the user service support cookie authentication?
JM 60      * 
61      * @return true or false
62      */
85c2e6 63     boolean supportsCookies();
JM 64
892570 65     /**
JM 66      * Returns the cookie value for the specified user.
67      * 
68      * @param model
69      * @return cookie value
70      */
85c2e6 71     char[] getCookie(UserModel model);
JM 72
892570 73     /**
JM 74      * Authenticate a user based on their cookie.
75      * 
76      * @param cookie
77      * @return a user object or null
78      */
85c2e6 79     UserModel authenticate(char[] cookie);
fc948c 80
892570 81     /**
JM 82      * Authenticate a user based on a username and password.
83      * 
84      * @param username
85      * @param password
86      * @return a user object or null
87      */
511554 88     UserModel authenticate(String username, char[] password);
155bf7 89
892570 90     /**
ea094a 91      * Logout a user.
JM 92      * 
93      * @param user
94      */
95     void logout(UserModel user);
96     
97     /**
892570 98      * Retrieve the user object for the specified username.
JM 99      * 
100      * @param username
101      * @return a user object or null
102      */
511554 103     UserModel getUserModel(String username);
2a7306 104
892570 105     /**
JM 106      * Updates/writes a complete user object.
107      * 
108      * @param model
109      * @return true if update is successful
110      */
511554 111     boolean updateUserModel(UserModel model);
2a7306 112
892570 113     /**
JM 114      * Adds/updates a user object keyed by username. This method allows for
115      * renaming a user.
116      * 
117      * @param username
118      *            the old username
119      * @param model
120      *            the user object to use for username
121      * @return true if update is successful
122      */
8a2e9c 123     boolean updateUserModel(String username, UserModel model);
2a7306 124
892570 125     /**
JM 126      * Deletes the user object from the user service.
127      * 
128      * @param model
129      * @return true if successful
130      */
511554 131     boolean deleteUserModel(UserModel model);
2a7306 132
892570 133     /**
JM 134      * Delete the user object with the specified username
135      * 
136      * @param username
137      * @return true if successful
138      */
8a2e9c 139     boolean deleteUser(String username);
2a7306 140
892570 141     /**
JM 142      * Returns the list of all users available to the login service.
143      * 
144      * @return list of all usernames
145      */
f98825 146     List<String> getAllUsernames();
abeaaf 147     
JM 148     /**
149      * Returns the list of all users available to the login service.
150      * 
151      * @return list of all users
152      * @since 0.8.0
153      */
154     List<UserModel> getAllUsers();
2a7306 155
892570 156     /**
fe24a0 157      * Returns the list of all teams available to the login service.
JM 158      * 
159      * @return list of all teams
160      * @since 0.8.0
161      */    
162     List<String> getAllTeamNames();
163     
164     /**
abeaaf 165      * Returns the list of all teams available to the login service.
JM 166      * 
167      * @return list of all teams
168      * @since 0.8.0
169      */    
170     List<TeamModel> getAllTeams();
171     
172     /**
fe24a0 173      * Returns the list of all users who are allowed to bypass the access
JM 174      * restriction placed on the specified repository.
175      * 
176      * @param role
177      *            the repository name
178      * @return list of all usernames that can bypass the access restriction
abeaaf 179      * @since 0.8.0
fe24a0 180      */    
JM 181     List<String> getTeamnamesForRepositoryRole(String role);
182
183     /**
184      * Sets the list of all teams who are allowed to bypass the access
185      * restriction placed on the specified repository.
186      * 
187      * @param role
188      *            the repository name
189      * @param teamnames
190      * @return true if successful
abeaaf 191      * @since 0.8.0
fe24a0 192      */    
JM 193     boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames);
194     
195     /**
196      * Retrieve the team object for the specified team name.
197      * 
198      * @param teamname
199      * @return a team object or null
200      * @since 0.8.0
201      */    
202     TeamModel getTeamModel(String teamname);
203
204     /**
205      * Updates/writes a complete team object.
206      * 
207      * @param model
208      * @return true if update is successful
209      * @since 0.8.0
210      */    
211     boolean updateTeamModel(TeamModel model);
212
213     /**
214      * Updates/writes and replaces a complete team object keyed by teamname.
215      * This method allows for renaming a team.
216      * 
217      * @param teamname
218      *            the old teamname
219      * @param model
220      *            the team object to use for teamname
221      * @return true if update is successful
222      * @since 0.8.0
223      */
224     boolean updateTeamModel(String teamname, TeamModel model);
225
226     /**
227      * Deletes the team object from the user service.
228      * 
229      * @param model
230      * @return true if successful
231      * @since 0.8.0
232      */
233     boolean deleteTeamModel(TeamModel model);
234
235     /**
236      * Delete the team object with the specified teamname
237      * 
238      * @param teamname
239      * @return true if successful
240      * @since 0.8.0
241      */    
242     boolean deleteTeam(String teamname);
243
244     /**
892570 245      * Returns the list of all users who are allowed to bypass the access
JM 246      * restriction placed on the specified repository.
247      * 
248      * @param role
249      *            the repository name
250      * @return list of all usernames that can bypass the access restriction
abeaaf 251      * @since 0.8.0
892570 252      */
JM 253     List<String> getUsernamesForRepositoryRole(String role);
2a7306 254
892570 255     /**
JM 256      * Sets the list of all uses who are allowed to bypass the access
257      * restriction placed on the specified repository.
258      * 
259      * @param role
260      *            the repository name
261      * @param usernames
262      * @return true if successful
263      */
264     boolean setUsernamesForRepositoryRole(String role, List<String> usernames);
2a7306 265
892570 266     /**
JM 267      * Renames a repository role.
268      * 
269      * @param oldRole
270      * @param newRole
271      * @return true if successful
272      */
85c2e6 273     boolean renameRepositoryRole(String oldRole, String newRole);
2a7306 274
892570 275     /**
JM 276      * Removes a repository role from all users.
277      * 
278      * @param role
279      * @return true if successful
280      */
85c2e6 281     boolean deleteRepositoryRole(String role);
JM 282
892570 283     /**
JM 284      * @See java.lang.Object.toString();
285      * @return string representation of the login service
286      */
5450d0 287     String toString();
fc948c 288 }