Coverage Report - org.acegisecurity.AuthenticationTrustResolverImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
AuthenticationTrustResolverImpl
93% 
100% 
1.667
 
 1  
 /* Copyright 2004, 2005, 2006 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;
 17  
 
 18  
 import org.acegisecurity.providers.anonymous.AnonymousAuthenticationToken;
 19  
 import org.acegisecurity.providers.rememberme.RememberMeAuthenticationToken;
 20  
 
 21  
 
 22  
 /**
 23  
  * Basic implementation of {@link AuthenticationTrustResolver}.<p>Makes trust decisions based on whether the passed
 24  
  * <code>Authentication</code> is an instance of a defined class.</p>
 25  
  *  <p>If {@link #anonymousClass} or {@link #rememberMeClass} is <code>null</code>, the corresponding method will
 26  
  * always return <code>false</code>.</p>
 27  
  *
 28  
  * @author Ben Alex
 29  
  * @version $Id: AuthenticationTrustResolverImpl.java 1496 2006-05-23 13:38:33Z benalex $
 30  
  */
 31  27
 public class AuthenticationTrustResolverImpl implements AuthenticationTrustResolver {
 32  
     //~ Instance fields ================================================================================================
 33  
 
 34  29
     private Class anonymousClass = AnonymousAuthenticationToken.class;
 35  27
     private Class rememberMeClass = RememberMeAuthenticationToken.class;
 36  
 
 37  
     //~ Methods ========================================================================================================
 38  
 
 39  
     public Class getAnonymousClass() {
 40  2
         return anonymousClass;
 41  
     }
 42  
 
 43  
     public Class getRememberMeClass() {
 44  2
         return rememberMeClass;
 45  
     }
 46  
 
 47  
     public boolean isAnonymous(Authentication authentication) {
 48  32
         if ((anonymousClass == null) || (authentication == null)) {
 49  4
             return false;
 50  
         }
 51  
 
 52  28
         return anonymousClass.isAssignableFrom(authentication.getClass());
 53  
     }
 54  
 
 55  
     public boolean isRememberMe(Authentication authentication) {
 56  10
         if ((rememberMeClass == null) || (authentication == null)) {
 57  0
             return false;
 58  
         }
 59  
 
 60  10
         return rememberMeClass.isAssignableFrom(authentication.getClass());
 61  
     }
 62  
 
 63  
     public void setAnonymousClass(Class anonymousClass) {
 64  1
         this.anonymousClass = anonymousClass;
 65  1
     }
 66  
 
 67  
     public void setRememberMeClass(Class rememberMeClass) {
 68  1
         this.rememberMeClass = rememberMeClass;
 69  1
     }
 70  
 }