01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.providers.cas.populator;
17:
18: import org.acegisecurity.AuthenticationException;
19:
20: import org.acegisecurity.providers.cas.CasAuthoritiesPopulator;
21:
22: import org.acegisecurity.userdetails.UserDetails;
23: import org.acegisecurity.userdetails.UserDetailsService;
24:
25: import org.springframework.beans.factory.InitializingBean;
26:
27: import org.springframework.util.Assert;
28:
29: /**
30: * Populates the CAS authorities via an {@link UserDetailsService}.<P>The additional information (username,
31: * password, enabled status etc) an <code>AuthenticationDao</code> implementation provides about a <code>User</code>
32: * is ignored. Only the <code>GrantedAuthority</code>s are relevant to this class.</p>
33: *
34: * @author Ben Alex
35: * @version $Id: DaoCasAuthoritiesPopulator.java 1821 2007-05-17 03:18:35Z raykrueger $
36: */
37: public class DaoCasAuthoritiesPopulator implements
38: CasAuthoritiesPopulator, InitializingBean {
39: //~ Instance fields ================================================================================================
40:
41: private UserDetailsService userDetailsService;
42:
43: //~ Methods ========================================================================================================
44:
45: public void afterPropertiesSet() throws Exception {
46: Assert.notNull(this .userDetailsService,
47: "A UserDetailsService must be set");
48: }
49:
50: public UserDetails getUserDetails(String casUserId)
51: throws AuthenticationException {
52: return this .userDetailsService.loadUserByUsername(casUserId);
53: }
54:
55: public UserDetailsService getUserDetailsService() {
56: return userDetailsService;
57: }
58:
59: public void setUserDetailsService(
60: UserDetailsService userDetailsService) {
61: this.userDetailsService = userDetailsService;
62: }
63: }
|