1 package com.atlassian.security.auth.trustedapps.filter;
2
3 import java.io.BufferedReader;
4 import java.io.IOException;
5 import java.io.UnsupportedEncodingException;
6 import java.security.Principal;
7 import java.util.Enumeration;
8 import java.util.Locale;
9 import java.util.Map;
10
11 import javax.servlet.RequestDispatcher;
12 import javax.servlet.ServletInputStream;
13 import javax.servlet.http.Cookie;
14 import javax.servlet.http.HttpServletRequest;
15 import javax.servlet.http.HttpSession;
16
17 public class ImmutableRequest
18 {
19 static HttpServletRequest wrap(final HttpServletRequest delegate)
20 {
21 return new HttpServletRequest()
22 {
23 final HttpServletRequest request = delegate;
24
25 public Object getAttribute(final String arg0)
26 {
27 return request.getAttribute(arg0);
28 }
29
30 @SuppressWarnings("unchecked")
31 public Enumeration getAttributeNames()
32 {
33 return request.getAttributeNames();
34 }
35
36 public String getAuthType()
37 {
38 return request.getAuthType();
39 }
40
41 public String getCharacterEncoding()
42 {
43 return request.getCharacterEncoding();
44 }
45
46 public int getContentLength()
47 {
48 return request.getContentLength();
49 }
50
51 public String getContentType()
52 {
53 return request.getContentType();
54 }
55
56 public String getContextPath()
57 {
58 return request.getContextPath();
59 }
60
61 public Cookie[] getCookies()
62 {
63 return request.getCookies();
64 }
65
66 public long getDateHeader(final String arg0)
67 {
68 return request.getDateHeader(arg0);
69 }
70
71 public String getHeader(final String arg0)
72 {
73 return request.getHeader(arg0);
74 }
75
76 @SuppressWarnings("unchecked")
77 public Enumeration getHeaderNames()
78 {
79 return request.getHeaderNames();
80 }
81
82 @SuppressWarnings("unchecked")
83 public Enumeration getHeaders(final String arg0)
84 {
85 return request.getHeaders(arg0);
86 }
87
88 public ServletInputStream getInputStream() throws IOException
89 {
90 return request.getInputStream();
91 }
92
93 public int getIntHeader(final String arg0)
94 {
95 return request.getIntHeader(arg0);
96 }
97
98 public Locale getLocale()
99 {
100 return request.getLocale();
101 }
102
103 @SuppressWarnings("unchecked")
104 public Enumeration getLocales()
105 {
106 return request.getLocales();
107 }
108
109 public String getMethod()
110 {
111 return request.getMethod();
112 }
113
114 public String getParameter(final String arg0)
115 {
116 return request.getParameter(arg0);
117 }
118
119 @SuppressWarnings("unchecked")
120 public Map getParameterMap()
121 {
122 return request.getParameterMap();
123 }
124
125 @SuppressWarnings("unchecked")
126 public Enumeration getParameterNames()
127 {
128 return request.getParameterNames();
129 }
130
131 public String[] getParameterValues(final String arg0)
132 {
133 return request.getParameterValues(arg0);
134 }
135
136 public String getPathInfo()
137 {
138 return request.getPathInfo();
139 }
140
141 public String getPathTranslated()
142 {
143 return request.getPathTranslated();
144 }
145
146 public String getProtocol()
147 {
148 return request.getProtocol();
149 }
150
151 public String getQueryString()
152 {
153 return request.getQueryString();
154 }
155
156 public BufferedReader getReader() throws IOException
157 {
158 return request.getReader();
159 }
160
161 @SuppressWarnings("deprecation")
162 public String getRealPath(final String arg0)
163 {
164 return request.getRealPath(arg0);
165 }
166
167 public String getRemoteAddr()
168 {
169 return request.getRemoteAddr();
170 }
171
172 public String getRemoteHost()
173 {
174 return request.getRemoteHost();
175 }
176
177 public String getRemoteUser()
178 {
179 return request.getRemoteUser();
180 }
181
182 public RequestDispatcher getRequestDispatcher(final String arg0)
183 {
184 return request.getRequestDispatcher(arg0);
185 }
186
187 public String getRequestedSessionId()
188 {
189 return request.getRequestedSessionId();
190 }
191
192 public String getRequestURI()
193 {
194 return request.getRequestURI();
195 }
196
197 public StringBuffer getRequestURL()
198 {
199 return request.getRequestURL();
200 }
201
202 public String getScheme()
203 {
204 return request.getScheme();
205 }
206
207 public String getServerName()
208 {
209 return request.getServerName();
210 }
211
212 public int getServerPort()
213 {
214 return request.getServerPort();
215 }
216
217 public String getServletPath()
218 {
219 return request.getServletPath();
220 }
221
222 public HttpSession getSession()
223 {
224 return request.getSession();
225 }
226
227 public HttpSession getSession(final boolean arg0)
228 {
229 return request.getSession(arg0);
230 }
231
232 public Principal getUserPrincipal()
233 {
234 return request.getUserPrincipal();
235 }
236
237 public boolean isRequestedSessionIdFromCookie()
238 {
239 return request.isRequestedSessionIdFromCookie();
240 }
241
242 @SuppressWarnings("deprecation")
243 public boolean isRequestedSessionIdFromUrl()
244 {
245 return request.isRequestedSessionIdFromUrl();
246 }
247
248 public boolean isRequestedSessionIdFromURL()
249 {
250 return request.isRequestedSessionIdFromURL();
251 }
252
253 public boolean isRequestedSessionIdValid()
254 {
255 return request.isRequestedSessionIdValid();
256 }
257
258 public boolean isSecure()
259 {
260 return request.isSecure();
261 }
262
263 public boolean isUserInRole(final String arg0)
264 {
265 return request.isUserInRole(arg0);
266 }
267
268 public void removeAttribute(final String arg0)
269 {
270 throw new UnsupportedOperationException();
271 }
272
273 public void setAttribute(final String arg0, final Object arg1)
274 {
275 throw new UnsupportedOperationException();
276 }
277
278 public void setCharacterEncoding(final String arg0) throws UnsupportedEncodingException
279 {
280 throw new UnsupportedOperationException();
281 }
282 };
283 }
284 }