Coverage Report - org.kuali.rice.kim.client.acegi.KualiUserDetailsServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiUserDetailsServiceImpl
0%
0/19
0%
0/6
1.75
 
 1  
 /*
 2  
  * Copyright 2007-2008 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
  * Populates a UserDetails object with ticket or username and 
 29  
  * Authentication Method
 30  
  *  
 31  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
      * This overridden method appends the Distributed Session Ticket to the
 42  
      * granted authorities
 43  
      * 
 44  
      * @see org.kuali.rice.kim.client.acegi.KualiUserDetailsService#loadUserByTicketResponse(org.kuali.rice.kim.client.acegi.KualiTicketResponse)
 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  
      * This overridden method ...
 57  
      * 
 58  
      * @see org.acegisecurity.userdetails.UserDetailsService#loadUserByUsername(java.lang.String)
 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  
      * This method is necessary for loading users by the ticket response
 70  
      * 
 71  
      * @param username
 72  
      * @param authorities
 73  
      * @return the UserDetails
 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  
 }