1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kim.client.acegi; |
18 | |
|
19 | |
import org.acegisecurity.GrantedAuthority; |
20 | |
import org.acegisecurity.GrantedAuthorityImpl; |
21 | |
import org.acegisecurity.userdetails.User; |
22 | |
import org.acegisecurity.userdetails.UserDetails; |
23 | |
import org.apache.commons.logging.Log; |
24 | |
import org.apache.commons.logging.LogFactory; |
25 | |
import org.springframework.beans.factory.InitializingBean; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class KualiUserDetailsServiceImpl implements KualiUserDetailsService, InitializingBean |
35 | |
{ |
36 | 0 | private static final Log logger = LogFactory.getLog(KualiUserDetailsServiceImpl.class); |
37 | |
|
38 | 0 | public void afterPropertiesSet() throws Exception {} |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public UserDetails loadUserByTicketResponse(KualiTicketResponse response) { |
47 | 0 | GrantedAuthority[] authorities = new GrantedAuthority[1]; |
48 | 0 | authorities[0]= new GrantedAuthorityImpl(response.getDistributedSessionToken()); |
49 | 0 | if (logger.isDebugEnabled()) { |
50 | 0 | logger.debug("loadUserByTicketResponse:" + response.getDistributedSessionToken()); |
51 | |
} |
52 | 0 | return loadUserByUsernameAndAuthorities(response.getUser(), authorities); |
53 | |
} |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public UserDetails loadUserByUsername(String username) |
61 | |
{ |
62 | 0 | if (logger.isDebugEnabled()) { |
63 | 0 | logger.debug("loadUserByUsername"); |
64 | |
} |
65 | 0 | return loadUserByUsernameAndAuthorities(username, new GrantedAuthority[0]); |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
public UserDetails loadUserByUsernameAndAuthorities(String username, GrantedAuthority[] authorities) { |
76 | 0 | if (logger.isDebugEnabled()) { |
77 | 0 | logger.debug("loadUserByUsernameAndAuthorities"); |
78 | |
} |
79 | 0 | GrantedAuthority[] newAuthorities = new GrantedAuthority[authorities.length+1]; |
80 | 0 | System.arraycopy(authorities, 0, newAuthorities, 0, authorities.length); |
81 | 0 | newAuthorities[authorities.length]= new GrantedAuthorityImpl("ROLE_KUALI_USER"); |
82 | 0 | logger.warn("setting granted authorities:" + newAuthorities.toString()); |
83 | 0 | UserDetails user = new User(username, "empty_password", true, true, true, true, newAuthorities); |
84 | 0 | return user; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
} |