HTTPCLIENT-2078: Log debug message when no credentials for given auth scope are found
This closes #251
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicScheme.java
index 81b015a..427df1c 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicScheme.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/BasicScheme.java
@@ -55,6 +55,8 @@
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Basic authentication scheme as defined in RFC 2617.
@@ -66,6 +68,8 @@
private static final long serialVersionUID = -1931571557597830536L;
+ private static final Logger LOG = LoggerFactory.getLogger(BasicScheme.class);
+
private final Map<String, String> paramMap;
private transient Charset charset;
private transient ByteArrayBuilder buffer;
@@ -141,13 +145,16 @@
Args.notNull(host, "Auth host");
Args.notNull(credentialsProvider, "CredentialsProvider");
+ final AuthScope authScope = new AuthScope(host, getRealm(), getName());
final Credentials credentials = credentialsProvider.getCredentials(
- new AuthScope(host, getRealm(), getName()), context);
+ authScope, context);
if (credentials != null) {
this.username = credentials.getUserPrincipal().getName();
this.password = credentials.getPassword();
return true;
}
+
+ LOG.debug("No credentials found for auth scope [{}]", authScope);
this.username = null;
this.password = null;
return false;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java
index d9b5177..7353e6f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/DigestScheme.java
@@ -64,6 +64,8 @@
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.CharArrayBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Digest authentication scheme as defined in RFC 2617.
@@ -83,6 +85,8 @@
private static final long serialVersionUID = 3883908186234566916L;
+ private static final Logger LOG = LoggerFactory.getLogger(DigestScheme.class);
+
/**
* Hexa values used when creating 32 character long digest in HTTP DigestScheme
* in case of authentication.
@@ -173,13 +177,16 @@
Args.notNull(host, "Auth host");
Args.notNull(credentialsProvider, "CredentialsProvider");
+ final AuthScope authScope = new AuthScope(host, getRealm(), getName());
final Credentials credentials = credentialsProvider.getCredentials(
- new AuthScope(host, getRealm(), getName()), context);
+ authScope, context);
if (credentials != null) {
this.username = credentials.getUserPrincipal().getName();
this.password = credentials.getPassword();
return true;
}
+
+ LOG.debug("No credentials found for auth scope [{}]", authScope);
this.username = null;
this.password = null;
return false;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMScheme.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMScheme.java
index 1b1beb3..53c4a7b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMScheme.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/NTLMScheme.java
@@ -41,6 +41,8 @@
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* NTLM is a proprietary authentication scheme developed by Microsoft
@@ -50,6 +52,8 @@
*/
public final class NTLMScheme implements AuthScheme {
+ private static final Logger LOG = LoggerFactory.getLogger(NTLMScheme.class);
+
enum State {
UNINITIATED,
CHALLENGE_RECEIVED,
@@ -126,12 +130,15 @@
Args.notNull(host, "Auth host");
Args.notNull(credentialsProvider, "CredentialsProvider");
+ final AuthScope authScope = new AuthScope(host, null, getName());
final Credentials credentials = credentialsProvider.getCredentials(
- new AuthScope(host, null, getName()), context);
+ authScope, context);
if (credentials instanceof NTCredentials) {
this.credentials = (NTCredentials) credentials;
return true;
}
+
+ LOG.debug("No credentials found for auth scope [{}]", authScope);
return false;
}