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