1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package com.xpn.xwiki.web; |
21 |
|
|
22 |
|
import java.io.IOException; |
23 |
|
import java.io.PrintWriter; |
24 |
|
import java.util.Collection; |
25 |
|
import java.util.Locale; |
26 |
|
|
27 |
|
import javax.servlet.ServletOutputStream; |
28 |
|
import javax.servlet.http.Cookie; |
29 |
|
import javax.servlet.http.HttpServletResponse; |
30 |
|
|
31 |
|
import org.apache.commons.lang3.StringUtils; |
32 |
|
import org.slf4j.Logger; |
33 |
|
import org.slf4j.LoggerFactory; |
34 |
|
|
|
|
| 41.7% |
Uncovered Elements: 60 (103) |
Complexity: 43 |
Complexity Density: 0.75 |
|
35 |
|
public class XWikiServletResponse implements XWikiResponse |
36 |
|
{ |
37 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(XWikiServletResponse.class); |
38 |
|
|
39 |
|
private HttpServletResponse response; |
40 |
|
|
41 |
|
|
42 |
|
@link |
43 |
|
|
44 |
|
private int httpStatus; |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
18576 |
public XWikiServletResponse(HttpServletResponse response)... |
47 |
|
{ |
48 |
18574 |
this.response = response; |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@return |
57 |
|
@since |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
59 |
13846 |
public int getStatus()... |
60 |
|
{ |
61 |
13846 |
return this.httpStatus; |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
0 |
@Override... |
65 |
|
public HttpServletResponse getHttpServletResponse() |
66 |
|
{ |
67 |
0 |
return this.response; |
68 |
|
} |
69 |
|
|
|
|
| 54.5% |
Uncovered Elements: 5 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
70 |
375 |
@Override... |
71 |
|
public void sendRedirect(String redirect) throws IOException |
72 |
|
{ |
73 |
375 |
if (StringUtils.isBlank(redirect)) { |
74 |
|
|
75 |
0 |
return; |
76 |
|
} |
77 |
375 |
if (StringUtils.containsAny(redirect, '\r', '\n')) { |
78 |
0 |
LOGGER.warn("Possible HTTP Response Splitting attack, attempting to redirect to [{}]", redirect); |
79 |
0 |
return; |
80 |
|
} |
81 |
375 |
this.httpStatus = SC_FOUND; |
82 |
375 |
this.response.sendRedirect(redirect); |
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
14332 |
@Override... |
86 |
|
public void setContentType(String type) |
87 |
|
{ |
88 |
14332 |
this.response.setContentType(type); |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
91 |
0 |
@Override... |
92 |
|
public void setBufferSize(int i) |
93 |
|
{ |
94 |
0 |
this.response.setBufferSize(i); |
95 |
|
} |
96 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
97 |
0 |
@Override... |
98 |
|
public int getBufferSize() |
99 |
|
{ |
100 |
0 |
return this.response.getBufferSize(); |
101 |
|
} |
102 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
103 |
0 |
@Override... |
104 |
|
public void flushBuffer() throws IOException |
105 |
|
{ |
106 |
0 |
this.response.flushBuffer(); |
107 |
|
} |
108 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
0 |
@Override... |
110 |
|
public void resetBuffer() |
111 |
|
{ |
112 |
0 |
this.response.resetBuffer(); |
113 |
|
} |
114 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
115 |
0 |
@Override... |
116 |
|
public boolean isCommitted() |
117 |
|
{ |
118 |
0 |
return this.response.isCommitted(); |
119 |
|
} |
120 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
0 |
@Override... |
122 |
|
public void reset() |
123 |
|
{ |
124 |
0 |
this.response.reset(); |
125 |
|
} |
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
127 |
9176 |
@Override... |
128 |
|
public void setContentLength(int length) |
129 |
|
{ |
130 |
9177 |
this.response.setContentLength(length); |
131 |
|
} |
132 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
133 |
0 |
@Override... |
134 |
|
public String getCharacterEncoding() |
135 |
|
{ |
136 |
0 |
return this.response.getCharacterEncoding(); |
137 |
|
} |
138 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
139 |
15790 |
@Override... |
140 |
|
public ServletOutputStream getOutputStream() throws IOException |
141 |
|
{ |
142 |
15790 |
return this.response.getOutputStream(); |
143 |
|
} |
144 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
145 |
9640 |
@Override... |
146 |
|
public PrintWriter getWriter() throws IOException |
147 |
|
{ |
148 |
9642 |
return this.response.getWriter(); |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
1010 |
@Override... |
152 |
|
public void setCharacterEncoding(String s) |
153 |
|
{ |
154 |
1010 |
this.response.setCharacterEncoding(s); |
155 |
|
} |
156 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
157 |
1061 |
@Override... |
158 |
|
public void addCookie(Cookie cookie) |
159 |
|
{ |
160 |
1061 |
this.response.addCookie(cookie); |
161 |
|
} |
162 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
163 |
0 |
public void addCookie(String cookieName, String cookieValue, int age)... |
164 |
|
{ |
165 |
0 |
Cookie cookie = new Cookie(cookieName, cookieValue); |
166 |
0 |
cookie.setVersion(1); |
167 |
0 |
cookie.setMaxAge(age); |
168 |
0 |
this.response.addCookie(cookie); |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
174 |
|
@param |
175 |
|
@param |
176 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
177 |
0 |
@Override... |
178 |
|
public void removeCookie(String cookieName, XWikiRequest request) |
179 |
|
{ |
180 |
0 |
Cookie cookie = request.getCookie(cookieName); |
181 |
0 |
if (cookie != null) { |
182 |
0 |
cookie.setMaxAge(0); |
183 |
0 |
cookie.setPath(cookie.getPath()); |
184 |
0 |
addCookie(cookie); |
185 |
|
} |
186 |
|
} |
187 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
188 |
11447 |
@Override... |
189 |
|
public void setLocale(Locale locale) |
190 |
|
{ |
191 |
11442 |
this.response.setLocale(locale); |
192 |
|
} |
193 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
194 |
0 |
@Override... |
195 |
|
public Locale getLocale() |
196 |
|
{ |
197 |
0 |
return this.response.getLocale(); |
198 |
|
} |
199 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
200 |
9968 |
@Override... |
201 |
|
public void setDateHeader(String name, long value) |
202 |
|
{ |
203 |
9968 |
this.response.setDateHeader(name, value); |
204 |
|
} |
205 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
206 |
0 |
@Override... |
207 |
|
public void setIntHeader(String name, int value) |
208 |
|
{ |
209 |
0 |
this.response.setIntHeader(name, value); |
210 |
|
} |
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
21339 |
@Override... |
213 |
|
public void setHeader(String name, String value) |
214 |
|
{ |
215 |
21339 |
this.response.setHeader(name, value); |
216 |
|
} |
217 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
218 |
289 |
@Override... |
219 |
|
public void addHeader(String name, String value) |
220 |
|
{ |
221 |
289 |
this.response.addHeader(name, value); |
222 |
|
} |
223 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
224 |
0 |
@Override... |
225 |
|
public void addDateHeader(String name, long value) |
226 |
|
{ |
227 |
0 |
this.response.addDateHeader(name, value); |
228 |
|
} |
229 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
230 |
0 |
@Override... |
231 |
|
public void addIntHeader(String name, int value) |
232 |
|
{ |
233 |
0 |
this.response.addIntHeader(name, value); |
234 |
|
} |
235 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
236 |
1105 |
@Override... |
237 |
|
public void setStatus(int i) |
238 |
|
{ |
239 |
1106 |
this.response.setStatus(i); |
240 |
1101 |
this.httpStatus = i; |
241 |
|
} |
242 |
|
|
243 |
|
|
244 |
|
@deprecated |
245 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
246 |
2 |
@Override... |
247 |
|
@Deprecated |
248 |
|
public void setStatus(int i, String s) |
249 |
|
{ |
250 |
2 |
this.response.setStatus(i, s); |
251 |
2 |
this.httpStatus = i; |
252 |
|
} |
253 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
254 |
5 |
@Override... |
255 |
|
public boolean containsHeader(String name) |
256 |
|
{ |
257 |
5 |
return this.response.containsHeader(name); |
258 |
|
} |
259 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
260 |
142285 |
@Override... |
261 |
|
public String encodeURL(String s) |
262 |
|
{ |
263 |
142280 |
return this.response.encodeURL(s); |
264 |
|
} |
265 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
266 |
345 |
@Override... |
267 |
|
public String encodeRedirectURL(String s) |
268 |
|
{ |
269 |
345 |
return this.response.encodeRedirectURL(s); |
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
|
@deprecated |
274 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
275 |
0 |
@Override... |
276 |
|
@Deprecated |
277 |
|
public String encodeUrl(String s) |
278 |
|
{ |
279 |
0 |
return this.response.encodeUrl(s); |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
|
@deprecated |
284 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
285 |
0 |
@Override... |
286 |
|
@Deprecated |
287 |
|
public String encodeRedirectUrl(String s) |
288 |
|
{ |
289 |
0 |
return this.response.encodeRedirectUrl(s); |
290 |
|
} |
291 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
292 |
0 |
@Override... |
293 |
|
public void sendError(int i, String s) throws IOException |
294 |
|
{ |
295 |
0 |
this.httpStatus = i; |
296 |
0 |
this.response.sendError(i, s); |
297 |
|
} |
298 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
299 |
0 |
@Override... |
300 |
|
public void sendError(int i) throws IOException |
301 |
|
{ |
302 |
0 |
this.httpStatus = i; |
303 |
0 |
this.response.sendError(i); |
304 |
|
} |
305 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
306 |
0 |
@Override... |
307 |
|
public String getContentType() |
308 |
|
{ |
309 |
0 |
return this.response.getContentType(); |
310 |
|
} |
311 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
312 |
0 |
@Override... |
313 |
|
public String getHeader(String s) |
314 |
|
{ |
315 |
0 |
return this.response.getHeader(s); |
316 |
|
} |
317 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
318 |
0 |
@Override... |
319 |
|
public Collection<String> getHeaders(String s) |
320 |
|
{ |
321 |
0 |
return this.response.getHeaders(s); |
322 |
|
} |
323 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
324 |
0 |
@Override... |
325 |
|
public Collection<String> getHeaderNames() |
326 |
|
{ |
327 |
0 |
return this.response.getHeaderNames(); |
328 |
|
} |
329 |
|
} |