1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
29
30
31
32
33 public class DefaultWebSessionContext extends DefaultSessionContext implements WebSessionContext {
34
35 private static final long serialVersionUID = -3974604687792523072L;
36
37 private static final String SERVLET_REQUEST = DefaultWebSessionContext.class.getName() + ".SERVLET_REQUEST";
38 private static final String SERVLET_RESPONSE = DefaultWebSessionContext.class.getName() + ".SERVLET_RESPONSE";
39
40 public DefaultWebSessionContext() {
41 super();
42 }
43
44 public DefaultWebSessionContext(Map<String, Object> map) {
45 super(map);
46 }
47
48 public void setServletRequest(ServletRequest request) {
49 if (request != null) {
50 put(SERVLET_REQUEST, request);
51 }
52 }
53
54 public ServletRequest getServletRequest() {
55 return getTypedValue(SERVLET_REQUEST, ServletRequest.class);
56 }
57
58 public void setServletResponse(ServletResponse response) {
59 if (response != null) {
60 put(SERVLET_RESPONSE, response);
61 }
62 }
63
64 public ServletResponse getServletResponse() {
65 return getTypedValue(SERVLET_RESPONSE, ServletResponse.class);
66 }
67 }