Coverage Report - org.acegisecurity.runas.RunAsUserToken
 
Classes in this File Line Coverage Branch Coverage Complexity
RunAsUserToken
100% 
N/A 
1
 
 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.runas;
 17  
 
 18  
 import org.acegisecurity.GrantedAuthority;
 19  
 
 20  
 import org.acegisecurity.providers.AbstractAuthenticationToken;
 21  
 
 22  
 
 23  
 /**
 24  
  * An immutable {@link org.acegisecurity.Authentication}  implementation that supports {@link RunAsManagerImpl}.
 25  
  *
 26  
  * @author Ben Alex
 27  
  * @version $Id: RunAsUserToken.java 1784 2007-02-24 21:00:24Z luke_t $
 28  
  */
 29  
 public class RunAsUserToken extends AbstractAuthenticationToken {
 30  
     //~ Instance fields ================================================================================================
 31  
 
 32  
     private static final long serialVersionUID = 1L;
 33  
     private Class originalAuthentication;
 34  
     private Object credentials;
 35  
     private Object principal;
 36  
     private int keyHash;
 37  
 
 38  
     //~ Constructors ===================================================================================================
 39  
 
 40  
     public RunAsUserToken(String key, Object principal, Object credentials, GrantedAuthority[] authorities,
 41  
         Class originalAuthentication) {
 42  7
         super(authorities);
 43  7
         this.keyHash = key.hashCode();
 44  7
         this.principal = principal;
 45  7
         this.credentials = credentials;
 46  7
         this.originalAuthentication = originalAuthentication;
 47  7
         setAuthenticated(true);
 48  7
     }
 49  
 
 50  
     //~ Methods ========================================================================================================
 51  
 
 52  
     public Object getCredentials() {
 53  5
         return this.credentials;
 54  
     }
 55  
 
 56  
     public int getKeyHash() {
 57  6
         return this.keyHash;
 58  
     }
 59  
 
 60  
     public Class getOriginalAuthentication() {
 61  1
         return this.originalAuthentication;
 62  
     }
 63  
 
 64  
     public Object getPrincipal() {
 65  6
         return this.principal;
 66  
     }
 67  
 
 68  
     public String toString() {
 69  1
         StringBuffer sb = new StringBuffer(super.toString());
 70  1
         sb.append("; Original Class: ").append(this.originalAuthentication.getName());
 71  
 
 72  1
         return sb.toString();
 73  
     }
 74  
 }