01: package ch.ethz.ssh2;
02:
03: /**
04: * A <code>HTTPProxyData</code> object is used to specify the needed connection data
05: * to connect through a HTTP proxy.
06: *
07: * @see Connection#setProxyData(ProxyData)
08: *
09: * @author Christian Plattner, plattner@inf.ethz.ch
10: * @version $Id: HTTPProxyData.java,v 1.2 2006/08/02 12:05:00 cplattne Exp $
11: */
12:
13: public class HTTPProxyData implements ProxyData {
14: public final String proxyHost;
15: public final int proxyPort;
16: public final String proxyUser;
17: public final String proxyPass;
18: public final String[] requestHeaderLines;
19:
20: /**
21: * Same as calling {@link #HTTPProxyData(String, int, String, String) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>)}
22: *
23: * @param proxyHost Proxy hostname.
24: * @param proxyPort Proxy port.
25: */
26: public HTTPProxyData(String proxyHost, int proxyPort) {
27: this (proxyHost, proxyPort, null, null);
28: }
29:
30: /**
31: * Same as calling {@link #HTTPProxyData(String, int, String, String, String[]) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>, <code>null</code>)}
32: *
33: * @param proxyHost Proxy hostname.
34: * @param proxyPort Proxy port.
35: * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
36: * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
37: */
38: public HTTPProxyData(String proxyHost, int proxyPort,
39: String proxyUser, String proxyPass) {
40: this (proxyHost, proxyPort, proxyUser, proxyPass, null);
41: }
42:
43: /**
44: * Connection data for a HTTP proxy. It is possible to specify a username and password
45: * if the proxy requires basic authentication. Also, additional request header lines can
46: * be specified (e.g., "User-Agent: CERN-LineMode/2.15 libwww/2.17b3").
47: * <p>
48: * Please note: if you want to use basic authentication, then both <code>proxyUser</code>
49: * and <code>proxyPass</code> must be non-null.
50: * <p>
51: * Here is an example:
52: * <p>
53: * <code>
54: * new HTTPProxyData("192.168.1.1", "3128", "proxyuser", "secret", new String[] {"User-Agent: GanymedBasedClient/1.0", "X-My-Proxy-Option: something"});
55: * </code>
56: *
57: * @param proxyHost Proxy hostname.
58: * @param proxyPort Proxy port.
59: * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
60: * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
61: * @param requestHeaderLines An array with additional request header lines (without end-of-line markers)
62: * that have to be sent to the server. May be <code>null</code>.
63: */
64:
65: public HTTPProxyData(String proxyHost, int proxyPort,
66: String proxyUser, String proxyPass,
67: String[] requestHeaderLines) {
68: if (proxyHost == null)
69: throw new IllegalArgumentException(
70: "proxyHost must be non-null");
71:
72: if (proxyPort < 0)
73: throw new IllegalArgumentException(
74: "proxyPort must be non-negative");
75:
76: this.proxyHost = proxyHost;
77: this.proxyPort = proxyPort;
78: this.proxyUser = proxyUser;
79: this.proxyPass = proxyPass;
80: this.requestHeaderLines = requestHeaderLines;
81: }
82: }
|