Revision 8427
Added by Jing Tao about 11 years ago
src/edu/ucsb/nceas/metacat/authentication/AuthFile.java | ||
---|---|---|
183 | 183 |
} |
184 | 184 |
|
185 | 185 |
@Override |
186 |
/** |
|
187 |
* Get all users. This is two-dimmention array. Each row is a user. The first element of |
|
188 |
* a row is the user name. |
|
189 |
*/ |
|
186 | 190 |
public String[][] getUsers(String user, String password) |
187 | 191 |
throws ConnectException { |
188 |
// TODO Auto-generated method stub |
|
192 |
List<Object> users = userpassword.getList(USERS+SLASH+USER+SLASH+AT+NAME); |
|
193 |
if(users != null && users.size() > 0) { |
|
194 |
String[][] usersArray = new String[users.size()][1]; |
|
195 |
for(int i=0; i<users.size(); i++) { |
|
196 |
usersArray[i][0] = (String) users.get(i); |
|
197 |
} |
|
198 |
return usersArray; |
|
199 |
} |
|
189 | 200 |
return null; |
190 | 201 |
} |
191 | 202 |
|
... | ... | |
196 | 207 |
return null; |
197 | 208 |
} |
198 | 209 |
|
210 |
|
|
199 | 211 |
@Override |
212 |
/** |
|
213 |
* Get the users for a particular group from the authentication service |
|
214 |
* The null will return if there is no user. |
|
215 |
* @param user |
|
216 |
* the user for authenticating against the service |
|
217 |
* @param password |
|
218 |
* the password for authenticating against the service |
|
219 |
* @param group |
|
220 |
* the group whose user list should be returned |
|
221 |
* @returns string array of the user names belonging to the group |
|
222 |
*/ |
|
200 | 223 |
public String[] getUsers(String user, String password, String group) |
201 | 224 |
throws ConnectException { |
202 |
// TODO Auto-generated method stub |
|
225 |
List<Object> users = userpassword.getList(USERS+SLASH+USER+"["+GROUP+"='"+group+"']"+SLASH+AT+NAME); |
|
226 |
if(users != null && users.size() > 0) { |
|
227 |
String[] usersArray = new String[users.size()]; |
|
228 |
for(int i=0; i<users.size(); i++) { |
|
229 |
usersArray[i] = (String) users.get(i); |
|
230 |
} |
|
231 |
return usersArray; |
|
232 |
} |
|
203 | 233 |
return null; |
204 | 234 |
} |
205 | 235 |
|
206 | 236 |
@Override |
237 |
/** |
|
238 |
* Get all groups from the authentication service. It returns a two dimmension array. Each row is a |
|
239 |
* group. The first column is the group name. The null will return if no group found. |
|
240 |
*/ |
|
207 | 241 |
public String[][] getGroups(String user, String password) |
208 | 242 |
throws ConnectException { |
209 |
// TODO Auto-generated method stub |
|
243 |
List<Object> groups = userpassword.getList(GROUPS+SLASH+GROUP+SLASH+AT+NAME); |
|
244 |
if(groups!= null && groups.size() >0) { |
|
245 |
String[][] groupsArray = new String[groups.size()][1]; |
|
246 |
for(int i=0; i<groups.size(); i++) { |
|
247 |
groupsArray[i][0] = (String) groups.get(i); |
|
248 |
} |
|
249 |
return groupsArray; |
|
250 |
} |
|
210 | 251 |
return null; |
211 | 252 |
} |
212 | 253 |
|
213 | 254 |
@Override |
255 |
/** |
|
256 |
* Get groups from a specified user. It returns two dimmension array. Each row is a |
|
257 |
* group. The first column is the group name. The null will return if no group found. |
|
258 |
*/ |
|
214 | 259 |
public String[][] getGroups(String user, String password, String foruser) |
215 | 260 |
throws ConnectException { |
216 |
// TODO Auto-generated method stub |
|
261 |
List<Object> groups = userpassword.getList(USERS+SLASH+USER+"["+AT+NAME+"='"+foruser+"']"+SLASH+GROUP); |
|
262 |
if(groups != null && groups.size() > 0) { |
|
263 |
String[][] groupsArray = new String[groups.size()][1]; |
|
264 |
for(int i=0; i<groups.size(); i++) { |
|
265 |
groupsArray[i][0] = (String) groups.get(i); |
|
266 |
} |
|
267 |
return groupsArray; |
|
268 |
} |
|
217 | 269 |
return null; |
218 | 270 |
} |
219 | 271 |
|
Also available in: Unified diff
Add method to get groups and users.