KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ch > ethz > ssh2 > HTTPProxyData


1
2 package ch.ethz.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@inf.ethz.ch
11  * @version $Id: HTTPProxyData.java,v 1.2 2006/08/02 12:05:00 cplattne Exp $
12  */

13
14 public class HTTPProxyData implements ProxyData
15 {
16     public final String JavaDoc proxyHost;
17     public final int proxyPort;
18     public final String JavaDoc proxyUser;
19     public final String JavaDoc proxyPass;
20     public final String JavaDoc[] requestHeaderLines;
21
22     /**
23      * Same as calling {@link #HTTPProxyData(String, int, String, String) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>)}
24      *
25      * @param proxyHost Proxy hostname.
26      * @param proxyPort Proxy port.
27      */

28     public HTTPProxyData(String JavaDoc proxyHost, int proxyPort)
29     {
30         this(proxyHost, proxyPort, null, null);
31     }
32
33     /**
34      * Same as calling {@link #HTTPProxyData(String, int, String, String, String[]) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>, <code>null</code>)}
35      *
36      * @param proxyHost Proxy hostname.
37      * @param proxyPort Proxy port.
38      * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
39      * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
40      */

41     public HTTPProxyData(String JavaDoc proxyHost, int proxyPort, String JavaDoc proxyUser, String JavaDoc proxyPass)
42     {
43         this(proxyHost, proxyPort, proxyUser, proxyPass, null);
44     }
45
46     /**
47      * Connection data for a HTTP proxy. It is possible to specify a username and password
48      * if the proxy requires basic authentication. Also, additional request header lines can
49      * be specified (e.g., "User-Agent: CERN-LineMode/2.15 libwww/2.17b3").
50      * <p>
51      * Please note: if you want to use basic authentication, then both <code>proxyUser</code>
52      * and <code>proxyPass</code> must be non-null.
53      * <p>
54      * Here is an example:
55      * <p>
56      * <code>
57      * new HTTPProxyData("192.168.1.1", "3128", "proxyuser", "secret", new String[] {"User-Agent: GanymedBasedClient/1.0", "X-My-Proxy-Option: something"});
58      * </code>
59      *
60      * @param proxyHost Proxy hostname.
61      * @param proxyPort Proxy port.
62      * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
63      * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
64      * @param requestHeaderLines An array with additional request header lines (without end-of-line markers)
65      * that have to be sent to the server. May be <code>null</code>.
66      */

67
68     public HTTPProxyData(String JavaDoc proxyHost, int proxyPort, String JavaDoc proxyUser, String JavaDoc proxyPass,
69             String JavaDoc[] requestHeaderLines)
70     {
71         if (proxyHost == null)
72             throw new IllegalArgumentException JavaDoc("proxyHost must be non-null");
73
74         if (proxyPort < 0)
75             throw new IllegalArgumentException JavaDoc("proxyPort must be non-negative");
76
77         this.proxyHost = proxyHost;
78         this.proxyPort = proxyPort;
79         this.proxyUser = proxyUser;
80         this.proxyPass = proxyPass;
81         this.requestHeaderLines = requestHeaderLines;
82     }
83 }
84
Popular Tags