Skip to content

Commit eb2a831

Browse files
stotyok2c
authored andcommitted
HTTPCLIENT-2403: Mutual authentication check not performed for proxies (#745)
1 parent 844f156 commit eb2a831

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncProtocolExec.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,26 +334,25 @@ private boolean needAuthentication(
334334
}
335335
}
336336

337+
boolean targetNeedsAuth = false;
338+
boolean proxyNeedsAuth = false;
337339
if (targetAuthRequested || targetMutualAuthRequired) {
338-
final boolean updated = authenticator.handleResponse(target, ChallengeType.TARGET, response,
340+
targetNeedsAuth = authenticator.handleResponse(target, ChallengeType.TARGET, response,
339341
targetAuthStrategy, targetAuthExchange, context);
340342

341343
if (authCacheKeeper != null) {
342344
authCacheKeeper.updateOnResponse(target, pathPrefix, targetAuthExchange, context);
343345
}
344-
345-
return updated;
346346
}
347347
if (proxyAuthRequested || proxyMutualAuthRequired) {
348-
final boolean updated = authenticator.handleResponse(proxy, ChallengeType.PROXY, response,
348+
proxyNeedsAuth = authenticator.handleResponse(proxy, ChallengeType.PROXY, response,
349349
proxyAuthStrategy, proxyAuthExchange, context);
350350

351351
if (authCacheKeeper != null) {
352352
authCacheKeeper.updateOnResponse(proxy, null, proxyAuthExchange, context);
353353
}
354-
355-
return updated;
356354
}
355+
return targetNeedsAuth || proxyNeedsAuth;
357356
}
358357
return false;
359358
}

httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthenticationHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public boolean isChallenged(
121121
}
122122

123123
/**
124-
* Determines whether the given response represents an authentication challenge, without
125-
* changing the {@link AuthExchange} state.
124+
* Determines whether the given response represents an authentication challenge
125+
* of challangeType, without changing the {@link AuthExchange} state.
126126
*
127127
* @param challengeType the challenge type (target or proxy).
128128
* @param response the response message head.

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProtocolExec.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,26 +295,25 @@ private boolean needAuthentication(
295295
}
296296
}
297297

298+
boolean targetNeedsAuth = false;
299+
boolean proxyNeedsAuth = false;
298300
if (targetAuthRequested || targetMutualAuthRequired) {
299-
final boolean updated = authenticator.handleResponse(target, ChallengeType.TARGET, response,
301+
targetNeedsAuth = authenticator.handleResponse(target, ChallengeType.TARGET, response,
300302
targetAuthStrategy, targetAuthExchange, context);
301303

302304
if (authCacheKeeper != null) {
303305
authCacheKeeper.updateOnResponse(target, pathPrefix, targetAuthExchange, context);
304306
}
305-
306-
return updated;
307307
}
308308
if (proxyAuthRequested || proxyMutualAuthRequired) {
309-
final boolean updated = authenticator.handleResponse(proxy, ChallengeType.PROXY, response,
309+
proxyNeedsAuth = authenticator.handleResponse(proxy, ChallengeType.PROXY, response,
310310
proxyAuthStrategy, proxyAuthExchange, context);
311311

312312
if (authCacheKeeper != null) {
313313
authCacheKeeper.updateOnResponse(proxy, null, proxyAuthExchange, context);
314314
}
315-
316-
return updated;
317315
}
316+
return targetNeedsAuth || proxyNeedsAuth;
318317
}
319318
return false;
320319
}

0 commit comments

Comments
 (0)