Skip to content

Commit 9ec6dc9

Browse files
committed
Better fix proposed by Benjamin
1 parent e9271cf commit 9ec6dc9

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

src/main/java/com/ning/http/client/ProxyServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public String toString() {
5151
private final String principal;
5252
private final String password;
5353
private int port;
54-
private String ntlmDomain;
54+
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");
5555

5656
public ProxyServer(final Protocol protocol, final String host, final int port, String principal, String password) {
5757
this.protocol = protocol;

src/main/java/com/ning/http/client/Realm.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static class RealmBuilder {
266266
private String uri = "";
267267
private String methodName = "GET";
268268
private boolean usePreemptive = false;
269-
private String domain = "";
269+
private String domain = System.getProperty("http.auth.ntlm.domain", "");
270270
private String enc = "UTF-8";
271271
private String host = "localhost";
272272
private boolean messageType2Received = false;
@@ -560,14 +560,6 @@ public Realm build() {
560560
}
561561
}
562562

563-
if (scheme.equals(AuthScheme.NTLM) && domain.equalsIgnoreCase("")){
564-
logger.info("NTLM domain is not set, trying to read it from system property -Dhttp.auth.ntlm.domain");
565-
String tmp = System.getProperty("http.auth.ntlm.domain");
566-
if (tmp != null) {
567-
domain = tmp;
568-
}
569-
}
570-
571563
return new Realm(scheme,
572564
principal,
573565
password,

src/main/java/com/ning/http/client/providers/jdk/JDKAsyncHttpProvider.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,7 @@ private void configure(URI uri, HttpURLConnection urlConnection, Request request
498498
}
499499

500500
if (proxyServer.getProtocol().equals(ProxyServer.Protocol.NTLM)) {
501-
502501
jdkNtlmDomain = System.getProperty(NTLM_DOMAIN);
503-
if (proxyServer.getNtlmDomain() == null) {
504-
logger.info("NTLM domain is not set, trying to read it from system property -D{}", NTLM_DOMAIN);
505-
if (jdkNtlmDomain != null) {
506-
proxyServer.setNtlmDomain(jdkNtlmDomain);
507-
}
508-
}
509-
510502
System.setProperty(NTLM_DOMAIN, proxyServer.getNtlmDomain());
511503
}
512504
}
@@ -530,11 +522,7 @@ private void configure(URI uri, HttpURLConnection urlConnection, Request request
530522
break;
531523
case NTLM:
532524
jdkNtlmDomain = System.getProperty(NTLM_DOMAIN);
533-
if (realm.getNtlmDomain() == null) {
534-
logger.info("NTLM domain is not set, trying to read it from system property -D{}", NTLM_DOMAIN);
535-
} else {
536-
System.setProperty(NTLM_DOMAIN, realm.getNtlmDomain());
537-
}
525+
System.setProperty(NTLM_DOMAIN, realm.getDomain());
538526
break;
539527
default:
540528
throw new IllegalStateException(String.format("Invalid Authentication %s", realm.toString()));

0 commit comments

Comments
 (0)