Clover coverage report - Acegi Security System for Spring - 1.0.0-RC1
Coverage timestamp: Mon Dec 5 2005 09:05:15 EST
file stats: LOC: 80   Methods: 5
NCLOC: 43   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SecurityContextImpl.java 70% 88.9% 100% 84.8%
coverage coverage
 1    /* Copyright 2004, 2005 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    package org.acegisecurity.context;
 16   
 17    import org.acegisecurity.Authentication;
 18   
 19   
 20    /**
 21    * Base implementation of {@link SecurityContext}.
 22    *
 23    * <p>
 24    * Used by default by {@link SecurityContextHolder} and {@link HttpSessionContextIntegrationFilter}.
 25    * </p>
 26    *
 27    * @author Ben Alex
 28    * @version $Id: SecurityContextImpl.java,v 1.4 2005/11/17 00:55:49 benalex Exp $
 29    */
 30    public class SecurityContextImpl implements SecurityContext {
 31    private Authentication authentication;
 32   
 33  187 public void setAuthentication(Authentication authentication) {
 34  187 this.authentication = authentication;
 35    }
 36   
 37  207 public Authentication getAuthentication() {
 38  207 return authentication;
 39    }
 40   
 41  6 public boolean equals(Object obj) {
 42  6 if (obj instanceof SecurityContextImpl) {
 43  6 SecurityContextImpl test = (SecurityContextImpl) obj;
 44   
 45  6 if ((this.getAuthentication() == null) &&
 46    (test.getAuthentication() == null)) {
 47  5 return true;
 48    }
 49   
 50  1 if ((this.getAuthentication() != null) &&
 51    (test.getAuthentication() != null) &&
 52    this.getAuthentication().equals(test.getAuthentication())) {
 53  0 return true;
 54    }
 55    }
 56   
 57  1 return false;
 58    }
 59   
 60  2 public String toString() {
 61  2 StringBuffer sb = new StringBuffer();
 62  2 sb.append(super.toString());
 63   
 64  2 if (this.authentication == null) {
 65  0 sb.append(": Null authentication");
 66    } else {
 67  2 sb.append(": Authentication: " + this.authentication);
 68    }
 69   
 70  2 return sb.toString();
 71    }
 72   
 73  11 public int hashCode() {
 74  11 if (this.authentication == null) {
 75  3 return -1;
 76    } else {
 77  8 return this.authentication.hashCode();
 78    }
 79    }
 80    }