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: 92   Methods: 10
NCLOC: 50   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RunAsUserToken.java - 100% 100% 100%
coverage
 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.runas;
 17   
 18    import org.acegisecurity.GrantedAuthority;
 19    import org.acegisecurity.providers.AbstractAuthenticationToken;
 20   
 21   
 22    /**
 23    * An immutable {@link org.acegisecurity.Authentication} implementation
 24    * that supports {@link RunAsManagerImpl}.
 25    *
 26    * @author Ben Alex
 27    * @version $Id: RunAsUserToken.java,v 1.5 2005/11/17 00:55:51 benalex Exp $
 28    */
 29    public class RunAsUserToken extends AbstractAuthenticationToken {
 30    //~ Instance fields ========================================================
 31   
 32    private Class originalAuthentication;
 33    private Object credentials;
 34    private Object principal;
 35    private GrantedAuthority[] authorities;
 36    private int keyHash;
 37    private boolean authenticated;
 38   
 39    //~ Constructors ===========================================================
 40   
 41  7 public RunAsUserToken(String key, Object principal, Object credentials,
 42    GrantedAuthority[] authorities, Class originalAuthentication) {
 43  7 super();
 44  7 this.keyHash = key.hashCode();
 45  7 this.authorities = authorities;
 46  7 this.principal = principal;
 47  7 this.credentials = credentials;
 48  7 this.originalAuthentication = originalAuthentication;
 49  7 this.authenticated = true;
 50    }
 51   
 52  1 protected RunAsUserToken() {
 53  1 throw new IllegalArgumentException("Cannot use default constructor");
 54    }
 55   
 56    //~ Methods ================================================================
 57   
 58  1 public void setAuthenticated(boolean isAuthenticated) {
 59  1 this.authenticated = isAuthenticated;
 60    }
 61   
 62  3 public boolean isAuthenticated() {
 63  3 return this.authenticated;
 64    }
 65   
 66  12 public GrantedAuthority[] getAuthorities() {
 67  12 return this.authorities;
 68    }
 69   
 70  3 public Object getCredentials() {
 71  3 return this.credentials;
 72    }
 73   
 74  6 public int getKeyHash() {
 75  6 return this.keyHash;
 76    }
 77   
 78  1 public Class getOriginalAuthentication() {
 79  1 return this.originalAuthentication;
 80    }
 81   
 82  4 public Object getPrincipal() {
 83  4 return this.principal;
 84    }
 85   
 86  1 public String toString() {
 87  1 StringBuffer sb = new StringBuffer(super.toString());
 88  1 sb.append("; Original Class: " + this.originalAuthentication.getName());
 89   
 90  1 return sb.toString();
 91    }
 92    }