0
|
1
|
|
2 package com.trilead.ssh2;
|
|
3
|
|
4 /**
|
|
5 * A <code>HTTPProxyData</code> object is used to specify the needed connection data
|
|
6 * to connect through a HTTP proxy.
|
|
7 *
|
|
8 * @see Connection#setProxyData(ProxyData)
|
|
9 *
|
|
10 * @author Christian Plattner, plattner@trilead.com
|
|
11 * @version $Id: HTTPProxyData.java,v 1.1 2007/10/15 12:49:56 cplattne Exp $
|
|
12 */
|
|
13
|
|
14 public class HTTPProxyData implements ProxyData {
|
|
15 public final String proxyHost;
|
|
16 public final int proxyPort;
|
|
17 public final String proxyUser;
|
|
18 public final String proxyPass;
|
|
19 public final String[] requestHeaderLines;
|
|
20
|
|
21 /**
|
|
22 * Same as calling {@link #HTTPProxyData(String, int, String, String) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>)}
|
|
23 *
|
|
24 * @param proxyHost Proxy hostname.
|
|
25 * @param proxyPort Proxy port.
|
|
26 */
|
|
27 public HTTPProxyData(String proxyHost, int proxyPort) {
|
|
28 this(proxyHost, proxyPort, null, null);
|
|
29 }
|
|
30
|
|
31 /**
|
|
32 * Same as calling {@link #HTTPProxyData(String, int, String, String, String[]) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>, <code>null</code>)}
|
|
33 *
|
|
34 * @param proxyHost Proxy hostname.
|
|
35 * @param proxyPort Proxy port.
|
|
36 * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
|
|
37 * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
|
|
38 */
|
|
39 public HTTPProxyData(String proxyHost, int proxyPort, 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: TrileadBasedClient/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, String proxyUser, String proxyPass,
|
|
66 String[] requestHeaderLines) {
|
|
67 if (proxyHost == null)
|
|
68 throw new IllegalArgumentException("proxyHost must be non-null");
|
|
69
|
|
70 if (proxyPort < 0)
|
|
71 throw new IllegalArgumentException("proxyPort must be non-negative");
|
|
72
|
|
73 this.proxyHost = proxyHost;
|
|
74 this.proxyPort = proxyPort;
|
|
75 this.proxyUser = proxyUser;
|
|
76 this.proxyPass = proxyPass;
|
|
77 this.requestHeaderLines = requestHeaderLines;
|
|
78 }
|
|
79 }
|