1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. * Copyright (c) 1999 The Apache Software Foundation. All rights
  5. * reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. *
  14. * 2. Redistributions in binary form must reproduce the above copyright
  15. * notice, this list of conditions and the following disclaimer in
  16. * the documentation and/or other materials provided with the
  17. * distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if
  20. * any, must include the following acknowlegement:
  21. * "This product includes software developed by the
  22. * Apache Software Foundation (http://www.apache.org/)."
  23. * Alternately, this acknowlegement may appear in the software itself,
  24. * if and wherever such third-party acknowlegements normally appear.
  25. *
  26. * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
  27. * Foundation" must not be used to endorse or promote products derived
  28. * from this software without prior written permission. For written
  29. * permission, please contact apache@apache.org.
  30. *
  31. * 5. Products derived from this software may not be called "Apache"
  32. * nor may "Apache" appear in their names without prior written
  33. * permission of the Apache Group.
  34. *
  35. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46. * SUCH DAMAGE.
  47. * ====================================================================
  48. *
  49. * This software consists of voluntary contributions made by many
  50. * individuals on behalf of the Apache Software Foundation. For more
  51. * information on the Apache Software Foundation, please see
  52. * <http://www.apache.org/>.
  53. *
  54. * ====================================================================
  55. *
  56. * This source code implements specifications defined by the Java
  57. * Community Process. In order to remain compliant with the specification
  58. * DO NOT add / change / or delete method signatures!
  59. */
  60. package javax.servlet.http;
  61. import javax.servlet.ServletRequestWrapper;
  62. import java.util.Enumeration;
  63. /**
  64. *
  65. * Provides a convenient implementation of the HttpServletRequest interface that
  66. * can be subclassed by developers wishing to adapt the request to a Servlet.
  67. * This class implements the Wrapper or Decorator pattern. Methods default to
  68. * calling through to the wrapped request object.
  69. *
  70. *
  71. * @see javax.servlet.http.HttpServletRequest
  72. * @since v 2.3
  73. *
  74. */
  75. public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest {
  76. /**
  77. * Constructs a request object wrapping the given request.
  78. * @throws java.lang.IllegalArgumentException if the request is null
  79. */
  80. public HttpServletRequestWrapper(HttpServletRequest request) {
  81. super(request);
  82. }
  83. private HttpServletRequest _getHttpServletRequest() {
  84. return (HttpServletRequest) super.getRequest();
  85. }
  86. /**
  87. * The default behavior of this method is to return getAuthType()
  88. * on the wrapped request object.
  89. */
  90. public String getAuthType() {
  91. return this._getHttpServletRequest().getAuthType();
  92. }
  93. /**
  94. * The default behavior of this method is to return getCookies()
  95. * on the wrapped request object.
  96. */
  97. public Cookie[] getCookies() {
  98. return this._getHttpServletRequest().getCookies();
  99. }
  100. /**
  101. * The default behavior of this method is to return getDateHeader(String name)
  102. * on the wrapped request object.
  103. */
  104. public long getDateHeader(String name) {
  105. return this._getHttpServletRequest().getDateHeader(name);
  106. }
  107. /**
  108. * The default behavior of this method is to return getHeader(String name)
  109. * on the wrapped request object.
  110. */
  111. public String getHeader(String name) {
  112. return this._getHttpServletRequest().getHeader(name);
  113. }
  114. /**
  115. * The default behavior of this method is to return getHeaders(String name)
  116. * on the wrapped request object.
  117. */
  118. public Enumeration getHeaders(String name) {
  119. return this._getHttpServletRequest().getHeaders(name);
  120. }
  121. /**
  122. * The default behavior of this method is to return getHeaderNames()
  123. * on the wrapped request object.
  124. */
  125. public Enumeration getHeaderNames() {
  126. return this._getHttpServletRequest().getHeaderNames();
  127. }
  128. /**
  129. * The default behavior of this method is to return getIntHeader(String name)
  130. * on the wrapped request object.
  131. */
  132. public int getIntHeader(String name) {
  133. return this._getHttpServletRequest().getIntHeader(name);
  134. }
  135. /**
  136. * The default behavior of this method is to return getMethod()
  137. * on the wrapped request object.
  138. */
  139. public String getMethod() {
  140. return this._getHttpServletRequest().getMethod();
  141. }
  142. /**
  143. * The default behavior of this method is to return getPathInfo()
  144. * on the wrapped request object.
  145. */
  146. public String getPathInfo() {
  147. return this._getHttpServletRequest().getPathInfo();
  148. }
  149. /**
  150. * The default behavior of this method is to return getPathTranslated()
  151. * on the wrapped request object.
  152. */
  153. public String getPathTranslated() {
  154. return this._getHttpServletRequest().getPathTranslated();
  155. }
  156. /**
  157. * The default behavior of this method is to return getContextPath()
  158. * on the wrapped request object.
  159. */
  160. public String getContextPath() {
  161. return this._getHttpServletRequest().getContextPath();
  162. }
  163. /**
  164. * The default behavior of this method is to return getQueryString()
  165. * on the wrapped request object.
  166. */
  167. public String getQueryString() {
  168. return this._getHttpServletRequest().getQueryString();
  169. }
  170. /**
  171. * The default behavior of this method is to return getRemoteUser()
  172. * on the wrapped request object.
  173. */
  174. public String getRemoteUser() {
  175. return this._getHttpServletRequest().getRemoteUser();
  176. }
  177. /**
  178. * The default behavior of this method is to return isUserInRole(String role)
  179. * on the wrapped request object.
  180. */
  181. public boolean isUserInRole(String role) {
  182. return this._getHttpServletRequest().isUserInRole(role);
  183. }
  184. /**
  185. * The default behavior of this method is to return getUserPrincipal()
  186. * on the wrapped request object.
  187. */
  188. public java.security.Principal getUserPrincipal() {
  189. return this._getHttpServletRequest().getUserPrincipal();
  190. }
  191. /**
  192. * The default behavior of this method is to return getRequestedSessionId()
  193. * on the wrapped request object.
  194. */
  195. public String getRequestedSessionId() {
  196. return this._getHttpServletRequest().getRequestedSessionId();
  197. }
  198. /**
  199. * The default behavior of this method is to return getRequestURI()
  200. * on the wrapped request object.
  201. */
  202. public String getRequestURI() {
  203. return this._getHttpServletRequest().getRequestURI();
  204. }
  205. /**
  206. * The default behavior of this method is to return getRequestURL()
  207. * on the wrapped request object.
  208. */
  209. public StringBuffer getRequestURL() {
  210. return this._getHttpServletRequest().getRequestURL();
  211. }
  212. /**
  213. * The default behavior of this method is to return getServletPath()
  214. * on the wrapped request object.
  215. */
  216. public String getServletPath() {
  217. return this._getHttpServletRequest().getServletPath();
  218. }
  219. /**
  220. * The default behavior of this method is to return getSession(boolean create)
  221. * on the wrapped request object.
  222. */
  223. public HttpSession getSession(boolean create) {
  224. return this._getHttpServletRequest().getSession(create);
  225. }
  226. /**
  227. * The default behavior of this method is to return getSession()
  228. * on the wrapped request object.
  229. */
  230. public HttpSession getSession() {
  231. return this._getHttpServletRequest().getSession();
  232. }
  233. /**
  234. * The default behavior of this method is to return isRequestedSessionIdValid()
  235. * on the wrapped request object.
  236. */
  237. public boolean isRequestedSessionIdValid() {
  238. return this._getHttpServletRequest().isRequestedSessionIdValid();
  239. }
  240. /**
  241. * The default behavior of this method is to return isRequestedSessionIdFromCookie()
  242. * on the wrapped request object.
  243. */
  244. public boolean isRequestedSessionIdFromCookie() {
  245. return this._getHttpServletRequest().isRequestedSessionIdFromCookie();
  246. }
  247. /**
  248. * The default behavior of this method is to return isRequestedSessionIdFromURL()
  249. * on the wrapped request object.
  250. */
  251. public boolean isRequestedSessionIdFromURL() {
  252. return this._getHttpServletRequest().isRequestedSessionIdFromURL();
  253. }
  254. /**
  255. * The default behavior of this method is to return isRequestedSessionIdFromUrl()
  256. * on the wrapped request object.
  257. */
  258. public boolean isRequestedSessionIdFromUrl() {
  259. return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
  260. }
  261. }