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