Skip to content

Commit 202ef8e

Browse files
author
Kedar
committed
1. Added domain in ProxyConfig
2. Added NTCredentials if domain not empty in HttpRequestClinent
1 parent eea9427 commit 202ef8e

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

oauth2-platform-api/src/main/java/com/intuit/oauth2/config/ProxyConfig.java

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,25 @@
1717

1818
/**
1919
* Config class to hold the proxy properties
20-
*
21-
* @author dderose
2220
*
21+
* @author dderose
2322
*/
2423
public class ProxyConfig {
2524

2625
private String host;
2726
private String port;
2827
private String username;
2928
private String password;
30-
29+
private String domain;
30+
3131
private ProxyConfig(ProxyConfigBuilder builder) {
32-
this.host = builder.host;
33-
this.port = builder.port;
34-
this.username = builder.username;
35-
this.password = builder.password;
36-
32+
this.host = builder.host;
33+
this.port = builder.port;
34+
this.username = builder.username;
35+
this.password = builder.password;
36+
this.domain = builder.domain;
3737
}
38-
38+
3939
public String getHost() {
4040
return host;
4141
}
@@ -52,33 +52,43 @@ public String getPassword() {
5252
return password;
5353
}
5454

55+
public String getDomain() {
56+
return domain;
57+
}
58+
5559
public static class ProxyConfigBuilder {
56-
60+
5761
private String host;
5862
private String port;
5963
private String username;
6064
private String password;
65+
private String domain;
6166

6267
public ProxyConfigBuilder(String host, String port) {
6368
this.host = host;
6469
this.port = port;
6570
}
66-
71+
6772
public ProxyConfigBuilder username(String username) {
6873
this.username = username;
6974
return this;
7075
}
71-
76+
7277
public ProxyConfigBuilder password(String password) {
7378
this.password = password;
7479
return this;
7580
}
7681

82+
public ProxyConfigBuilder domain(String domain) {
83+
this.domain = domain;
84+
return this;
85+
}
86+
7787
public ProxyConfig buildConfig() {
7888
return new ProxyConfig(this);
7989
}
80-
90+
8191
}
8292

83-
93+
8494
}

oauth2-platform-api/src/main/java/com/intuit/oauth2/http/HttpRequestClient.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,9 @@ public CredentialsProvider setProxyAuthentication(ProxyConfig proxyConfig) {
129129
String port = proxyConfig.getPort();
130130
if (!host.isEmpty() && !port.isEmpty()) {
131131
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
132-
if (username.contains("/") || username.contains("\\")) {
133-
int index = username.indexOf("/") > 0 ? username.indexOf("/") : username.indexOf("\\");
134-
String domain = username.substring(0, index);
135-
String user = username.substring(index + 1, username.length());
136-
credentialsProvider.setCredentials(new AuthScope(host, Integer.parseInt(port)), new NTCredentials(user, password, host, domain));
132+
String domain=proxyConfig.getDomain();
133+
if (!domain.isEmpty()) {
134+
credentialsProvider.setCredentials(new AuthScope(host, Integer.parseInt(port)), new NTCredentials(username, password, host, domain));
137135
} else {
138136
credentialsProvider.setCredentials(new AuthScope(host, Integer.parseInt(port)), new UsernamePasswordCredentials(username, password));
139137
}

0 commit comments

Comments
 (0)