Coverage Report - org.apache.shiro.web.session.mgt.DefaultWebSessionContext
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultWebSessionContext
85%
12/14
50%
2/4
1.333
 
 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.web.session.mgt;
 20  
 
 21  
 import org.apache.shiro.session.mgt.DefaultSessionContext;
 22  
 
 23  
 import javax.servlet.ServletRequest;
 24  
 import javax.servlet.ServletResponse;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * Default implementation of the {@link WebSessionContext} interface which provides getters and setters that
 29  
  * wrap interaction with the underlying backing context map.
 30  
  *
 31  
  * @since 1.0
 32  
  */
 33  
 public class DefaultWebSessionContext extends DefaultSessionContext implements WebSessionContext {
 34  
 
 35  
     private static final long serialVersionUID = -3974604687792523072L;
 36  
 
 37  1
     private static final String SERVLET_REQUEST = DefaultWebSessionContext.class.getName() + ".SERVLET_REQUEST";
 38  1
     private static final String SERVLET_RESPONSE = DefaultWebSessionContext.class.getName() + ".SERVLET_RESPONSE";
 39  
 
 40  
     public DefaultWebSessionContext() {
 41  7
         super();
 42  7
     }
 43  
 
 44  
     public DefaultWebSessionContext(Map<String, Object> map) {
 45  0
         super(map);
 46  0
     }
 47  
 
 48  
     public void setServletRequest(ServletRequest request) {
 49  7
         if (request != null) {
 50  7
             put(SERVLET_REQUEST, request);
 51  
         }
 52  7
     }
 53  
 
 54  
     public ServletRequest getServletRequest() {
 55  21
         return getTypedValue(SERVLET_REQUEST, ServletRequest.class);
 56  
     }
 57  
 
 58  
     public void setServletResponse(ServletResponse response) {
 59  7
         if (response != null) {
 60  7
             put(SERVLET_RESPONSE, response);
 61  
         }
 62  7
     }
 63  
 
 64  
     public ServletResponse getServletResponse() {
 65  18
         return getTypedValue(SERVLET_RESPONSE, ServletResponse.class);
 66  
     }
 67  
 }