|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| DaoCasAuthoritiesPopulator.java | - | 100% | 100% | 100% |
|
||||||||||||||
| 1 | /* Copyright 2004 Acegi Technology Pty Limited | |
| 2 | * | |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 | * you may not use this file except in compliance with the License. | |
| 5 | * You may obtain a copy of the License at | |
| 6 | * | |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 | * | |
| 9 | * 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 | 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 | //~ Instance fields ======================================================== | |
| 43 | ||
| 44 | private UserDetailsService userDetailsService; | |
| 45 | ||
| 46 | //~ Methods ================================================================ | |
| 47 | ||
| 48 | 4 | public void setUserDetailsService(UserDetailsService authenticationDao) { |
| 49 | 4 | this.userDetailsService = authenticationDao; |
| 50 | } | |
| 51 | ||
| 52 | 1 | public UserDetailsService getUserDetailsService() { |
| 53 | 1 | return userDetailsService; |
| 54 | } | |
| 55 | ||
| 56 | 3 | public UserDetails getUserDetails(String casUserId) |
| 57 | throws AuthenticationException { | |
| 58 | 3 | return this.userDetailsService.loadUserByUsername(casUserId); |
| 59 | } | |
| 60 | ||
| 61 | 4 | public void afterPropertiesSet() throws Exception { |
| 62 | 4 | Assert.notNull(this.userDetailsService, "An authenticationDao must be set"); |
| 63 | } | |
| 64 | } |
|
||||||||||