1 45 package org.exolab.jms.net.http; 46 47 import org.exolab.jms.net.connector.ConnectionRequestInfo; 48 import org.exolab.jms.net.connector.URIRequestInfo; 49 import org.exolab.jms.net.connector.ResourceException; 50 import org.exolab.jms.net.uri.URI; 51 import org.exolab.jms.net.util.SSLProperties; 52 import org.exolab.jms.net.util.Properties; 53 54 55 62 public class HTTPRequestInfo extends URIRequestInfo { 63 64 67 private String _proxyHost; 68 69 72 private int _proxyPort; 73 74 77 private String _proxyUser; 78 79 82 private String _proxyPassword; 83 84 88 private SSLProperties _sslProperties; 89 90 93 private static final String PROXY_HOST = "proxyHost"; 94 95 98 private static final String PROXY_PORT = "proxyPort"; 99 100 103 private static final String PROXY_USER = "proxyUser"; 104 105 108 private static final String PROXY_PASSWORD = "proxyPassword"; 109 110 111 116 public HTTPRequestInfo(URI uri) { 117 super(uri); 118 } 119 120 127 public HTTPRequestInfo(URI uri, Properties properties) 128 throws ResourceException { 129 super(uri); 130 setProxyHost(properties.get(PROXY_HOST)); 131 setProxyPort(properties.getInt(PROXY_PORT, 0)); 132 setProxyUser(properties.get(PROXY_USER)); 133 setProxyPassword(properties.get(PROXY_PASSWORD)); 134 135 SSLProperties ssl = new SSLProperties(properties); 136 if (!ssl.isEmpty()) { 137 setSSLProperties(ssl); 138 } 139 } 140 141 146 public void setProxyHost(String host) { 147 _proxyHost = host; 148 } 149 150 155 public String getProxyHost() { 156 return _proxyHost; 157 } 158 159 164 public void setProxyPort(int port) { 165 _proxyPort = port; 166 } 167 168 173 public int getProxyPort() { 174 return _proxyPort; 175 } 176 177 182 public void setProxyUser(String user) { 183 _proxyUser = user; 184 } 185 186 191 public String getProxyUser() { 192 return _proxyUser; 193 } 194 195 200 public void setProxyPassword(String pwd) { 201 _proxyPassword = pwd; 202 } 203 204 209 public String getProxyPassword() { 210 return _proxyPassword; 211 } 212 213 218 public SSLProperties getSSLProperties() { 219 return _sslProperties; 220 } 221 222 227 public void setSSLProperties(SSLProperties properties) { 228 _sslProperties = properties; 229 } 230 231 236 public void export(Properties properties) { 237 super.export(properties); 238 properties.setNonNull(PROXY_HOST, getProxyHost()); 239 properties.set(PROXY_PORT, getProxyPort()); 240 properties.setNonNull(PROXY_USER, getProxyUser()); 241 properties.setNonNull(PROXY_PASSWORD, getProxyPassword()); 242 243 SSLProperties ssl = getSSLProperties(); 244 if (ssl != null) { 245 ssl.export(properties); 246 } 247 } 248 249 256 public boolean equals(Object other) { 257 boolean equal = false; 258 if (other instanceof HTTPRequestInfo && super.equals(other)) { 259 HTTPRequestInfo info = (HTTPRequestInfo) other; 260 if (equals(_proxyHost, info._proxyHost) 261 && (_proxyPort == info._proxyPort) 262 && equals(_proxyUser, info._proxyUser) 263 && equals(_proxyPassword, info._proxyPassword) 264 && equals(_sslProperties, info._sslProperties)) { 265 equal = true; 266 } 267 } 268 return equal; 269 } 270 271 279 private boolean equals(Object o1, Object o2) { 280 boolean equal = (o1 == null && o2 == null); 281 if (!equal) { 282 if (o1 != null && o1.equals(o2)) { 283 equal = true; 284 } 285 } 286 return equal; 287 } 288 289 } 290 | Popular Tags |