Properly distinguish between AuthScheme and auth scheme name

Throughout the code the terms 'authScheme' and 'scheme' have been used
synonymously for an AuthScheme instance and a string-based auth scheme
name. To avoid confusion, fields, methods and variable have been adapted
to distinguish both properly. If necessary, Javadoc has been modified to
denote the nature of the input.

Also an auth scheme name is retained as-is, but normalized to lowercase
if comparsion is required.

This closes #193
This commit is contained in:
Michael Osipov 2019-12-30 01:20:04 +01:00
parent 634886ab61
commit 3730b03a99
14 changed files with 91 additions and 82 deletions

View File

@ -44,8 +44,8 @@ public class BasicAuthTokenExtractor {
if (i == -1) {
throw new ProtocolException("Invalid challenge response: " + challengeResponse);
}
final String authscheme = challengeResponse.substring(0, i);
if (authscheme.equalsIgnoreCase(StandardAuthScheme.BASIC)) {
final String schemeName = challengeResponse.substring(0, i);
if (schemeName.equalsIgnoreCase(StandardAuthScheme.BASIC)) {
final String s = challengeResponse.substring(i + 1).trim();
try {
final byte[] credsRaw = s.getBytes(StandardCharsets.US_ASCII);

View File

@ -32,8 +32,8 @@ import com.sun.jna.platform.win32.WinError;
public final class WindowsNegotiateSchemeGetTokenFail extends WindowsNegotiateScheme {
public WindowsNegotiateSchemeGetTokenFail(final String scheme, final String servicePrincipalName) {
super(scheme, servicePrincipalName);
public WindowsNegotiateSchemeGetTokenFail(final String schemeName, final String servicePrincipalName) {
super(schemeName, servicePrincipalName);
}
@Override

View File

@ -74,7 +74,7 @@ public class WindowsNegotiateScheme implements AuthScheme {
private final Logger log = LoggerFactory.getLogger(getClass());
// NTLM or Negotiate
private final String scheme;
private final String schemeName;
private final String servicePrincipalName;
private ChallengeType challengeType;
@ -83,15 +83,15 @@ public class WindowsNegotiateScheme implements AuthScheme {
private CtxtHandle sspiContext;
private boolean continueNeeded;
WindowsNegotiateScheme(final String scheme, final String servicePrincipalName) {
WindowsNegotiateScheme(final String schemeName, final String servicePrincipalName) {
super();
this.scheme = (scheme == null) ? StandardAuthScheme.SPNEGO : scheme;
this.schemeName = (schemeName == null) ? StandardAuthScheme.SPNEGO : schemeName;
this.continueNeeded = true;
this.servicePrincipalName = servicePrincipalName;
if (this.log.isDebugEnabled()) {
this.log.debug("Created WindowsNegotiateScheme using " + this.scheme);
this.log.debug("Created WindowsNegotiateScheme using " + this.schemeName);
}
}
@ -115,7 +115,7 @@ public class WindowsNegotiateScheme implements AuthScheme {
@Override
public String getName() {
return scheme;
return schemeName;
}
@Override
@ -186,7 +186,7 @@ public class WindowsNegotiateScheme implements AuthScheme {
clientCred = new CredHandle();
final int rc = Secur32.INSTANCE.AcquireCredentialsHandle(username,
scheme, Sspi.SECPKG_CRED_OUTBOUND, null, null, null, null,
schemeName, Sspi.SECPKG_CRED_OUTBOUND, null, null, null, null,
clientCred, lifetime);
if (WinError.SEC_E_OK != rc) {
@ -220,7 +220,7 @@ public class WindowsNegotiateScheme implements AuthScheme {
throw ex;
}
}
return scheme + " " + response;
return schemeName + " " + response;
}
private void failAuthCleanup() {

View File

@ -46,28 +46,28 @@ import org.apache.hc.core5.util.Args;
public final class AuthChallenge {
private final ChallengeType challengeType;
private final String scheme;
private final String schemeName;
private final String value;
private final List<NameValuePair> params;
public AuthChallenge(final ChallengeType challengeType, final String scheme, final String value, final List<? extends NameValuePair> params) {
public AuthChallenge(final ChallengeType challengeType, final String schemeName, final String value, final List<? extends NameValuePair> params) {
super();
this.challengeType = Args.notNull(challengeType, "Challenge type");
this.scheme = Args.notNull(scheme, "Auth scheme");
this.schemeName = Args.notNull(schemeName, "schemeName");
this.value = value;
this.params = params != null ? Collections.unmodifiableList(new ArrayList<>(params)) : null;
}
public AuthChallenge(final ChallengeType challengeType, final String scheme, final NameValuePair... params) {
this(challengeType, scheme, null, Arrays.asList(params));
public AuthChallenge(final ChallengeType challengeType, final String schemeName, final NameValuePair... params) {
this(challengeType, schemeName, null, Arrays.asList(params));
}
public ChallengeType getChallengeType() {
return challengeType;
}
public String getScheme() {
return scheme;
public String getSchemeName() {
return schemeName;
}
public String getValue() {
@ -81,7 +81,7 @@ public final class AuthChallenge {
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
buffer.append(scheme).append(" ");
buffer.append(schemeName).append(" ");
if (value != null) {
buffer.append(value);
} else if (params != null) {

View File

@ -48,7 +48,7 @@ public class AuthScope {
private final String host;
private final int port;
private final String realm;
private final String authScheme;
private final String schemeName;
/**
* Defines auth scope with the given {@code protocol}, {@code host}, {@code port},
@ -62,20 +62,20 @@ public class AuthScope {
* to any port of the host.
* @param realm authentication realm. May be {@code null} if applies
* to any realm on the host.
* @param authScheme authentication scheme. May be {@code null} if applies
* to any authScheme supported by the host.
* @param schemeName authentication scheme name. May be {@code null} if applies
* to any auth scheme supported by the host.
*/
public AuthScope(
final String protocol,
final String host,
final int port,
final String realm,
final String authScheme) {
final String schemeName) {
this.protocol = protocol != null ? protocol.toLowerCase(Locale.ROOT) : null;
this.host = host != null ? host.toLowerCase(Locale.ROOT) : null;
this.port = port >= 0 ? port: -1;
this.realm = realm;
this.authScheme = authScheme != null ? authScheme.toUpperCase(Locale.ROOT): null;
this.schemeName = schemeName != null ? schemeName : null;
}
/**
@ -84,8 +84,8 @@ public class AuthScope {
* @param origin host of origin
* @param realm authentication realm. May be {@code null} if applies
* to any realm on the host.
* @param schemeName authentication authScheme. May be {@code null} if applies
* to any authScheme supported by the host.
* @param schemeName authentication scheme name. May be {@code null} if applies
* to any auth scheme supported by the host.
*
* @since 4.2
*/
@ -98,7 +98,7 @@ public class AuthScope {
this.host = origin.getHostName().toLowerCase(Locale.ROOT);
this.port = origin.getPort() >= 0 ? origin.getPort() : -1;
this.realm = realm;
this.authScheme = schemeName != null ? schemeName.toUpperCase(Locale.ROOT): null;
this.schemeName = schemeName != null ? schemeName : null;
}
/**
@ -134,7 +134,7 @@ public class AuthScope {
this.host = authScope.getHost();
this.port = authScope.getPort();
this.realm = authScope.getRealm();
this.authScheme = authScope.getAuthScheme();
this.schemeName = authScope.getSchemeName();
}
public String getProtocol() {
@ -153,8 +153,8 @@ public class AuthScope {
return this.realm;
}
public String getAuthScheme() {
return this.authScheme;
public String getSchemeName() {
return this.schemeName;
}
/**
@ -166,10 +166,11 @@ public class AuthScope {
*/
public int match(final AuthScope that) {
int factor = 0;
if (LangUtils.equals(this.authScheme, that.authScheme)) {
if (LangUtils.equals(toNullSafeLowerCase(this.schemeName),
toNullSafeLowerCase(that.schemeName))) {
factor += 1;
} else {
if (this.authScheme != null && that.authScheme != null) {
if (this.schemeName != null && that.schemeName != null) {
return -1;
}
}
@ -215,7 +216,8 @@ public class AuthScope {
&& LangUtils.equals(this.host, that.host)
&& this.port == that.port
&& LangUtils.equals(this.realm, that.realm)
&& LangUtils.equals(this.authScheme, that.authScheme);
&& LangUtils.equals(toNullSafeLowerCase(this.schemeName),
toNullSafeLowerCase(that.schemeName));
}
return false;
}
@ -227,15 +229,19 @@ public class AuthScope {
hash = LangUtils.hashCode(hash, this.host);
hash = LangUtils.hashCode(hash, this.port);
hash = LangUtils.hashCode(hash, this.realm);
hash = LangUtils.hashCode(hash, this.authScheme);
hash = LangUtils.hashCode(hash, toNullSafeLowerCase(this.schemeName));
return hash;
}
private String toNullSafeLowerCase(final String str) {
return str != null ? str.toLowerCase(Locale.ROOT) : null;
}
@Override
public String toString() {
final StringBuilder buffer = new StringBuilder();
if (this.authScheme != null) {
buffer.append(this.authScheme);
if (this.schemeName != null) {
buffer.append(this.schemeName);
} else {
buffer.append("<any auth scheme>");
}

View File

@ -373,7 +373,7 @@ public class RequestConfig implements Cloneable {
/**
* Determines the order of preference for supported authentication schemes
* when authenticating with the target host.
* by their names when authenticating with the target host.
* <p>
* Default: {@code null}
* </p>
@ -385,7 +385,7 @@ public class RequestConfig implements Cloneable {
/**
* Determines the order of preference for supported authentication schemes
* when authenticating with the proxy host.
* by their names when authenticating with the proxy host.
* <p>
* Default: {@code null}
* </p>

View File

@ -97,13 +97,13 @@ public class DefaultAuthenticationStrategy implements AuthenticationStrategy {
this.log.debug("Authentication schemes in the order of preference: " + authPrefs);
}
for (final String id: authPrefs) {
final AuthChallenge challenge = challenges.get(id.toLowerCase(Locale.ROOT));
for (final String schemeName: authPrefs) {
final AuthChallenge challenge = challenges.get(schemeName.toLowerCase(Locale.ROOT));
if (challenge != null) {
final AuthSchemeFactory authSchemeFactory = registry.lookup(id);
final AuthSchemeFactory authSchemeFactory = registry.lookup(schemeName);
if (authSchemeFactory == null) {
if (this.log.isWarnEnabled()) {
this.log.warn("Authentication scheme " + id + " not supported");
this.log.warn("Authentication scheme " + schemeName + " not supported");
// Try again
}
continue;
@ -112,7 +112,7 @@ public class DefaultAuthenticationStrategy implements AuthenticationStrategy {
options.add(authScheme);
} else {
if (this.log.isDebugEnabled()) {
this.log.debug("Challenge for " + id + " authentication scheme not available");
this.log.debug("Challenge for " + schemeName + " authentication scheme not available");
}
}
}

View File

@ -88,42 +88,42 @@ public class AuthChallengeParser {
final ChallengeType challengeType, final CharSequence buffer, final ParserCursor cursor) throws ParseException {
final List<AuthChallenge> list = new ArrayList<>();
String scheme = null;
String schemeName = null;
final List<NameValuePair> params = new ArrayList<>();
while (!cursor.atEnd()) {
final NameValuePair tokenOrParameter = parseTokenOrParameter(buffer, cursor);
if (tokenOrParameter.getValue() == null && !cursor.atEnd() && buffer.charAt(cursor.getPos()) != COMMA_CHAR) {
if (scheme != null) {
if (schemeName != null) {
if (params.isEmpty()) {
throw new ParseException("Malformed auth challenge");
}
list.add(createAuthChallenge(challengeType, scheme, params));
list.add(createAuthChallenge(challengeType, schemeName, params));
params.clear();
}
scheme = tokenOrParameter.getName();
schemeName = tokenOrParameter.getName();
} else {
params.add(tokenOrParameter);
if (!cursor.atEnd() && buffer.charAt(cursor.getPos()) != COMMA_CHAR) {
scheme = null;
schemeName = null;
}
}
if (!cursor.atEnd() && buffer.charAt(cursor.getPos()) == COMMA_CHAR) {
cursor.updatePos(cursor.getPos() + 1);
}
}
list.add(createAuthChallenge(challengeType, scheme, params));
list.add(createAuthChallenge(challengeType, schemeName, params));
return list;
}
private static AuthChallenge createAuthChallenge(final ChallengeType challengeType, final String scheme, final List<NameValuePair> params) throws ParseException {
if (scheme != null) {
private static AuthChallenge createAuthChallenge(final ChallengeType challengeType, final String schemeName, final List<NameValuePair> params) throws ParseException {
if (schemeName != null) {
if (params.size() == 1) {
final NameValuePair nvp = params.get(0);
if (nvp.getValue() == null) {
return new AuthChallenge(challengeType, scheme, nvp.getName(), null);
return new AuthChallenge(challengeType, schemeName, nvp.getName(), null);
}
}
return new AuthChallenge(challengeType, scheme, null, params.size() > 0 ? params : null);
return new AuthChallenge(challengeType, schemeName, null, params.size() > 0 ? params : null);
}
if (params.size() == 1) {
final NameValuePair nvp = params.get(0);

View File

@ -195,9 +195,9 @@ public final class HttpAuthenticator {
continue;
}
for (final AuthChallenge authChallenge: authChallenges) {
final String scheme = authChallenge.getScheme().toLowerCase(Locale.ROOT);
if (!challengeMap.containsKey(scheme)) {
challengeMap.put(scheme, authChallenge);
final String schemeName = authChallenge.getSchemeName().toLowerCase(Locale.ROOT);
if (!challengeMap.containsKey(schemeName)) {
challengeMap.put(schemeName, authChallenge);
}
}
}
@ -220,8 +220,8 @@ public final class HttpAuthenticator {
case UNCHALLENGED:
final AuthScheme authScheme = authExchange.getAuthScheme();
if (authScheme != null) {
final String id = authScheme.getName();
final AuthChallenge challenge = challengeMap.get(id.toLowerCase(Locale.ROOT));
final String schemeName = authScheme.getName();
final AuthChallenge challenge = challengeMap.get(schemeName.toLowerCase(Locale.ROOT));
if (challenge != null) {
this.log.debug("Authorization challenge processed");
try {
@ -259,8 +259,8 @@ public final class HttpAuthenticator {
final Queue<AuthScheme> authOptions = new LinkedList<>();
for (final AuthScheme authScheme: preferredSchemes) {
try {
final String id = authScheme.getName();
final AuthChallenge challenge = challengeMap.get(id.toLowerCase(Locale.ROOT));
final String schemeName = authScheme.getName();
final AuthChallenge challenge = challengeMap.get(schemeName.toLowerCase(Locale.ROOT));
authScheme.processChallenge(challenge, context);
if (authScheme.isResponseReady(host, credsProvider, context)) {
authOptions.add(authScheme);

View File

@ -91,7 +91,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore {
authScope.getPort(),
protocol,
authScope.getRealm(),
authScope.getAuthScheme(),
authScope.getSchemeName(),
targetHostURL,
requestorType);
}
@ -128,7 +128,7 @@ public class SystemDefaultCredentialsProvider implements CredentialsStore {
if (domain != null) {
return new NTCredentials(systemcreds.getUserName(), systemcreds.getPassword(), null, domain);
}
if (StandardAuthScheme.NTLM.equalsIgnoreCase(authScope.getAuthScheme())) {
if (StandardAuthScheme.NTLM.equalsIgnoreCase(authScope.getSchemeName())) {
// Domain may be specified in a fully qualified user name
return new NTCredentials(
systemcreds.getUserName(), systemcreds.getPassword(), null, null);

View File

@ -38,7 +38,7 @@ public class TestAuthChallenge {
@Test
public void testAuthChallengeWithValue() {
final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, "blah", null);
Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName());
Assert.assertEquals("blah", authChallenge.getValue());
Assert.assertEquals(null, authChallenge.getParams());
Assert.assertEquals(StandardAuthScheme.BASIC + " blah", authChallenge.toString());
@ -48,7 +48,7 @@ public class TestAuthChallenge {
public void testAuthChallengeWithParams() {
final AuthChallenge authChallenge = new AuthChallenge(ChallengeType.TARGET, StandardAuthScheme.BASIC, null,
Arrays.asList(new BasicNameValuePair("blah", "this"), new BasicNameValuePair("blah", "that")));
Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, authChallenge.getSchemeName());
Assert.assertEquals(null, authChallenge.getValue());
Assert.assertNotNull(authChallenge.getParams());
Assert.assertEquals(StandardAuthScheme.BASIC + " [blah=this, blah=that]", authChallenge.toString());

View File

@ -37,20 +37,20 @@ public class TestAuthScope {
@Test
public void testBasics() {
final AuthScope authscope = new AuthScope("http", "somehost", 80, "somerealm", "somescheme");
Assert.assertEquals("SOMESCHEME", authscope.getAuthScheme());
final AuthScope authscope = new AuthScope("http", "somehost", 80, "somerealm", "SomeScheme");
Assert.assertEquals("SomeScheme", authscope.getSchemeName());
Assert.assertEquals("http", authscope.getProtocol());
Assert.assertEquals("somehost", authscope.getHost());
Assert.assertEquals(80, authscope.getPort());
Assert.assertEquals("somerealm", authscope.getRealm());
Assert.assertEquals("SOMESCHEME 'somerealm' http://somehost:80", authscope.toString());
Assert.assertEquals("SomeScheme 'somerealm' http://somehost:80", authscope.toString());
}
@Test
public void testByOrigin() {
final HttpHost host = new HttpHost("http", "somehost", 8080);
final AuthScope authscope = new AuthScope(host);
Assert.assertEquals(null, authscope.getAuthScheme());
Assert.assertEquals(null, authscope.getSchemeName());
Assert.assertEquals("somehost", authscope.getHost());
Assert.assertEquals(8080, authscope.getPort());
Assert.assertEquals(null, authscope.getRealm());
@ -61,7 +61,7 @@ public class TestAuthScope {
@Test
public void testMixedCaseHostname() {
final AuthScope authscope = new AuthScope("SomeHost", 80);
Assert.assertEquals(null, authscope.getAuthScheme());
Assert.assertEquals(null, authscope.getSchemeName());
Assert.assertEquals("somehost", authscope.getHost());
Assert.assertEquals(80, authscope.getPort());
Assert.assertEquals(null, authscope.getRealm());
@ -78,7 +78,7 @@ public class TestAuthScope {
@Test
public void testBasicsAllOptional() {
final AuthScope authscope = new AuthScope(null, null, -1, null, null);
Assert.assertEquals(null, authscope.getAuthScheme());
Assert.assertEquals(null, authscope.getSchemeName());
Assert.assertEquals(null, authscope.getHost());
Assert.assertEquals(-1, authscope.getPort());
Assert.assertEquals(null, authscope.getRealm());
@ -125,6 +125,7 @@ public class TestAuthScope {
final AuthScope authscope5 = new AuthScope("http", "somehost", 80, "someotherrealm", "somescheme");
final AuthScope authscope6 = new AuthScope("http", "somehost", 80, "somerealm", "someotherscheme");
final AuthScope authscope7 = new AuthScope("https", "somehost", 80, "somerealm", "somescheme");
final AuthScope authscope8 = new AuthScope("https", "somehost", 80, "somerealm", "SomeScheme");
Assert.assertTrue(authscope1.equals(authscope1));
Assert.assertFalse(authscope1.equals(authscope2));
Assert.assertTrue(authscope1.equals(authscope3));
@ -132,6 +133,7 @@ public class TestAuthScope {
Assert.assertFalse(authscope1.equals(authscope5));
Assert.assertFalse(authscope1.equals(authscope6));
Assert.assertFalse(authscope1.equals(authscope7));
Assert.assertTrue(authscope7.equals(authscope8));
}
@Test
@ -143,6 +145,7 @@ public class TestAuthScope {
final AuthScope authscope5 = new AuthScope("http", "somehost", 80, "someotherrealm", "somescheme");
final AuthScope authscope6 = new AuthScope("http", "somehost", 80, "somerealm", "someotherscheme");
final AuthScope authscope7 = new AuthScope("https", "somehost", 80, "somerealm", "somescheme");
final AuthScope authscope8 = new AuthScope("https", "somehost", 80, "somerealm", "SomeScheme");
Assert.assertTrue(authscope1.hashCode() == authscope1.hashCode());
Assert.assertFalse(authscope1.hashCode() == authscope2.hashCode());
Assert.assertTrue(authscope1.hashCode() == authscope3.hashCode());
@ -150,6 +153,7 @@ public class TestAuthScope {
Assert.assertFalse(authscope1.hashCode() == authscope5.hashCode());
Assert.assertFalse(authscope1.hashCode() == authscope6.hashCode());
Assert.assertFalse(authscope1.hashCode() == authscope7.hashCode());
Assert.assertTrue(authscope7.hashCode() == authscope8.hashCode());
}
}

View File

@ -157,7 +157,7 @@ public class TestAuthChallengeParser {
Assert.assertNotNull(challenges);
Assert.assertEquals(1, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName());
Assert.assertEquals(null, challenge1.getValue());
final List<NameValuePair> params = challenge1.getParams();
Assert.assertNotNull(params);
@ -174,7 +174,7 @@ public class TestAuthChallengeParser {
Assert.assertNotNull(challenges);
Assert.assertEquals(1, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName());
Assert.assertEquals(null, challenge1.getValue());
final List<NameValuePair> params = challenge1.getParams();
Assert.assertNotNull(params);
@ -193,12 +193,12 @@ public class TestAuthChallengeParser {
Assert.assertEquals(2, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals("This", challenge1.getScheme());
Assert.assertEquals("This", challenge1.getSchemeName());
Assert.assertEquals("xxxxxxxxxxxxxxxxxxxxxx", challenge1.getValue());
Assert.assertNull(challenge1.getParams());
final AuthChallenge challenge2 = challenges.get(1);
Assert.assertEquals("That", challenge2.getScheme());
Assert.assertEquals("That", challenge2.getSchemeName());
Assert.assertEquals("yyyyyyyyyyyyyyyyyyyyyy", challenge2.getValue());
Assert.assertNull(challenge2.getParams());
}
@ -214,7 +214,7 @@ public class TestAuthChallengeParser {
Assert.assertEquals(2, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, challenge1.getSchemeName());
Assert.assertEquals(null, challenge1.getValue());
final List<NameValuePair> params1 = challenge1.getParams();
Assert.assertNotNull(params1);
@ -224,7 +224,7 @@ public class TestAuthChallengeParser {
assertNameValuePair(new BasicNameValuePair("param2", "that"), params1.get(2));
final AuthChallenge challenge2 = challenges.get(1);
Assert.assertEquals(StandardAuthScheme.BASIC, challenge2.getScheme());
Assert.assertEquals(StandardAuthScheme.BASIC, challenge2.getSchemeName());
Assert.assertEquals(null, challenge2.getValue());
final List<NameValuePair> params2 = challenge2.getParams();
Assert.assertNotNull(params2);
@ -245,7 +245,7 @@ public class TestAuthChallengeParser {
Assert.assertEquals(1, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals("This", challenge1.getScheme());
Assert.assertEquals("This", challenge1.getSchemeName());
Assert.assertEquals(null, challenge1.getValue());
Assert.assertNull(challenge1.getParams());
}
@ -284,7 +284,7 @@ public class TestAuthChallengeParser {
Assert.assertEquals(1, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals("blah", challenge1.getScheme());
Assert.assertEquals("blah", challenge1.getSchemeName());
Assert.assertEquals("blah", challenge1.getValue());
Assert.assertNull(challenge1.getParams());
}
@ -299,7 +299,7 @@ public class TestAuthChallengeParser {
Assert.assertEquals(1, challenges.size());
final AuthChallenge challenge1 = challenges.get(0);
Assert.assertEquals("blah", challenge1.getScheme());
Assert.assertEquals("blah", challenge1.getSchemeName());
Assert.assertEquals(null, challenge1.getValue());
final List<NameValuePair> params1 = challenge1.getParams();
Assert.assertNotNull(params1);

View File

@ -28,7 +28,6 @@ package org.apache.hc.client5.http.impl.auth;
import java.net.Authenticator;
import java.net.Authenticator.RequestorType;
import java.util.Locale;
import java.net.InetAddress;
import java.net.PasswordAuthentication;
import java.net.URL;
@ -101,7 +100,7 @@ public class TestSystemDefaultCredentialsProvider {
new SystemDefaultCredentialsProvider().getCredentials(authScope, coreContext);
Mockito.verify(authenticatorDelegate).getPasswordAuthentication(PROXY_HOST1, null, PROXY_PORT1, PROXY_PROTOCOL1,
PROMPT1, StandardAuthScheme.BASIC.toUpperCase(Locale.ROOT), httpRequestUrl,
PROMPT1, StandardAuthScheme.BASIC, httpRequestUrl,
RequestorType.SERVER);
Assert.assertNotNull(receivedCredentials);
Assert.assertEquals(AUTH1.getUserName(), receivedCredentials.getUserPrincipal().getName());
@ -119,7 +118,7 @@ public class TestSystemDefaultCredentialsProvider {
new SystemDefaultCredentialsProvider().getCredentials(authScope, null);
Mockito.verify(authenticatorDelegate).getPasswordAuthentication(PROXY_HOST1, null, PROXY_PORT1, PROXY_PROTOCOL1,
PROMPT1, StandardAuthScheme.BASIC.toUpperCase(Locale.ROOT), null,
PROMPT1, StandardAuthScheme.BASIC, null,
RequestorType.SERVER);
Assert.assertNotNull(receivedCredentials);
Assert.assertEquals(AUTH1.getUserName(), receivedCredentials.getUserPrincipal().getName());