/projects/tomcat-7.0.2/java/javax/servlet/http/HttpServletRequestWrapper.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus · Java · 296 lines · 109 code · 35 blank · 152 comment · 0 complexity · 4cb9dbce90e1fdde52a2cdb9eb8d33bd MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package javax.servlet.http;
  18. import javax.servlet.ServletException;
  19. import javax.servlet.ServletRequestWrapper;
  20. import java.io.IOException;
  21. import java.util.Collection;
  22. import java.util.Enumeration;
  23. /**
  24. * Provides a convenient implementation of the HttpServletRequest interface that
  25. * can be subclassed by developers wishing to adapt the request to a Servlet.
  26. * This class implements the Wrapper or Decorator pattern. Methods default to
  27. * calling through to the wrapped request object.
  28. *
  29. * @see javax.servlet.http.HttpServletRequest
  30. * @since v 2.3
  31. */
  32. public class HttpServletRequestWrapper extends ServletRequestWrapper implements
  33. HttpServletRequest {
  34. /**
  35. * Constructs a request object wrapping the given request.
  36. *
  37. * @throws java.lang.IllegalArgumentException
  38. * if the request is null
  39. */
  40. public HttpServletRequestWrapper(HttpServletRequest request) {
  41. super(request);
  42. }
  43. private HttpServletRequest _getHttpServletRequest() {
  44. return (HttpServletRequest) super.getRequest();
  45. }
  46. /**
  47. * The default behavior of this method is to return getAuthType() on the
  48. * wrapped request object.
  49. */
  50. public String getAuthType() {
  51. return this._getHttpServletRequest().getAuthType();
  52. }
  53. /**
  54. * The default behavior of this method is to return getCookies() on the
  55. * wrapped request object.
  56. */
  57. public Cookie[] getCookies() {
  58. return this._getHttpServletRequest().getCookies();
  59. }
  60. /**
  61. * The default behavior of this method is to return getDateHeader(String
  62. * name) on the wrapped request object.
  63. */
  64. public long getDateHeader(String name) {
  65. return this._getHttpServletRequest().getDateHeader(name);
  66. }
  67. /**
  68. * The default behavior of this method is to return getHeader(String name)
  69. * on the wrapped request object.
  70. */
  71. public String getHeader(String name) {
  72. return this._getHttpServletRequest().getHeader(name);
  73. }
  74. /**
  75. * The default behavior of this method is to return getHeaders(String name)
  76. * on the wrapped request object.
  77. */
  78. public Enumeration<String> getHeaders(String name) {
  79. return this._getHttpServletRequest().getHeaders(name);
  80. }
  81. /**
  82. * The default behavior of this method is to return getHeaderNames() on the
  83. * wrapped request object.
  84. */
  85. public Enumeration<String> getHeaderNames() {
  86. return this._getHttpServletRequest().getHeaderNames();
  87. }
  88. /**
  89. * The default behavior of this method is to return getIntHeader(String
  90. * name) on the wrapped request object.
  91. */
  92. public int getIntHeader(String name) {
  93. return this._getHttpServletRequest().getIntHeader(name);
  94. }
  95. /**
  96. * The default behavior of this method is to return getMethod() on the
  97. * wrapped request object.
  98. */
  99. public String getMethod() {
  100. return this._getHttpServletRequest().getMethod();
  101. }
  102. /**
  103. * The default behavior of this method is to return getPathInfo() on the
  104. * wrapped request object.
  105. */
  106. public String getPathInfo() {
  107. return this._getHttpServletRequest().getPathInfo();
  108. }
  109. /**
  110. * The default behavior of this method is to return getPathTranslated() on
  111. * the wrapped request object.
  112. */
  113. public String getPathTranslated() {
  114. return this._getHttpServletRequest().getPathTranslated();
  115. }
  116. /**
  117. * The default behavior of this method is to return getContextPath() on the
  118. * wrapped request object.
  119. */
  120. public String getContextPath() {
  121. return this._getHttpServletRequest().getContextPath();
  122. }
  123. /**
  124. * The default behavior of this method is to return getQueryString() on the
  125. * wrapped request object.
  126. */
  127. public String getQueryString() {
  128. return this._getHttpServletRequest().getQueryString();
  129. }
  130. /**
  131. * The default behavior of this method is to return getRemoteUser() on the
  132. * wrapped request object.
  133. */
  134. public String getRemoteUser() {
  135. return this._getHttpServletRequest().getRemoteUser();
  136. }
  137. /**
  138. * The default behavior of this method is to return isUserInRole(String
  139. * role) on the wrapped request object.
  140. */
  141. public boolean isUserInRole(String role) {
  142. return this._getHttpServletRequest().isUserInRole(role);
  143. }
  144. /**
  145. * The default behavior of this method is to return getUserPrincipal() on
  146. * the wrapped request object.
  147. */
  148. public java.security.Principal getUserPrincipal() {
  149. return this._getHttpServletRequest().getUserPrincipal();
  150. }
  151. /**
  152. * The default behavior of this method is to return getRequestedSessionId()
  153. * on the wrapped request object.
  154. */
  155. public String getRequestedSessionId() {
  156. return this._getHttpServletRequest().getRequestedSessionId();
  157. }
  158. /**
  159. * The default behavior of this method is to return getRequestURI() on the
  160. * wrapped request object.
  161. */
  162. public String getRequestURI() {
  163. return this._getHttpServletRequest().getRequestURI();
  164. }
  165. /**
  166. * The default behavior of this method is to return getRequestURL() on the
  167. * wrapped request object.
  168. */
  169. public StringBuffer getRequestURL() {
  170. return this._getHttpServletRequest().getRequestURL();
  171. }
  172. /**
  173. * The default behavior of this method is to return getServletPath() on the
  174. * wrapped request object.
  175. */
  176. public String getServletPath() {
  177. return this._getHttpServletRequest().getServletPath();
  178. }
  179. /**
  180. * The default behavior of this method is to return getSession(boolean
  181. * create) on the wrapped request object.
  182. */
  183. public HttpSession getSession(boolean create) {
  184. return this._getHttpServletRequest().getSession(create);
  185. }
  186. /**
  187. * The default behavior of this method is to return getSession() on the
  188. * wrapped request object.
  189. */
  190. public HttpSession getSession() {
  191. return this._getHttpServletRequest().getSession();
  192. }
  193. /**
  194. * The default behavior of this method is to return
  195. * isRequestedSessionIdValid() on the wrapped request object.
  196. */
  197. public boolean isRequestedSessionIdValid() {
  198. return this._getHttpServletRequest().isRequestedSessionIdValid();
  199. }
  200. /**
  201. * The default behavior of this method is to return
  202. * isRequestedSessionIdFromCookie() on the wrapped request object.
  203. */
  204. public boolean isRequestedSessionIdFromCookie() {
  205. return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
  206. }
  207. /**
  208. * The default behavior of this method is to return
  209. * isRequestedSessionIdFromURL() on the wrapped request object.
  210. */
  211. public boolean isRequestedSessionIdFromURL() {
  212. return this._getHttpServletRequest().isRequestedSessionIdFromURL();
  213. }
  214. /**
  215. * The default behavior of this method is to return
  216. * isRequestedSessionIdFromUrl() on the wrapped request object.
  217. *
  218. * @deprecated As of Version 3.0 of the Java Servlet API
  219. */
  220. @SuppressWarnings("dep-ann")
  221. // Spec API does not use @Deprecated
  222. public boolean isRequestedSessionIdFromUrl() {
  223. return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
  224. }
  225. /**
  226. * @since Servlet 3.0 TODO SERVLET3 - Add comments
  227. */
  228. public boolean authenticate(HttpServletResponse response)
  229. throws IOException, ServletException {
  230. return this._getHttpServletRequest().authenticate(response);
  231. }
  232. /**
  233. * @since Servlet 3.0 TODO SERVLET3 - Add comments
  234. */
  235. public void login(String username, String password) throws ServletException {
  236. this._getHttpServletRequest().login(username, password);
  237. }
  238. /**
  239. * @since Servlet 3.0 TODO SERVLET3 - Add comments
  240. */
  241. public void logout() throws ServletException {
  242. this._getHttpServletRequest().logout();
  243. }
  244. /**
  245. * @since Servlet 3.0 TODO SERVLET3 - Add comments
  246. */
  247. public Collection<Part> getParts() throws IllegalStateException,
  248. IOException, ServletException {
  249. return this._getHttpServletRequest().getParts();
  250. }
  251. /**
  252. * @throws ServletException
  253. * @throws IOException
  254. * @throws IllegalStateException
  255. * @since Servlet 3.0 TODO SERVLET3 - Add comments
  256. */
  257. public Part getPart(String name) throws IllegalStateException, IOException,
  258. ServletException {
  259. return this._getHttpServletRequest().getPart(name);
  260. }
  261. }