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 |
|
1f9dae
|
20 |
import com.gitblit.models.UserModel;
|
fc948c
|
21 |
|
892570
|
22 |
/**
|
JM |
23 |
* Implementations of IUserService control all aspects of UserModel objects and
|
|
24 |
* user authentication.
|
|
25 |
*
|
|
26 |
* @author James Moger
|
|
27 |
*
|
|
28 |
*/
|
85c2e6
|
29 |
public interface IUserService {
|
JM |
30 |
|
892570
|
31 |
/**
|
63ee41
|
32 |
* Setup the user service. This method allows custom implementations to
|
JM |
33 |
* retrieve settings from gitblit.properties or the web.xml file without
|
|
34 |
* relying on the GitBlit static singleton.
|
|
35 |
*
|
|
36 |
* @param settings
|
4c6dab
|
37 |
* @since 0.7.0
|
63ee41
|
38 |
*/
|
JM |
39 |
void setup(IStoredSettings settings);
|
|
40 |
|
|
41 |
/**
|
892570
|
42 |
* Does the user service support cookie authentication?
|
JM |
43 |
*
|
|
44 |
* @return true or false
|
|
45 |
*/
|
85c2e6
|
46 |
boolean supportsCookies();
|
JM |
47 |
|
892570
|
48 |
/**
|
JM |
49 |
* Returns the cookie value for the specified user.
|
|
50 |
*
|
|
51 |
* @param model
|
|
52 |
* @return cookie value
|
|
53 |
*/
|
85c2e6
|
54 |
char[] getCookie(UserModel model);
|
JM |
55 |
|
892570
|
56 |
/**
|
JM |
57 |
* Authenticate a user based on their cookie.
|
|
58 |
*
|
|
59 |
* @param cookie
|
|
60 |
* @return a user object or null
|
|
61 |
*/
|
85c2e6
|
62 |
UserModel authenticate(char[] cookie);
|
fc948c
|
63 |
|
892570
|
64 |
/**
|
JM |
65 |
* Authenticate a user based on a username and password.
|
|
66 |
*
|
|
67 |
* @param username
|
|
68 |
* @param password
|
|
69 |
* @return a user object or null
|
|
70 |
*/
|
511554
|
71 |
UserModel authenticate(String username, char[] password);
|
155bf7
|
72 |
|
892570
|
73 |
/**
|
JM |
74 |
* Retrieve the user object for the specified username.
|
|
75 |
*
|
|
76 |
* @param username
|
|
77 |
* @return a user object or null
|
|
78 |
*/
|
511554
|
79 |
UserModel getUserModel(String username);
|
2a7306
|
80 |
|
892570
|
81 |
/**
|
JM |
82 |
* Updates/writes a complete user object.
|
|
83 |
*
|
|
84 |
* @param model
|
|
85 |
* @return true if update is successful
|
|
86 |
*/
|
511554
|
87 |
boolean updateUserModel(UserModel model);
|
2a7306
|
88 |
|
892570
|
89 |
/**
|
JM |
90 |
* Adds/updates a user object keyed by username. This method allows for
|
|
91 |
* renaming a user.
|
|
92 |
*
|
|
93 |
* @param username
|
|
94 |
* the old username
|
|
95 |
* @param model
|
|
96 |
* the user object to use for username
|
|
97 |
* @return true if update is successful
|
|
98 |
*/
|
8a2e9c
|
99 |
boolean updateUserModel(String username, UserModel model);
|
2a7306
|
100 |
|
892570
|
101 |
/**
|
JM |
102 |
* Deletes the user object from the user service.
|
|
103 |
*
|
|
104 |
* @param model
|
|
105 |
* @return true if successful
|
|
106 |
*/
|
511554
|
107 |
boolean deleteUserModel(UserModel model);
|
2a7306
|
108 |
|
892570
|
109 |
/**
|
JM |
110 |
* Delete the user object with the specified username
|
|
111 |
*
|
|
112 |
* @param username
|
|
113 |
* @return true if successful
|
|
114 |
*/
|
8a2e9c
|
115 |
boolean deleteUser(String username);
|
2a7306
|
116 |
|
892570
|
117 |
/**
|
JM |
118 |
* Returns the list of all users available to the login service.
|
|
119 |
*
|
|
120 |
* @return list of all usernames
|
|
121 |
*/
|
f98825
|
122 |
List<String> getAllUsernames();
|
2a7306
|
123 |
|
892570
|
124 |
/**
|
JM |
125 |
* Returns the list of all users who are allowed to bypass the access
|
|
126 |
* restriction placed on the specified repository.
|
|
127 |
*
|
|
128 |
* @param role
|
|
129 |
* the repository name
|
|
130 |
* @return list of all usernames that can bypass the access restriction
|
|
131 |
*/
|
|
132 |
List<String> getUsernamesForRepositoryRole(String role);
|
2a7306
|
133 |
|
892570
|
134 |
/**
|
JM |
135 |
* Sets the list of all uses who are allowed to bypass the access
|
|
136 |
* restriction placed on the specified repository.
|
|
137 |
*
|
|
138 |
* @param role
|
|
139 |
* the repository name
|
|
140 |
* @param usernames
|
|
141 |
* @return true if successful
|
|
142 |
*/
|
|
143 |
boolean setUsernamesForRepositoryRole(String role, List<String> usernames);
|
2a7306
|
144 |
|
892570
|
145 |
/**
|
JM |
146 |
* Renames a repository role.
|
|
147 |
*
|
|
148 |
* @param oldRole
|
|
149 |
* @param newRole
|
|
150 |
* @return true if successful
|
|
151 |
*/
|
85c2e6
|
152 |
boolean renameRepositoryRole(String oldRole, String newRole);
|
2a7306
|
153 |
|
892570
|
154 |
/**
|
JM |
155 |
* Removes a repository role from all users.
|
|
156 |
*
|
|
157 |
* @param role
|
|
158 |
* @return true if successful
|
|
159 |
*/
|
85c2e6
|
160 |
boolean deleteRepositoryRole(String role);
|
JM |
161 |
|
892570
|
162 |
/**
|
JM |
163 |
* @See java.lang.Object.toString();
|
|
164 |
* @return string representation of the login service
|
|
165 |
*/
|
5450d0
|
166 |
String toString();
|
fc948c
|
167 |
}
|