1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.apache.shiro.web.session.mgt; |
17 | |
|
18 | |
import org.apache.shiro.session.mgt.DefaultSessionKey; |
19 | |
import org.apache.shiro.web.util.RequestPairSource; |
20 | |
|
21 | |
import javax.servlet.ServletRequest; |
22 | |
import javax.servlet.ServletResponse; |
23 | |
import java.io.Serializable; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class WebSessionKey extends DefaultSessionKey implements RequestPairSource { |
33 | |
|
34 | |
private final ServletRequest servletRequest; |
35 | |
private final ServletResponse servletResponse; |
36 | |
|
37 | 11 | public WebSessionKey(ServletRequest request, ServletResponse response) { |
38 | 11 | if (request == null) { |
39 | 0 | throw new NullPointerException("request argument cannot be null."); |
40 | |
} |
41 | 11 | if (response == null) { |
42 | 0 | throw new NullPointerException("response argument cannot be null."); |
43 | |
} |
44 | 11 | this.servletRequest = request; |
45 | 11 | this.servletResponse = response; |
46 | 11 | } |
47 | |
|
48 | |
public WebSessionKey(Serializable sessionId, ServletRequest request, ServletResponse response) { |
49 | 9 | this(request, response); |
50 | 9 | setSessionId(sessionId); |
51 | 9 | } |
52 | |
|
53 | |
public ServletRequest getServletRequest() { |
54 | 19 | return servletRequest; |
55 | |
} |
56 | |
|
57 | |
public ServletResponse getServletResponse() { |
58 | 16 | return servletResponse; |
59 | |
} |
60 | |
} |