001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019
020 package javax.servlet.http;
021
022 import javax.servlet.ServletRequestWrapper;
023 import java.util.Enumeration;
024
025 /**
026 *
027 * Provides a convenient implementation of the HttpServletRequest interface that
028 * can be subclassed by developers wishing to adapt the request to a Servlet.
029 * This class implements the Wrapper or Decorator pattern. Methods default to
030 * calling through to the wrapped request object.
031 *
032 *
033 * @see javax.servlet.http.HttpServletRequest
034 * @since v 2.3
035 *
036 */
037
038
039 public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest {
040
041 /**
042 * Constructs a request object wrapping the given request.
043 * @throws java.lang.IllegalArgumentException if the request is null
044 */
045 public HttpServletRequestWrapper(HttpServletRequest request) {
046 super(request);
047 }
048
049 private HttpServletRequest _getHttpServletRequest() {
050 return (HttpServletRequest) super.getRequest();
051 }
052
053 /**
054 * The default behavior of this method is to return getAuthType()
055 * on the wrapped request object.
056 */
057
058 public String getAuthType() {
059 return this._getHttpServletRequest().getAuthType();
060 }
061
062 /**
063 * The default behavior of this method is to return getCookies()
064 * on the wrapped request object.
065 */
066 public Cookie[] getCookies() {
067 return this._getHttpServletRequest().getCookies();
068 }
069
070 /**
071 * The default behavior of this method is to return getDateHeader(String name)
072 * on the wrapped request object.
073 */
074 public long getDateHeader(String name) {
075 return this._getHttpServletRequest().getDateHeader(name);
076 }
077
078 /**
079 * The default behavior of this method is to return getHeader(String name)
080 * on the wrapped request object.
081 */
082 public String getHeader(String name) {
083 return this._getHttpServletRequest().getHeader(name);
084 }
085
086 /**
087 * The default behavior of this method is to return getHeaders(String name)
088 * on the wrapped request object.
089 */
090 public Enumeration getHeaders(String name) {
091 return this._getHttpServletRequest().getHeaders(name);
092 }
093
094 /**
095 * The default behavior of this method is to return getHeaderNames()
096 * on the wrapped request object.
097 */
098
099 public Enumeration getHeaderNames() {
100 return this._getHttpServletRequest().getHeaderNames();
101 }
102
103 /**
104 * The default behavior of this method is to return getIntHeader(String name)
105 * on the wrapped request object.
106 */
107
108 public int getIntHeader(String name) {
109 return this._getHttpServletRequest().getIntHeader(name);
110 }
111
112 /**
113 * The default behavior of this method is to return getMethod()
114 * on the wrapped request object.
115 */
116 public String getMethod() {
117 return this._getHttpServletRequest().getMethod();
118 }
119
120 /**
121 * The default behavior of this method is to return getPathInfo()
122 * on the wrapped request object.
123 */
124 public String getPathInfo() {
125 return this._getHttpServletRequest().getPathInfo();
126 }
127
128 /**
129 * The default behavior of this method is to return getPathTranslated()
130 * on the wrapped request object.
131 */
132
133 public String getPathTranslated() {
134 return this._getHttpServletRequest().getPathTranslated();
135 }
136
137 /**
138 * The default behavior of this method is to return getContextPath()
139 * on the wrapped request object.
140 */
141 public String getContextPath() {
142 return this._getHttpServletRequest().getContextPath();
143 }
144
145 /**
146 * The default behavior of this method is to return getQueryString()
147 * on the wrapped request object.
148 */
149 public String getQueryString() {
150 return this._getHttpServletRequest().getQueryString();
151 }
152
153 /**
154 * The default behavior of this method is to return getRemoteUser()
155 * on the wrapped request object.
156 */
157 public String getRemoteUser() {
158 return this._getHttpServletRequest().getRemoteUser();
159 }
160
161
162 /**
163 * The default behavior of this method is to return isUserInRole(String role)
164 * on the wrapped request object.
165 */
166 public boolean isUserInRole(String role) {
167 return this._getHttpServletRequest().isUserInRole(role);
168 }
169
170
171
172 /**
173 * The default behavior of this method is to return getUserPrincipal()
174 * on the wrapped request object.
175 */
176 public java.security.Principal getUserPrincipal() {
177 return this._getHttpServletRequest().getUserPrincipal();
178 }
179
180
181 /**
182 * The default behavior of this method is to return getRequestedSessionId()
183 * on the wrapped request object.
184 */
185 public String getRequestedSessionId() {
186 return this._getHttpServletRequest().getRequestedSessionId();
187 }
188
189 /**
190 * The default behavior of this method is to return getRequestURI()
191 * on the wrapped request object.
192 */
193 public String getRequestURI() {
194 return this._getHttpServletRequest().getRequestURI();
195 }
196 /**
197 * The default behavior of this method is to return getRequestURL()
198 * on the wrapped request object.
199 */
200 public StringBuffer getRequestURL() {
201 return this._getHttpServletRequest().getRequestURL();
202 }
203
204
205 /**
206 * The default behavior of this method is to return getServletPath()
207 * on the wrapped request object.
208 */
209 public String getServletPath() {
210 return this._getHttpServletRequest().getServletPath();
211 }
212
213
214 /**
215 * The default behavior of this method is to return getSession(boolean create)
216 * on the wrapped request object.
217 */
218 public HttpSession getSession(boolean create) {
219 return this._getHttpServletRequest().getSession(create);
220 }
221
222 /**
223 * The default behavior of this method is to return getSession()
224 * on the wrapped request object.
225 */
226 public HttpSession getSession() {
227 return this._getHttpServletRequest().getSession();
228 }
229
230 /**
231 * The default behavior of this method is to return isRequestedSessionIdValid()
232 * on the wrapped request object.
233 */
234
235 public boolean isRequestedSessionIdValid() {
236 return this._getHttpServletRequest().isRequestedSessionIdValid();
237 }
238
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 /**
249 * The default behavior of this method is to return isRequestedSessionIdFromURL()
250 * on the wrapped request object.
251 */
252 public boolean isRequestedSessionIdFromURL() {
253 return this._getHttpServletRequest().isRequestedSessionIdFromURL();
254 }
255
256 /**
257 * The default behavior of this method is to return isRequestedSessionIdFromUrl()
258 * on the wrapped request object.
259 */
260 public boolean isRequestedSessionIdFromUrl() {
261 return this._getHttpServletRequest().isRequestedSessionIdFromUrl();
262 }
263
264
265
266 }