001 /** 002 * 003 * Copyright 2003-2004 The Apache Software Foundation 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 // 019 // This source code implements specifications defined by the Java 020 // Community Process. In order to remain compliant with the specification 021 // DO NOT add / change / or delete method signatures! 022 // 023 024 package javax.servlet.http; 025 026 import java.util.Enumeration; 027 import javax.servlet.ServletRequestWrapper; 028 029 /** 030 * Provides a convenient implementation of the HttpServletRequest interface that 031 * can be subclassed by developers wishing to adapt the request to a Servlet. 032 * This class implements the Wrapper or Decorator pattern. Methods default to 033 * calling through to the wrapped request object. 034 * 035 * @see javax.servlet.http.HttpServletRequest 036 037 * @since Servlet 2.3 038 * 039 * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $ 040 */ 041 public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest { 042 /** 043 * Constructs a request object wrapping the given request. 044 * @throws java.lang.IllegalArgumentException if the request is null 045 */ 046 public HttpServletRequestWrapper(HttpServletRequest request) { 047 super(request); 048 } 049 050 private HttpServletRequest _getHttpServletRequest() { 051 return (HttpServletRequest) super.getRequest(); 052 } 053 054 /** 055 * The default behavior of this method is to return getAuthType() 056 * on the wrapped request object. 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 public Enumeration getHeaderNames() { 099 return this._getHttpServletRequest().getHeaderNames(); 100 } 101 102 /** 103 * The default behavior of this method is to return getIntHeader(String name) 104 * on the wrapped request object. 105 */ 106 public int getIntHeader(String name) { 107 return this._getHttpServletRequest().getIntHeader(name); 108 } 109 110 /** 111 * The default behavior of this method is to return getMethod() 112 * on the wrapped request object. 113 */ 114 public String getMethod() { 115 return this._getHttpServletRequest().getMethod(); 116 } 117 118 /** 119 * The default behavior of this method is to return getPathInfo() 120 * on the wrapped request object. 121 */ 122 public String getPathInfo() { 123 return this._getHttpServletRequest().getPathInfo(); 124 } 125 126 /** 127 * The default behavior of this method is to return getPathTranslated() 128 * on the wrapped request object. 129 */ 130 public String getPathTranslated() { 131 return this._getHttpServletRequest().getPathTranslated(); 132 } 133 134 /** 135 * The default behavior of this method is to return getContextPath() 136 * on the wrapped request object. 137 */ 138 public String getContextPath() { 139 return this._getHttpServletRequest().getContextPath(); 140 } 141 142 /** 143 * The default behavior of this method is to return getQueryString() 144 * on the wrapped request object. 145 */ 146 public String getQueryString() { 147 return this._getHttpServletRequest().getQueryString(); 148 } 149 150 /** 151 * The default behavior of this method is to return getRemoteUser() 152 * on the wrapped request object. 153 */ 154 public String getRemoteUser() { 155 return this._getHttpServletRequest().getRemoteUser(); 156 } 157 158 /** 159 * The default behavior of this method is to return isUserInRole(String role) 160 * on the wrapped request object. 161 */ 162 public boolean isUserInRole(String role) { 163 return this._getHttpServletRequest().isUserInRole(role); 164 } 165 166 /** 167 * The default behavior of this method is to return getUserPrincipal() 168 * on the wrapped request object. 169 */ 170 public java.security.Principal getUserPrincipal() { 171 return this._getHttpServletRequest().getUserPrincipal(); 172 } 173 174 /** 175 * The default behavior of this method is to return getRequestedSessionId() 176 * on the wrapped request object. 177 */ 178 public String getRequestedSessionId() { 179 return this._getHttpServletRequest().getRequestedSessionId(); 180 } 181 182 /** 183 * The default behavior of this method is to return getRequestURI() 184 * on the wrapped request object. 185 */ 186 public String getRequestURI() { 187 return this._getHttpServletRequest().getRequestURI(); 188 } 189 190 /** 191 * The default behavior of this method is to return getRequestURL() 192 * on the wrapped request object. 193 */ 194 public StringBuffer getRequestURL() { 195 return this._getHttpServletRequest().getRequestURL(); 196 } 197 198 /** 199 * The default behavior of this method is to return getServletPath() 200 * on the wrapped request object. 201 */ 202 public String getServletPath() { 203 return this._getHttpServletRequest().getServletPath(); 204 } 205 206 /** 207 * The default behavior of this method is to return getSession(boolean create) 208 * on the wrapped request object. 209 */ 210 public HttpSession getSession(boolean create) { 211 return this._getHttpServletRequest().getSession(create); 212 } 213 214 /** 215 * The default behavior of this method is to return getSession() 216 * on the wrapped request object. 217 */ 218 public HttpSession getSession() { 219 return this._getHttpServletRequest().getSession(); 220 } 221 222 /** 223 * The default behavior of this method is to return isRequestedSessionIdValid() 224 * on the wrapped request object. 225 */ 226 public boolean isRequestedSessionIdValid() { 227 return this._getHttpServletRequest().isRequestedSessionIdValid(); 228 } 229 230 /** 231 * The default behavior of this method is to return isRequestedSessionIdFromCookie() 232 * on the wrapped request object. 233 */ 234 public boolean isRequestedSessionIdFromCookie() { 235 return this._getHttpServletRequest().isRequestedSessionIdFromCookie(); 236 } 237 238 /** 239 * The default behavior of this method is to return isRequestedSessionIdFromURL() 240 * on the wrapped request object. 241 */ 242 public boolean isRequestedSessionIdFromURL() { 243 return this._getHttpServletRequest().isRequestedSessionIdFromURL(); 244 } 245 246 /** 247 * The default behavior of this method is to return isRequestedSessionIdFromUrl() 248 * on the wrapped request object. 249 */ 250 public boolean isRequestedSessionIdFromUrl() { 251 return this._getHttpServletRequest().isRequestedSessionIdFromUrl(); 252 } 253 }