KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > core > ServletRequestAdapter


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.core;
21
22 import java.io.IOException JavaDoc;
23 import java.io.InputStream JavaDoc;
24 import java.io.UnsupportedEncodingException JavaDoc;
25 import java.util.Enumeration JavaDoc;
26 import java.util.Map JavaDoc;
27
28 import javax.servlet.http.Cookie JavaDoc;
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30
31 import org.apache.commons.logging.Log;
32 import org.apache.commons.logging.LogFactory;
33
34 import com.sslexplorer.boot.RequestHandlerRequest;
35 import com.sslexplorer.boot.RequestHandlerTunnel;
36
37 public class ServletRequestAdapter implements RequestHandlerRequest {
38
39     final static Log log = LogFactory.getLog(ServletRequestAdapter.class);
40
41     
42     private HttpServletRequest JavaDoc request;
43
44     public ServletRequestAdapter(HttpServletRequest JavaDoc request) {
45         this.request = request;
46     }
47
48     public boolean isSecure() {
49         return request.isSecure();
50     }
51
52     public String JavaDoc getURIEncoded() {
53         return request.getRequestURI();
54     }
55     
56      public Cookie JavaDoc[] getCookies() {
57         return request.getCookies();
58     }
59
60     public String JavaDoc getRemoteAddr() {
61         return request.getRemoteAddr();
62     }
63
64     public String JavaDoc getRemoteHost() {
65         return request.getRemoteHost();
66     }
67
68     public String JavaDoc getField(String JavaDoc name) {
69         return request.getHeader(name);
70     }
71
72     public Enumeration JavaDoc getFieldValues(String JavaDoc name) {
73         return request.getHeaders(name);
74     }
75
76     public String JavaDoc getMethod() {
77         return request.getMethod();
78     }
79
80     public Enumeration JavaDoc getFieldNames() {
81         return request.getHeaderNames();
82     }
83
84     public String JavaDoc getPath() {
85         return request.getPathInfo();
86     }
87
88     public Map JavaDoc getParameters() {
89         return request.getParameterMap();
90     }
91
92     public String JavaDoc getHost() {
93         return request.getRemoteHost();
94     }
95
96     public InputStream JavaDoc getInputStream() {
97         try {
98             return request.getInputStream();
99         } catch (IOException JavaDoc ex) {
100             return null;
101         }
102     }
103
104     public int getPort() {
105         return request.getServerPort();
106     }
107
108     public void setTunnel(RequestHandlerTunnel tunnel) {
109         throw new UnsupportedOperationException JavaDoc("You cannot set a tunnel on a HttpServletRequest");
110             //request.getHttpConnection().setHttpTunnel(new TunnelAdapter(tunnel));
111
}
112
113     public void setTunnel(RequestHandlerTunnel tunnel, int timeoutMs) {
114         throw new UnsupportedOperationException JavaDoc("You cannot set a tunnel on a HttpServletRequest");
115             //request.getHttpConnection().setHttpTunnel(new TunnelAdapter(tunnel));
116
}
117     
118     public void setAttribute(String JavaDoc name, Object JavaDoc value) {
119         request.setAttribute(name, value);
120     }
121
122     public Object JavaDoc getAttribute(String JavaDoc name) {
123         return request.getAttribute(name);
124     }
125     
126     public void setCharacterEncoding(String JavaDoc charset) throws UnsupportedEncodingException JavaDoc {
127         request.setCharacterEncoding(charset);
128     }
129
130     public int getContentLength() {
131         return request.getContentLength();
132     }
133
134     public String JavaDoc getContentType() {
135         return request.getContentType();
136     }
137 }
138
Popular Tags