001: /*
002: * Copyright 2001-2007 Joe Walker <joe[remove] at getahead dot ltd dot uk> and
003: * Geert Bevin <gbevin[remove] at uwyn dot com>
004: * Distributed under the terms of either:
005: * - the common development and distribution license (CDDL), v1.0; or
006: * - the GNU Lesser General Public License, v2.1 or later
007: * $Id: DwrElementHttpServletRequest.java 3669 2007-02-26 13:51:23Z gbevin $
008: */
009: package com.uwyn.rife.engine.elements;
010:
011: import com.uwyn.rife.engine.ElementSupport;
012: import com.uwyn.rife.tools.StringUtils;
013: import java.io.BufferedReader;
014: import java.io.IOException;
015: import java.io.UnsupportedEncodingException;
016: import java.security.Principal;
017: import java.util.Enumeration;
018: import java.util.Locale;
019: import java.util.Map;
020: import javax.servlet.RequestDispatcher;
021: import javax.servlet.ServletInputStream;
022: import javax.servlet.http.Cookie;
023: import javax.servlet.http.HttpServletRequest;
024: import javax.servlet.http.HttpSession;
025:
026: /**
027: * This is an implementation of <code>HttpServletRequest</code> so that DWR
028: * can easily be integrated into RIFE. Data that is sent and retrieved is only
029: * done through DWR and thus doesn't create a security hole. The main purpose
030: * is for the URLs to be relocatable
031: *
032: * @author Joe Walker <joe[remove] at getahead dot ltd dot uk>
033: * @author Geert Bevin <gbevin[remove] at uwyn dot com>
034: */
035: final class DwrElementHttpServletRequest implements HttpServletRequest {
036: private ElementSupport mSupport;
037: private HttpServletRequest mRequest;
038:
039: DwrElementHttpServletRequest(ElementSupport support) {
040: mSupport = support;
041: mRequest = support.getHttpServletRequest();
042: }
043:
044: public String getPathInfo() {
045: return mSupport.getPathInfo();
046: }
047:
048: public String getPathTranslated() {
049: return mRequest.getPathTranslated();
050: }
051:
052: public String getContextPath() {
053: return StringUtils.stripFromEnd(mSupport.getWebappRootUrl(),
054: "/");
055: }
056:
057: public String getRequestURI() {
058: return mRequest.getRequestURI();
059: }
060:
061: public StringBuffer getRequestURL() {
062: return mRequest.getRequestURL();
063: }
064:
065: public String getRealPath(String arg0) {
066: return mRequest.getRealPath(arg0);
067: }
068:
069: public String getServletPath() {
070: return mSupport.getElementInfo().getUrl();
071: }
072:
073: public String getContentType() {
074: return mSupport.getContentType();
075: }
076:
077: public String getProtocol() {
078: return mSupport.getProtocol();
079: }
080:
081: public String getScheme() {
082: return mSupport.getScheme();
083: }
084:
085: public String getServerName() {
086: return mSupport.getServerName();
087: }
088:
089: public int getServerPort() {
090: return mSupport.getServerPort();
091: }
092:
093: public String getRemoteAddr() {
094: return mSupport.getRemoteAddr();
095: }
096:
097: public String getRemoteHost() {
098: return mSupport.getRemoteHost();
099: }
100:
101: public String getAuthType() {
102: return mRequest.getAuthType();
103: }
104:
105: public Cookie[] getCookies() {
106: return mRequest.getCookies();
107: }
108:
109: public long getDateHeader(String name) {
110: return mRequest.getDateHeader(name);
111: }
112:
113: public String getHeader(String name) {
114: return mRequest.getHeader(name);
115: }
116:
117: public Enumeration getHeaders(String name) {
118: return mRequest.getHeaders(name);
119: }
120:
121: public Enumeration getHeaderNames() {
122: return mRequest.getHeaderNames();
123: }
124:
125: public int getIntHeader(String name) {
126: return mRequest.getIntHeader(name);
127: }
128:
129: public String getMethod() {
130: return mRequest.getMethod();
131: }
132:
133: public String getQueryString() {
134: return mRequest.getQueryString();
135: }
136:
137: public String getRemoteUser() {
138: return mRequest.getRemoteUser();
139: }
140:
141: public boolean isUserInRole(String arg0) {
142: return mRequest.isUserInRole(arg0);
143: }
144:
145: public Principal getUserPrincipal() {
146: return mRequest.getUserPrincipal();
147: }
148:
149: public String getRequestedSessionId() {
150: return mRequest.getRequestedSessionId();
151: }
152:
153: public HttpSession getSession(boolean arg0) {
154: return mRequest.getSession(arg0);
155: }
156:
157: public HttpSession getSession() {
158: return mRequest.getSession();
159: }
160:
161: public boolean isRequestedSessionIdValid() {
162: return mRequest.isRequestedSessionIdValid();
163: }
164:
165: public boolean isRequestedSessionIdFromCookie() {
166: return mRequest.isRequestedSessionIdFromCookie();
167: }
168:
169: public boolean isRequestedSessionIdFromURL() {
170: return mRequest.isRequestedSessionIdFromURL();
171: }
172:
173: public boolean isRequestedSessionIdFromUrl() {
174: return mRequest.isRequestedSessionIdFromUrl();
175: }
176:
177: public Object getAttribute(String name) {
178: return mRequest.getAttribute(name);
179: }
180:
181: public Enumeration getAttributeNames() {
182: return mRequest.getAttributeNames();
183: }
184:
185: public String getCharacterEncoding() {
186: return mRequest.getCharacterEncoding();
187: }
188:
189: public void setCharacterEncoding(String arg0)
190: throws UnsupportedEncodingException {
191: mRequest.setCharacterEncoding(arg0);
192: }
193:
194: public int getContentLength() {
195: return mRequest.getContentLength();
196: }
197:
198: public ServletInputStream getInputStream() throws IOException {
199: return mRequest.getInputStream();
200: }
201:
202: public String getParameter(String name) {
203: return mRequest.getParameter(name);
204: }
205:
206: public Enumeration getParameterNames() {
207: return mRequest.getParameterNames();
208: }
209:
210: public String[] getParameterValues(String name) {
211: return mRequest.getParameterValues(name);
212: }
213:
214: public Map getParameterMap() {
215: return mRequest.getParameterMap();
216: }
217:
218: public BufferedReader getReader() throws IOException {
219: return mRequest.getReader();
220: }
221:
222: public void setAttribute(String name, Object object) {
223: mRequest.setAttribute(name, object);
224: }
225:
226: public void removeAttribute(String name) {
227: mRequest.removeAttribute(name);
228: }
229:
230: public Locale getLocale() {
231: return mRequest.getLocale();
232: }
233:
234: public Enumeration getLocales() {
235: return mRequest.getLocales();
236: }
237:
238: public boolean isSecure() {
239: return mRequest.isSecure();
240: }
241:
242: public RequestDispatcher getRequestDispatcher(String arg0) {
243: return mRequest.getRequestDispatcher(arg0);
244: }
245: }
|