| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>ImmutableProxiedSession.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Shiro :: Core</a> > <a href="index.source.html" class="el_package">org.apache.shiro.session.mgt</a> > <span class="el_source">ImmutableProxiedSession.java</span></div><h1>ImmutableProxiedSession.java</h1><pre class="source lang-java linenums">/* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| package org.apache.shiro.session.mgt; |
| |
| import org.apache.shiro.session.InvalidSessionException; |
| import org.apache.shiro.session.ProxiedSession; |
| import org.apache.shiro.session.Session; |
| |
| |
| /** |
| * Implementation of the {@link Session Session} interface that proxies another <code>Session</code>, but does not |
| * allow any 'write' operations to the underlying session. It allows 'read' operations only. |
| * <p/> |
| * The <code>Session</code> write operations are defined as follows. A call to any of these methods on this |
| * proxy will immediately result in an {@link InvalidSessionException} being thrown: |
| * <ul> |
| * <li>{@link Session#setTimeout(long) Session.setTimeout(long)}</li> |
| * <li>{@link Session#touch() Session.touch()}</li> |
| * <li>{@link Session#stop() Session.stop()}</li> |
| * <li>{@link Session#setAttribute(Object, Object) Session.setAttribute(key,value)}</li> |
| * <li>{@link Session#removeAttribute(Object) Session.removeAttribute(key)}</li> |
| * </ul> |
| * Any other method invocation not listed above will result in a corresponding call to the underlying <code>Session</code>. |
| * |
| * @since 0.9 |
| */ |
| public class ImmutableProxiedSession extends ProxiedSession { |
| |
| /** |
| * Constructs a new instance of this class proxying the specified <code>Session</code>. |
| * |
| * @param target the target <code>Session</code> to proxy. |
| */ |
| public ImmutableProxiedSession(Session target) { |
| <span class="fc" id="L51"> super(target);</span> |
| <span class="fc" id="L52"> }</span> |
| |
| /** |
| * Simply throws an <code>InvalidSessionException</code> indicating that this proxy is immutable. Used |
| * only in the Session's 'write' methods documented in the top class-level JavaDoc. |
| * |
| * @throws InvalidSessionException in all cases - used by the Session 'write' method implementations. |
| */ |
| protected void throwImmutableException() throws InvalidSessionException { |
| <span class="fc" id="L61"> String msg = "This session is immutable and read-only - it cannot be altered. This is usually because " +</span> |
| "the session has been stopped or expired already."; |
| <span class="fc" id="L63"> throw new InvalidSessionException(msg);</span> |
| } |
| |
| /** |
| * Immediately {@link #throwImmutableException() throws} an <code>InvalidSessionException</code> in all |
| * cases because this proxy is immutable. |
| */ |
| public void setTimeout(long maxIdleTimeInMillis) throws InvalidSessionException { |
| <span class="nc" id="L71"> throwImmutableException();</span> |
| <span class="nc" id="L72"> }</span> |
| |
| /** |
| * Immediately {@link #throwImmutableException() throws} an <code>InvalidSessionException</code> in all |
| * cases because this proxy is immutable. |
| */ |
| public void touch() throws InvalidSessionException { |
| <span class="nc" id="L79"> throwImmutableException();</span> |
| <span class="nc" id="L80"> }</span> |
| |
| /** |
| * Immediately {@link #throwImmutableException() throws} an <code>InvalidSessionException</code> in all |
| * cases because this proxy is immutable. |
| */ |
| public void stop() throws InvalidSessionException { |
| <span class="nc" id="L87"> throwImmutableException();</span> |
| <span class="nc" id="L88"> }</span> |
| |
| /** |
| * Immediately {@link #throwImmutableException() throws} an <code>InvalidSessionException</code> in all |
| * cases because this proxy is immutable. |
| */ |
| public void setAttribute(Object key, Object value) throws InvalidSessionException { |
| <span class="nc" id="L95"> throwImmutableException();</span> |
| <span class="nc" id="L96"> }</span> |
| |
| /** |
| * Immediately {@link #throwImmutableException() throws} an <code>InvalidSessionException</code> in all |
| * cases because this proxy is immutable. |
| */ |
| public Object removeAttribute(Object key) throws InvalidSessionException { |
| <span class="nc" id="L103"> throwImmutableException();</span> |
| //we should never ever reach this point due to the exception being thrown. |
| <span class="nc" id="L105"> throw new InternalError("This code should never execute - please report this as a bug!");</span> |
| } |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html> |