You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by mi...@apache.org on 2020/08/19 07:15:02 UTC
[httpcomponents-client] branch 5.1.x updated: HTTPCLIENT-2078: Log
debug message when no credentials for given auth scope are found
This is an automated email from the ASF dual-hosted git repository.
michaelo pushed a commit to branch 5.1.x
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git
The following commit(s) were added to refs/heads/5.1.x by this push:
new e7f155d HTTPCLIENT-2078: Log debug message when no credentials for given auth scope are found
e7f155d is described below
commit e7f155dd15c1ae01f7d8731a71f1c549d158bd1e
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Tue Aug 18 21:31:25 2020 +0200
HTTPCLIENT-2078: Log debug message when no credentials for given auth scope are found
This closes #251
---
.../java/org/apache/hc/client5/http/impl/auth/BasicScheme.java | 9 ++++++++-
.../java/org/apache/hc/client5/http/impl/auth/DigestScheme.java | 9 ++++++++-
.../java/org/apache/hc/client5/http/impl/auth/NTLMScheme.java | 9 ++++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
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.HttpRequest;
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 @@ public class BasicScheme implements AuthScheme, Serializable {
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 @@ public class BasicScheme implements AuthScheme, Serializable {
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 fc6f477..9aec188 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
@@ -66,6 +66,8 @@ import org.apache.hc.core5.http.message.BasicNameValuePair;
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.
@@ -85,6 +87,8 @@ public class DigestScheme implements AuthScheme, Serializable {
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.
@@ -181,13 +185,16 @@ public class DigestScheme implements AuthScheme, Serializable {
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.HttpHost;
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 @@ import org.apache.hc.core5.util.Args;
*/
public final class NTLMScheme implements AuthScheme {
+ private static final Logger LOG = LoggerFactory.getLogger(NTLMScheme.class);
+
enum State {
UNINITIATED,
CHALLENGE_RECEIVED,
@@ -126,12 +130,15 @@ public final class NTLMScheme implements AuthScheme {
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;
}