forked from auth0/auth0-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProxyOptions.java
More file actions
56 lines (48 loc) · 1.43 KB
/
ProxyOptions.java
File metadata and controls
56 lines (48 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.auth0.client;
import com.auth0.utils.Asserts;
import okhttp3.Credentials;
import java.net.Proxy;
/**
* Used to configure Java Proxy-related configurations.
*/
public class ProxyOptions {
private final Proxy proxy;
private String basicAuth;
/**
* Builds a new instance using the given Proxy.
* The Proxy will not have authentication unless {@link #setBasicAuthentication(String, char[])} is set.
*
* @param proxy the Proxy to use.
*/
public ProxyOptions(Proxy proxy) {
Asserts.assertNotNull(proxy, "proxy");
this.proxy = proxy;
}
/**
* Setter that builds the authentication value to use for this Proxy.
*
* @param username the username to use.
* @param password the password to use.
*/
public void setBasicAuthentication(String username, char[] password) {
Asserts.assertNotNull(proxy, "username");
Asserts.assertNotNull(proxy, "password");
this.basicAuth = Credentials.basic(username, new String(password));
}
/**
* Getter of the Proxy instance to set
*
* @return the Proxy instance to set
*/
public Proxy getProxy() {
return proxy;
}
/**
* Getter of the authentication value to use for this Proxy.
*
* @return the authentication value to use for this Proxy, or null if unset.
*/
public String getBasicAuthentication() {
return basicAuth;
}
}