comparison app/src/main/java/ch/ethz/ssh2/HTTPProxyData.java @ 438:d29cce60f393

migrate from Eclipse to Android Studio
author Carl Byington <carl@five-ten-sg.com>
date Thu, 03 Dec 2015 11:23:55 -0800
parents src/ch/ethz/ssh2/HTTPProxyData.java@071eccdff8ea
children
comparison
equal deleted inserted replaced
437:208b31032318 438:d29cce60f393
1 /*
2 * Copyright (c) 2006-2011 Christian Plattner. All rights reserved.
3 * Please refer to the LICENSE.txt for licensing details.
4 */
5 package ch.ethz.ssh2;
6
7 /**
8 * A <code>HTTPProxyData</code> object is used to specify the needed connection data
9 * to connect through a HTTP proxy.
10 *
11 * @see Connection#setProxyData(ProxyData)
12 *
13 * @author Christian Plattner
14 * @version 2.50, 03/15/10
15 */
16
17 public class HTTPProxyData implements ProxyData {
18 public final String proxyHost;
19 public final int proxyPort;
20 public final String proxyUser;
21 public final String proxyPass;
22 public final String[] requestHeaderLines;
23
24 /**
25 * Same as calling {@link #HTTPProxyData(String, int, String, String) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>)}
26 *
27 * @param proxyHost Proxy hostname.
28 * @param proxyPort Proxy port.
29 */
30 public HTTPProxyData(String proxyHost, int proxyPort) {
31 this(proxyHost, proxyPort, null, null);
32 }
33
34 /**
35 * Same as calling {@link #HTTPProxyData(String, int, String, String, String[]) HTTPProxyData(proxyHost, proxyPort, <code>null</code>, <code>null</code>, <code>null</code>)}
36 *
37 * @param proxyHost Proxy hostname.
38 * @param proxyPort Proxy port.
39 * @param proxyUser Username for basic authentication (<code>null</code> if no authentication is needed).
40 * @param proxyPass Password for basic authentication (<code>null</code> if no authentication is needed).
41 */
42 public HTTPProxyData(String proxyHost, int proxyPort, String proxyUser, String proxyPass) {
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 proxyHost, int proxyPort, String proxyUser, String proxyPass,
69 String[] requestHeaderLines) {
70 if (proxyHost == null)
71 throw new IllegalArgumentException("proxyHost must be non-null");
72
73 if (proxyPort < 0)
74 throw new IllegalArgumentException("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 }