Coverage Report - org.kuali.rice.kim.client.acegi.KualiTestAuthenticationProvider
 
Classes in this File Line Coverage Branch Coverage Complexity
KualiTestAuthenticationProvider
0%
0/9
0%
0/4
2.333
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  
 package org.kuali.rice.kim.client.acegi;
 17  
 
 18  
 import org.acegisecurity.Authentication;
 19  
 import org.acegisecurity.AuthenticationException;
 20  
 import org.acegisecurity.GrantedAuthority;
 21  
 import org.acegisecurity.GrantedAuthorityImpl;
 22  
 import org.acegisecurity.providers.AuthenticationProvider;
 23  
 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
 24  
 import org.apache.commons.logging.Log;
 25  
 import org.apache.commons.logging.LogFactory;
 26  
 
 27  
 /**
 28  
  * This is the out of box authentication method used by rice.  It authenticates any username/password pairs that match  
 29  
  * 
 30  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 31  
  *
 32  
  */
 33  0
 public class KualiTestAuthenticationProvider implements AuthenticationProvider {
 34  
 
 35  
         public Authentication authenticate(Authentication authentication)
 36  
         throws AuthenticationException {
 37  
 
 38  0
         if (authentication.getPrincipal().equals(authentication.getCredentials())) {
 39  0
                 Authentication auth = authenticateNow(authentication);
 40  0
                 return auth;
 41  
         } else {
 42  0
                 return authentication;
 43  
         }
 44  
     }
 45  
 
 46  
     private UsernamePasswordAuthenticationToken authenticateNow(Authentication authentication) throws AuthenticationException {
 47  0
             return new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials(), new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_KUALI_USER")});
 48  
     }
 49  
     
 50  
     public boolean supports(Class authentication) {
 51  0
         if (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication)) {
 52  0
             return true;
 53  
         } else {
 54  0
             return false;
 55  
         }
 56  
     }
 57  
 }