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 // 021 // This source code implements specifications defined by the Java 022 // Community Process. In order to remain compliant with the specification 023 // DO NOT add / change / or delete method signatures! 024 // 025 026 package javax.servlet.http; 027 028 import java.util.Enumeration; 029 import javax.servlet.ServletRequestWrapper; 030 031 /** 032 * Provides a convenient implementation of the HttpServletRequest interface that 033 * can be subclassed by developers wishing to adapt the request to a Servlet. 034 * This class implements the Wrapper or Decorator pattern. Methods default to 035 * calling through to the wrapped request object. 036 * 037 * @see javax.servlet.http.HttpServletRequest 038 039 * @since Servlet 2.3 040 * 041 * @version $Rev: 467553 $ $Date: 2006-10-25 06:01:51 +0200 (Mi, 25. Okt 2006) $ 042 */ 043 public class HttpServletRequestWrapper extends ServletRequestWrapper implements HttpServletRequest { 044 /** 045 * Constructs a request object wrapping the given request. 046 * @throws java.lang.IllegalArgumentException if the request is null 047 */ 048 public HttpServletRequestWrapper(HttpServletRequest request) { 049 super(request); 050 } 051 052 private HttpServletRequest _getHttpServletRequest() { 053 return (HttpServletRequest) super.getRequest(); 054 } 055 056 /** 057 * The default behavior of this method is to return getAuthType() 058 * on the wrapped request object. 059 */ 060 public String getAuthType() { 061 return this._getHttpServletRequest().getAuthType(); 062 } 063 064 /** 065 * The default behavior of this method is to return getCookies() 066 * on the wrapped request object. 067 */ 068 public Cookie[] getCookies() { 069 return this._getHttpServletRequest().getCookies(); 070 } 071 072 /** 073 * The default behavior of this method is to return getDateHeader(String name) 074 * on the wrapped request object. 075 */ 076 public long getDateHeader(String name) { 077 return this._getHttpServletRequest().getDateHeader(name); 078 } 079 080 /** 081 * The default behavior of this method is to return getHeader(String name) 082 * on the wrapped request object. 083 */ 084 public String getHeader(String name) { 085 return this._getHttpServletRequest().getHeader(name); 086 } 087 088 /** 089 * The default behavior of this method is to return getHeaders(String name) 090 * on the wrapped request object. 091 */ 092 public Enumeration getHeaders(String name) { 093 return this._getHttpServletRequest().getHeaders(name); 094 } 095 096 /** 097 * The default behavior of this method is to return getHeaderNames() 098 * on the wrapped request object. 099 */ 100 public Enumeration getHeaderNames() { 101 return this._getHttpServletRequest().getHeaderNames(); 102 } 103 104 /** 105 * The default behavior of this method is to return getIntHeader(String name) 106 * on the wrapped request object. 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 public String getPathTranslated() { 133 return this._getHttpServletRequest().getPathTranslated(); 134 } 135 136 /** 137 * The default behavior of this method is to return getContextPath() 138 * on the wrapped request object. 139 */ 140 public String getContextPath() { 141 return this._getHttpServletRequest().getContextPath(); 142 } 143 144 /** 145 * The default behavior of this method is to return getQueryString() 146 * on the wrapped request object. 147 */ 148 public String getQueryString() { 149 return this._getHttpServletRequest().getQueryString(); 150 } 151 152 /** 153 * The default behavior of this method is to return getRemoteUser() 154 * on the wrapped request object. 155 */ 156 public String getRemoteUser() { 157 return this._getHttpServletRequest().getRemoteUser(); 158 } 159 160 /** 161 * The default behavior of this method is to return isUserInRole(String role) 162 * on the wrapped request object. 163 */ 164 public boolean isUserInRole(String role) { 165 return this._getHttpServletRequest().isUserInRole(role); 166 } 167 168 /** 169 * The default behavior of this method is to return getUserPrincipal() 170 * on the wrapped request object. 171 */ 172 public java.security.Principal getUserPrincipal() { 173 return this._getHttpServletRequest().getUserPrincipal(); 174 } 175 176 /** 177 * The default behavior of this method is to return getRequestedSessionId() 178 * on the wrapped request object. 179 */ 180 public String getRequestedSessionId() { 181 return this._getHttpServletRequest().getRequestedSessionId(); 182 } 183 184 /** 185 * The default behavior of this method is to return getRequestURI() 186 * on the wrapped request object. 187 */ 188 public String getRequestURI() { 189 return this._getHttpServletRequest().getRequestURI(); 190 } 191 192 /** 193 * The default behavior of this method is to return getRequestURL() 194 * on the wrapped request object. 195 */ 196 public StringBuffer getRequestURL() { 197 return this._getHttpServletRequest().getRequestURL(); 198 } 199 200 /** 201 * The default behavior of this method is to return getServletPath() 202 * on the wrapped request object. 203 */ 204 public String getServletPath() { 205 return this._getHttpServletRequest().getServletPath(); 206 } 207 208 /** 209 * The default behavior of this method is to return getSession(boolean create) 210 * on the wrapped request object. 211 */ 212 public HttpSession getSession(boolean create) { 213 return this._getHttpServletRequest().getSession(create); 214 } 215 216 /** 217 * The default behavior of this method is to return getSession() 218 * on the wrapped request object. 219 */ 220 public HttpSession getSession() { 221 return this._getHttpServletRequest().getSession(); 222 } 223 224 /** 225 * The default behavior of this method is to return isRequestedSessionIdValid() 226 * on the wrapped request object. 227 */ 228 public boolean isRequestedSessionIdValid() { 229 return this._getHttpServletRequest().isRequestedSessionIdValid(); 230 } 231 232 /** 233 * The default behavior of this method is to return isRequestedSessionIdFromCookie() 234 * on the wrapped request object. 235 */ 236 public boolean isRequestedSessionIdFromCookie() { 237 return this._getHttpServletRequest().isRequestedSessionIdFromCookie(); 238 } 239 240 /** 241 * The default behavior of this method is to return isRequestedSessionIdFromURL() 242 * on the wrapped request object. 243 */ 244 public boolean isRequestedSessionIdFromURL() { 245 return this._getHttpServletRequest().isRequestedSessionIdFromURL(); 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 }