-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from auth0/add-proxy
Add support for java Proxy with basic auth
- Loading branch information
Showing
6 changed files
with
447 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.auth0.client; | ||
|
||
/** | ||
* Used to configure additional configuration options when customizing the API client instance. | ||
*/ | ||
public class HttpOptions { | ||
|
||
private ProxyOptions proxyOptions; | ||
|
||
/** | ||
* Getter for the Proxy configuration options | ||
* | ||
* @return the Proxy configuration options if set, null otherwise. | ||
*/ | ||
public ProxyOptions getProxyOptions() { | ||
return proxyOptions; | ||
} | ||
|
||
/** | ||
* Setter for the Proxy configuration options | ||
* | ||
* @param proxyOptions the Proxy configuration options | ||
*/ | ||
public void setProxyOptions(ProxyOptions proxyOptions) { | ||
this.proxyOptions = proxyOptions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.