-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
323 additions
and
18 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
play-ahc-ws-standalone/src/main/java/play/libs/ws/ahc/DefaultWSProxyServer.java
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,161 @@ | ||
/* | ||
* Copyright (C) Lightbend Inc. <https://www.lightbend.com> | ||
*/ | ||
|
||
package play.libs.ws.ahc; | ||
|
||
import play.libs.ws.WSProxyServer; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public class DefaultWSProxyServer implements WSProxyServer { | ||
private final String host; | ||
private final int port; | ||
private final String protocol; | ||
private final String proxyType; | ||
private final String principal; | ||
private final String password; | ||
private final String ntlmDomain; | ||
private final List<String> nonProxyHosts; | ||
private final String encoding; | ||
|
||
DefaultWSProxyServer(String host, | ||
Integer port, | ||
String protocol, | ||
String proxyType, | ||
String principal, | ||
String password, | ||
String ntlmDomain, | ||
List<String> nonProxyHosts, | ||
String encoding) { | ||
this.host = Objects.requireNonNull(host, "host cannot be null!"); | ||
this.port = Objects.requireNonNull(port, "port cannot be null"); | ||
this.protocol = protocol; | ||
this.proxyType = proxyType; | ||
this.principal = principal; | ||
this.password = password; | ||
this.ntlmDomain = ntlmDomain; | ||
this.nonProxyHosts = nonProxyHosts; | ||
this.encoding = encoding; | ||
} | ||
|
||
@Override | ||
public String getHost() { | ||
return this.host; | ||
} | ||
|
||
@Override | ||
public int getPort() { | ||
return this.port; | ||
} | ||
|
||
@Override | ||
public Optional<String> getProtocol() { | ||
return Optional.ofNullable(this.protocol); | ||
} | ||
|
||
@Override | ||
public Optional<String> getProxyType() { | ||
return Optional.ofNullable(this.proxyType); | ||
} | ||
|
||
@Override | ||
public Optional<String> getPrincipal() { | ||
return Optional.ofNullable(this.principal); | ||
} | ||
|
||
@Override | ||
public Optional<String> getPassword() { | ||
return Optional.ofNullable(this.password); | ||
} | ||
|
||
@Override | ||
public Optional<String> getNtlmDomain() { | ||
return Optional.ofNullable(this.ntlmDomain); | ||
} | ||
|
||
@Override | ||
public Optional<String> getEncoding() { | ||
return Optional.ofNullable(this.encoding); | ||
} | ||
|
||
@Override | ||
public Optional<List<String>> getNonProxyHosts() { | ||
return Optional.ofNullable(this.nonProxyHosts); | ||
} | ||
|
||
static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
static class Builder { | ||
private String host; | ||
private Integer port; | ||
private String protocol; | ||
private String proxyType; | ||
private String principal; | ||
private String password; | ||
private String ntlmDomain; | ||
private List<String> nonProxyHosts; | ||
private String encoding; | ||
|
||
public Builder withHost(String host) { | ||
this.host = host; | ||
return this; | ||
} | ||
|
||
public Builder withPort(int port) { | ||
this.port = port; | ||
return this; | ||
} | ||
|
||
public Builder withProtocol(String protocol) { | ||
this.protocol = protocol; | ||
return this; | ||
} | ||
|
||
public Builder withProxyType(String proxyType) { | ||
this.proxyType = proxyType; | ||
return this; | ||
} | ||
|
||
public Builder withPrincipal(String principal) { | ||
this.principal = principal; | ||
return this; | ||
} | ||
|
||
public Builder withPassword(String password) { | ||
this.password = password; | ||
return this; | ||
} | ||
|
||
public Builder withNtlmDomain(String ntlmDomain) { | ||
this.ntlmDomain = ntlmDomain; | ||
return this; | ||
} | ||
|
||
public Builder withNonProxyHosts(List<String> nonProxyHosts) { | ||
this.nonProxyHosts = nonProxyHosts; | ||
return this; | ||
} | ||
|
||
public Builder withEncoding(String encoding) { | ||
this.encoding = encoding; | ||
return this; | ||
} | ||
|
||
public WSProxyServer build() { | ||
return new DefaultWSProxyServer(host, | ||
port, | ||
protocol, | ||
proxyType, | ||
principal, | ||
password, | ||
ntlmDomain, | ||
nonProxyHosts, | ||
encoding); | ||
} | ||
} | ||
} |
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
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.