Coverage Report - org.apache.shiro.session.mgt.DefaultSessionContext
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultSessionContext
61%
8/13
50%
1/2
1.167
 
 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.mgt;
 20  
 
 21  
 import org.apache.shiro.util.MapContext;
 22  
 import org.apache.shiro.util.StringUtils;
 23  
 
 24  
 import java.io.Serializable;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * Default implementation of the {@link SessionContext} 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 DefaultSessionContext extends MapContext implements SessionContext {
 34  
 
 35  
     private static final long serialVersionUID = -1424160751361252966L;
 36  
 
 37  1
     private static final String HOST = DefaultSessionContext.class.getName() + ".HOST";
 38  1
     private static final String SESSION_ID = DefaultSessionContext.class.getName() + ".SESSION_ID";
 39  
 
 40  
     public DefaultSessionContext() {
 41  20
         super();
 42  20
     }
 43  
 
 44  
     public DefaultSessionContext(Map<String, Object> map) {
 45  0
         super(map);
 46  0
     }
 47  
 
 48  
     public String getHost() {
 49  20
         return getTypedValue(HOST, String.class);
 50  
     }
 51  
 
 52  
     public void setHost(String host) {
 53  1
         if (StringUtils.hasText(host)) {
 54  1
             put(HOST, host);
 55  
         }
 56  1
     }
 57  
 
 58  
     public Serializable getSessionId() {
 59  0
         return getTypedValue(SESSION_ID, Serializable.class);
 60  
     }
 61  
 
 62  
     public void setSessionId(Serializable sessionId) {
 63  0
         nullSafePut(SESSION_ID, sessionId);
 64  0
     }
 65  
 }