|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| package org.acegisecurity.intercept.web; |
|
17 |
| |
|
18 |
| import javax.servlet.FilterChain; |
|
19 |
| import javax.servlet.ServletRequest; |
|
20 |
| import javax.servlet.ServletResponse; |
|
21 |
| import javax.servlet.http.HttpServletRequest; |
|
22 |
| import javax.servlet.http.HttpServletResponse; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| public class FilterInvocation { |
|
44 |
| |
|
45 |
| |
|
46 |
| private FilterChain chain; |
|
47 |
| private ServletRequest request; |
|
48 |
| private ServletResponse response; |
|
49 |
| |
|
50 |
| |
|
51 |
| |
|
52 |
51
| public FilterInvocation(ServletRequest request, ServletResponse response,
|
|
53 |
| FilterChain chain) { |
|
54 |
51
| if ((request == null) || (response == null) || (chain == null)) {
|
|
55 |
3
| throw new IllegalArgumentException(
|
|
56 |
| "Cannot pass null values to constructor"); |
|
57 |
| } |
|
58 |
| |
|
59 |
48
| if (!(request instanceof HttpServletRequest)) {
|
|
60 |
1
| throw new IllegalArgumentException(
|
|
61 |
| "Can only process HttpServletRequest"); |
|
62 |
| } |
|
63 |
| |
|
64 |
47
| if (!(response instanceof HttpServletResponse)) {
|
|
65 |
1
| throw new IllegalArgumentException(
|
|
66 |
| "Can only process HttpServletResponse"); |
|
67 |
| } |
|
68 |
| |
|
69 |
46
| this.request = request;
|
|
70 |
46
| this.response = response;
|
|
71 |
46
| this.chain = chain;
|
|
72 |
| } |
|
73 |
| |
|
74 |
1
| protected FilterInvocation() {
|
|
75 |
1
| throw new IllegalArgumentException("Cannot use default constructor");
|
|
76 |
| } |
|
77 |
| |
|
78 |
| |
|
79 |
| |
|
80 |
5
| public FilterChain getChain() {
|
|
81 |
5
| return chain;
|
|
82 |
| } |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
| |
|
87 |
| |
|
88 |
| |
|
89 |
| |
|
90 |
| |
|
91 |
| |
|
92 |
| |
|
93 |
| |
|
94 |
3
| public String getFullRequestUrl() {
|
|
95 |
3
| return getHttpRequest().getScheme() + "://"
|
|
96 |
| + getHttpRequest().getServerName() + ":" |
|
97 |
| + getHttpRequest().getServerPort() + getHttpRequest().getContextPath() |
|
98 |
| + getRequestUrl(); |
|
99 |
| } |
|
100 |
| |
|
101 |
109
| public HttpServletRequest getHttpRequest() {
|
|
102 |
109
| return (HttpServletRequest) request;
|
|
103 |
| } |
|
104 |
| |
|
105 |
3
| public HttpServletResponse getHttpResponse() {
|
|
106 |
3
| return (HttpServletResponse) response;
|
|
107 |
| } |
|
108 |
| |
|
109 |
21
| public ServletRequest getRequest() {
|
|
110 |
21
| return request;
|
|
111 |
| } |
|
112 |
| |
|
113 |
29
| public String getRequestUrl() {
|
|
114 |
29
| String pathInfo = getHttpRequest().getPathInfo();
|
|
115 |
29
| String queryString = getHttpRequest().getQueryString();
|
|
116 |
| |
|
117 |
29
| String uri = getHttpRequest().getServletPath();
|
|
118 |
| |
|
119 |
29
| if (uri == null) {
|
|
120 |
0
| uri = getHttpRequest().getRequestURI();
|
|
121 |
0
| uri = uri.substring(getHttpRequest().getContextPath().length());
|
|
122 |
| } |
|
123 |
| |
|
124 |
29
| return uri + ((pathInfo == null) ? "" : pathInfo)
|
|
125 |
29
| + ((queryString == null) ? "" : ("?" + queryString));
|
|
126 |
| } |
|
127 |
| |
|
128 |
24
| public ServletResponse getResponse() {
|
|
129 |
24
| return response;
|
|
130 |
| } |
|
131 |
| |
|
132 |
3
| public String toString() {
|
|
133 |
3
| return "FilterInvocation: URL: " + getRequestUrl();
|
|
134 |
| } |
|
135 |
| } |