1 19 20 package com.sslexplorer.core; 21 22 import java.io.IOException ; 23 import java.io.InputStream ; 24 import java.io.UnsupportedEncodingException ; 25 import java.util.Enumeration ; 26 import java.util.Map ; 27 28 import javax.servlet.http.Cookie ; 29 import javax.servlet.http.HttpServletRequest ; 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 request; 43 44 public ServletRequestAdapter(HttpServletRequest request) { 45 this.request = request; 46 } 47 48 public boolean isSecure() { 49 return request.isSecure(); 50 } 51 52 public String getURIEncoded() { 53 return request.getRequestURI(); 54 } 55 56 public Cookie [] getCookies() { 57 return request.getCookies(); 58 } 59 60 public String getRemoteAddr() { 61 return request.getRemoteAddr(); 62 } 63 64 public String getRemoteHost() { 65 return request.getRemoteHost(); 66 } 67 68 public String getField(String name) { 69 return request.getHeader(name); 70 } 71 72 public Enumeration getFieldValues(String name) { 73 return request.getHeaders(name); 74 } 75 76 public String getMethod() { 77 return request.getMethod(); 78 } 79 80 public Enumeration getFieldNames() { 81 return request.getHeaderNames(); 82 } 83 84 public String getPath() { 85 return request.getPathInfo(); 86 } 87 88 public Map getParameters() { 89 return request.getParameterMap(); 90 } 91 92 public String getHost() { 93 return request.getRemoteHost(); 94 } 95 96 public InputStream getInputStream() { 97 try { 98 return request.getInputStream(); 99 } catch (IOException 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 ("You cannot set a tunnel on a HttpServletRequest"); 110 } 112 113 public void setTunnel(RequestHandlerTunnel tunnel, int timeoutMs) { 114 throw new UnsupportedOperationException ("You cannot set a tunnel on a HttpServletRequest"); 115 } 117 118 public void setAttribute(String name, Object value) { 119 request.setAttribute(name, value); 120 } 121 122 public Object getAttribute(String name) { 123 return request.getAttribute(name); 124 } 125 126 public void setCharacterEncoding(String charset) throws UnsupportedEncodingException { 127 request.setCharacterEncoding(charset); 128 } 129 130 public int getContentLength() { 131 return request.getContentLength(); 132 } 133 134 public String getContentType() { 135 return request.getContentType(); 136 } 137 } 138 | Popular Tags |