From 5bed670873a2e197bc047737d2f0f4518ab94524 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 5 Dec 2017 09:57:34 +0100 Subject: [PATCH] HTTPCLIENT-1888: Regression in SystemDefaultCredentialsProvider#getCredentials causing NPE --- .../apache/http/impl/client/AuthenticationStrategyImpl.java | 3 +-- .../http/impl/client/SystemDefaultCredentialsProvider.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java b/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java index 4ca17c37f..7c059d208 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java @@ -190,8 +190,7 @@ abstract class AuthenticationStrategyImpl implements AuthenticationStrategy { authScheme.processChallenge(challenge); final AuthScope authScope = new AuthScope( - authhost.getHostName(), - authhost.getPort(), + authhost, authScheme.getRealm(), authScheme.getSchemeName()); diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java index f977d0529..122a85995 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java @@ -111,7 +111,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsProvider { final String host = authscope.getHost(); if (host != null) { final HttpHost origin = authscope.getOrigin(); - final String protocol = origin != null ? origin.getSchemeName() : (origin.getPort() == 443 ? "https" : "http"); + final String protocol = origin != null ? origin.getSchemeName() : (authscope.getPort() == 443 ? "https" : "http"); PasswordAuthentication systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.SERVER); if (systemcreds == null) { systemcreds = getSystemCreds(protocol, authscope, Authenticator.RequestorType.PROXY);