1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.providers.cas.populator;
17
18 import org.acegisecurity.AuthenticationException;
19 import org.acegisecurity.providers.cas.CasAuthoritiesPopulator;
20 import org.acegisecurity.userdetails.UserDetailsService;
21 import org.acegisecurity.userdetails.UserDetails;
22
23 import org.springframework.beans.factory.InitializingBean;
24 import org.springframework.util.Assert;
25
26
27 /***
28 * Populates the CAS authorities via an {@link UserDetailsService}.
29 *
30 * <P>
31 * The additional information (username, password, enabled status etc) an
32 * <code>AuthenticationDao</code> implementation provides about a
33 * <code>User</code> is ignored. Only the <code>GrantedAuthority</code>s are
34 * relevant to this class.
35 * </p>
36 *
37 * @author Ben Alex
38 * @version $Id: DaoCasAuthoritiesPopulator.java,v 1.6 2005/11/30 00:20:12 benalex Exp $
39 */
40 public class DaoCasAuthoritiesPopulator implements CasAuthoritiesPopulator,
41 InitializingBean {
42
43
44 private UserDetailsService userDetailsService;
45
46
47
48 public void setUserDetailsService(UserDetailsService authenticationDao) {
49 this.userDetailsService = authenticationDao;
50 }
51
52 public UserDetailsService getUserDetailsService() {
53 return userDetailsService;
54 }
55
56 public UserDetails getUserDetails(String casUserId)
57 throws AuthenticationException {
58 return this.userDetailsService.loadUserByUsername(casUserId);
59 }
60
61 public void afterPropertiesSet() throws Exception {
62 Assert.notNull(this.userDetailsService, "An authenticationDao must be set");
63 }
64 }