Coverage Report - org.apache.shiro.session.ProxiedSession
 
Classes in this File Line Coverage Branch Coverage Complexity
ProxiedSession
66%
14/21
50%
1/2
1.154
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.shiro.session;
 20  
 
 21  
 import java.io.Serializable;
 22  
 import java.util.Collection;
 23  
 import java.util.Date;
 24  
 
 25  
 /**
 26  
  * Simple <code>Session</code> implementation that immediately delegates all corresponding calls to an
 27  
  * underlying proxied session instance.
 28  
  * <p/>
 29  
  * This class is mostly useful for framework subclassing to intercept certain <code>Session</code> calls
 30  
  * and perform additional logic.
 31  
  *
 32  
  * @since 0.9
 33  
  */
 34  
 public class ProxiedSession implements Session {
 35  
 
 36  
     /**
 37  
      * The proxied instance
 38  
      */
 39  
     protected final Session delegate;
 40  
 
 41  
     /**
 42  
      * Constructs an instance that proxies the specified <code>target</code>.  Subclasses may access this
 43  
      * target via the <code>protected final 'delegate'</code> attribute, i.e. <code>this.delegate</code>.
 44  
      *
 45  
      * @param target the specified target <code>Session</code> to proxy.
 46  
      */
 47  56
     public ProxiedSession(Session target) {
 48  56
         if (target == null) {
 49  0
             throw new IllegalArgumentException("Target session to proxy cannot be null.");
 50  
         }
 51  56
         delegate = target;
 52  56
     }
 53  
 
 54  
     /**
 55  
      * Immediately delegates to the underlying proxied session.
 56  
      */
 57  
     public Serializable getId() {
 58  283
         return delegate.getId();
 59  
     }
 60  
 
 61  
     /**
 62  
      * Immediately delegates to the underlying proxied session.
 63  
      */
 64  
     public Date getStartTimestamp() {
 65  0
         return delegate.getStartTimestamp();
 66  
     }
 67  
 
 68  
     /**
 69  
      * Immediately delegates to the underlying proxied session.
 70  
      */
 71  
     public Date getLastAccessTime() {
 72  0
         return delegate.getLastAccessTime();
 73  
     }
 74  
 
 75  
     /**
 76  
      * Immediately delegates to the underlying proxied session.
 77  
      */
 78  
     public long getTimeout() throws InvalidSessionException {
 79  0
         return delegate.getTimeout();
 80  
     }
 81  
 
 82  
     /**
 83  
      * Immediately delegates to the underlying proxied session.
 84  
      */
 85  
     public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException {
 86  2
         delegate.setTimeout(maxIdleTimeInMillis);
 87  1
     }
 88  
 
 89  
     /**
 90  
      * Immediately delegates to the underlying proxied session.
 91  
      */
 92  
     public String getHost() {
 93  0
         return delegate.getHost();
 94  
     }
 95  
 
 96  
     /**
 97  
      * Immediately delegates to the underlying proxied session.
 98  
      */
 99  
     public void touch() throws InvalidSessionException {
 100  0
         delegate.touch();
 101  0
     }
 102  
 
 103  
     /**
 104  
      * Immediately delegates to the underlying proxied session.
 105  
      */
 106  
     public void stop() throws InvalidSessionException {
 107  18
         delegate.stop();
 108  18
     }
 109  
 
 110  
     /**
 111  
      * Immediately delegates to the underlying proxied session.
 112  
      */
 113  
     public Collection<Object> getAttributeKeys() throws InvalidSessionException {
 114  1
         return delegate.getAttributeKeys();
 115  
     }
 116  
 
 117  
     /**
 118  
      * Immediately delegates to the underlying proxied session.
 119  
      */
 120  
     public Object getAttribute(Object key) throws InvalidSessionException {
 121  196
         return delegate.getAttribute(key);
 122  
     }
 123  
 
 124  
     /**
 125  
      * Immediately delegates to the underlying proxied session.
 126  
      */
 127  
     public void setAttribute(Object key, Object value) throws InvalidSessionException {
 128  51
         delegate.setAttribute(key, value);
 129  51
     }
 130  
 
 131  
     /**
 132  
      * Immediately delegates to the underlying proxied session.
 133  
      */
 134  
     public Object removeAttribute(Object key) throws InvalidSessionException {
 135  53
         return delegate.removeAttribute(key);
 136  
     }
 137  
 
 138  
 }