Revision a784f00f
Added by Katja Luther about 14 years ago
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/UserService.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.api.service; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
12 | 13 |
import java.util.List; |
13 | 14 |
import java.util.UUID; |
14 | 15 |
|
... | ... | |
16 | 17 |
import org.springframework.beans.factory.annotation.Autowired; |
17 | 18 |
import org.springframework.dao.DataAccessException; |
18 | 19 |
import org.springframework.dao.IncorrectResultSizeDataAccessException; |
19 |
import org.springframework.security.AccessDeniedException; |
|
20 |
import org.springframework.security.Authentication; |
|
21 |
import org.springframework.security.AuthenticationManager; |
|
22 |
import org.springframework.security.GrantedAuthority; |
|
23 |
import org.springframework.security.context.SecurityContextHolder; |
|
24 |
import org.springframework.security.providers.UsernamePasswordAuthenticationToken; |
|
25 |
import org.springframework.security.providers.dao.SaltSource; |
|
26 |
import org.springframework.security.providers.dao.UserCache; |
|
27 |
import org.springframework.security.providers.dao.cache.NullUserCache; |
|
28 |
import org.springframework.security.providers.dao.salt.ReflectionSaltSource; |
|
29 |
import org.springframework.security.providers.encoding.Md5PasswordEncoder; |
|
30 |
import org.springframework.security.providers.encoding.PasswordEncoder; |
|
31 |
import org.springframework.security.userdetails.UserDetails; |
|
32 |
import org.springframework.security.userdetails.UsernameNotFoundException; |
|
20 |
|
|
21 |
import org.springframework.security.access.AccessDeniedException; |
|
22 |
import org.springframework.security.authentication.AuthenticationManager; |
|
23 |
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|
24 |
import org.springframework.security.authentication.dao.ReflectionSaltSource; |
|
25 |
import org.springframework.security.authentication.dao.SaltSource; |
|
26 |
import org.springframework.security.authentication.encoding.Md5PasswordEncoder; |
|
27 |
import org.springframework.security.authentication.encoding.PasswordEncoder; |
|
28 |
import org.springframework.security.core.Authentication; |
|
29 |
import org.springframework.security.core.GrantedAuthority; |
|
30 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
31 |
import org.springframework.security.core.userdetails.UserCache; |
|
32 |
import org.springframework.security.core.userdetails.UserDetails; |
|
33 |
import org.springframework.security.core.userdetails.UsernameNotFoundException; |
|
34 |
import org.springframework.security.core.userdetails.cache.NullUserCache; |
|
33 | 35 |
import org.springframework.stereotype.Service; |
34 | 36 |
import org.springframework.transaction.annotation.Propagation; |
35 | 37 |
import org.springframework.transaction.annotation.Transactional; |
... | ... | |
236 | 238 |
} |
237 | 239 |
|
238 | 240 |
@Transactional(readOnly=false) |
239 |
public void createGroup(String groupName, GrantedAuthority[] authorities) {
|
|
241 |
public void createGroup(String groupName, List<GrantedAuthority> authorities) {
|
|
240 | 242 |
Assert.hasText(groupName); |
241 | 243 |
Assert.notNull(authorities); |
242 | 244 |
|
... | ... | |
258 | 260 |
groupDao.delete(group); |
259 | 261 |
} |
260 | 262 |
|
261 |
public String[] findAllGroups() { |
|
262 |
List<String> names = groupDao.listNames(null,null); |
|
263 |
return names.toArray(new String[names.size()]); |
|
263 |
public List<String> findAllGroups() { |
|
264 |
return groupDao.listNames(null,null); |
|
264 | 265 |
} |
265 | 266 |
|
266 |
public GrantedAuthority[] findGroupAuthorities(String groupName) {
|
|
267 |
public List<GrantedAuthority> findGroupAuthorities(String groupName) {
|
|
267 | 268 |
Assert.hasText(groupName); |
268 | 269 |
Group group = groupDao.findGroupByName(groupName); |
269 | 270 |
|
270 |
return group.getGrantedAuthorities().toArray(new GrantedAuthority[group.getGrantedAuthorities().size()]);
|
|
271 |
return new ArrayList<GrantedAuthority>(group.getGrantedAuthorities());
|
|
271 | 272 |
} |
272 | 273 |
|
273 |
public String[] findUsersInGroup(String groupName) {
|
|
274 |
public List<String> findUsersInGroup(String groupName) {
|
|
274 | 275 |
Assert.hasText(groupName); |
275 | 276 |
Group group = groupDao.findGroupByName(groupName); |
276 | 277 |
|
277 | 278 |
List<String> users = groupDao.listMembers(group, null, null); |
278 | 279 |
|
279 |
return users.toArray(new String[users.size()]);
|
|
280 |
return users; |
|
280 | 281 |
} |
281 | 282 |
|
282 | 283 |
@Transactional(readOnly=false) |
Also available in: Unified diff
merge cate-development2 branch with trunk