Package org.asynchttpclient.util
Class AuthenticatorUtils
- java.lang.Object
-
- org.asynchttpclient.util.AuthenticatorUtils
-
public final class AuthenticatorUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcomputeBodyHash(Request request, Realm realm)static @Nullable StringcomputeExpectedRspAuth(Realm realm, String sentCredentials)RFC 7616 Section 3.5: the rspauth an honest server must have sent, computed over the Digest credentials this client actually put on the wire.static StringcomputeRealmURI(Uri uri, boolean useAbsoluteURI, boolean omitQuery)The value of the Digesturiauth-param (RFC 7616 Section 3.4).static @Nullable StringgetHeaderWithPrefix(@Nullable List<String> authenticateHeaders, String prefix)static @Nullable StringperConnectionAuthorizationHeader(Request request, @Nullable ProxyServer proxyServer, @Nullable Realm realm)static @Nullable StringperConnectionProxyAuthorizationHeader(Request request, @Nullable Realm proxyRealm)static @Nullable StringperRequestAuthorizationHeader(Request request, @Nullable Realm realm)static @Nullable StringperRequestProxyAuthorizationHeader(Request request, @Nullable Realm proxyRealm)static @Nullable StringselectBestDigestChallenge(@Nullable List<String> authenticateHeaders)RFC 7616 Section 4: Select the best Digest challenge from the list.
-
-
-
Field Detail
-
NEGOTIATE
public static final String NEGOTIATE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHeaderWithPrefix
@Nullable public static @Nullable String getHeaderWithPrefix(@Nullable @Nullable List<String> authenticateHeaders, String prefix)
-
selectBestDigestChallenge
@Nullable public static @Nullable String selectBestDigestChallenge(@Nullable @Nullable List<String> authenticateHeaders)
RFC 7616 Section 4: Select the best Digest challenge from the list. Iterates in server preference order and returns the first challenge whose algorithm is supported.
-
computeRealmURI
public static String computeRealmURI(Uri uri, boolean useAbsoluteURI, boolean omitQuery)
The value of the Digesturiauth-param (RFC 7616 Section 3.4). It is the Effective Request URI (RFC 7230 Section 5.5), which never carries the deprecated userinfo subcomponent, so render the absolute form without it: the credentials would otherwise be spelled out in cleartext in theAuthorizationheader on the very hop Digest exists to keep them off, and the value would disagree with the absolute-form request line that RFC 7616 Section 3.4.6 has servers verify it against.
-
computeExpectedRspAuth
@Nullable public static @Nullable String computeExpectedRspAuth(Realm realm, String sentCredentials)
RFC 7616 Section 3.5: the rspauth an honest server must have sent, computed over the Digest credentials this client actually put on the wire.The rspauth signs the parameters of the request it answers, and none of them can be read back off the
Realm. The realm on the response future is rebuilt for header emission (seeperRequestAuthorizationHeader(org.asynchttpclient.Request, org.asynchttpclient.Realm)), and everyRealm.Builder.build()regenerates the cnonce; itsuriis whatever the exchange started with, which a redirect or a preemptive first request leaves stale or unset. So parse the credentials header instead and use the realm only for the secret and the charset.- Parameters:
sentCredentials- theAuthorizationorProxy-Authorizationheader value sent with the request being answered- Returns:
- the expected rspauth, or
nullwhen it cannot be derived — no Digest credentials were sent (a CONNECT is answered before any are), the header is missing parameters, the algorithm is unsupported, orqop=auth-intsigns a response body that has not arrived yet. Callers must then skip verification rather than enforce a value known to be wrong.
-
perConnectionProxyAuthorizationHeader
@Nullable public static @Nullable String perConnectionProxyAuthorizationHeader(Request request, @Nullable @Nullable Realm proxyRealm)
-
perRequestProxyAuthorizationHeader
@Nullable public static @Nullable String perRequestProxyAuthorizationHeader(Request request, @Nullable @Nullable Realm proxyRealm)
-
perConnectionAuthorizationHeader
@Nullable public static @Nullable String perConnectionAuthorizationHeader(Request request, @Nullable @Nullable ProxyServer proxyServer, @Nullable @Nullable Realm realm)
-
-