public final class AsyncUtil extends Object
Modifier and Type | Method and Description |
---|---|
static void |
calculateSignature(Signer signer,
com.ning.http.client.Request request,
com.ning.http.client.RequestBuilderBase<?> requestBuilder) |
static void |
enableAuth(com.ning.http.client.AsyncHttpClient client,
Signer signer)
Attaches the provided
Signer to the AsyncHttpClient as a signature calculator. |
static void |
enableAuth(com.ning.http.client.AsyncHttpClient client,
Signer signer,
com.ning.http.client.SignatureCalculator calcBefore)
Attaches the provided
Signer to the AsyncHttpClient as a signature calculator. |
protected static String |
getRequestPath(com.ning.http.client.Request request) |
static Future<com.ning.http.client.Response> |
login(com.ning.http.client.AsyncHttpClient client,
Signer signer,
com.ning.http.client.Request loginRequest)
Executes and replays a login request until one is found which satisfies the
Challenge being returned by the server, or until there are no more keys in the
keychain. |
static <T> Future<T> |
login(com.ning.http.client.AsyncHttpClient client,
Signer signer,
com.ning.http.client.Request loginRequest,
com.ning.http.client.AsyncCompletionHandler<T> responseHandler)
Executes and replays a login request until one is found which satisfies the
Challenge being returned by the server, or until there are no more keys in the
keychain. |
static <T> Future<T> |
login(com.ning.http.client.AsyncHttpClient client,
Signer signer,
com.ning.http.client.Request loginRequest,
com.ning.http.client.AsyncCompletionHandler<T> responseHandler,
com.ning.http.client.SignatureCalculator calcBefore)
Executes and replays a login request until one is found which satisfies the
Challenge being returned by the server, or until there are no more keys in the
keychain. |
public static void enableAuth(com.ning.http.client.AsyncHttpClient client, Signer signer)
Signer
to the AsyncHttpClient
as a signature calculator.
It is expected that key rotation and Challenge
management is outside the scope
of this method, so only the Keychain.currentKey()
will be used, and signature
content will be built according to the last Challenge
provided to the
Signer.rotateKeys(net.adamcin.httpsig.api.Challenge)
method.client
- the AsyncHttpClient
to use forsigner
- the Signer
to use for authentication. It's keys must be rotated separately.login(com.ning.http.client.AsyncHttpClient, net.adamcin.httpsig.api.Signer, com.ning.http.client.Request)
public static void enableAuth(com.ning.http.client.AsyncHttpClient client, Signer signer, com.ning.http.client.SignatureCalculator calcBefore)
Signer
to the AsyncHttpClient
as a signature calculator.
It is expected that key rotation and Challenge
management is outside the scope
of this method, so only the Keychain.currentKey()
will be used, and signature
content will be built according to the last Challenge
provided to the
Signer.rotateKeys(net.adamcin.httpsig.api.Challenge)
method.client
- the AsyncHttpClient
to use forsigner
- the Signer
to use for authentication. It's keys must be rotated separately.calcBefore
- provide another SignatureCalculator
to call (such as a Content-MD5 generator) prior to
generating the signature for authentication.login(com.ning.http.client.AsyncHttpClient, net.adamcin.httpsig.api.Signer, com.ning.http.client.Request)
public static Future<com.ning.http.client.Response> login(com.ning.http.client.AsyncHttpClient client, Signer signer, com.ning.http.client.Request loginRequest) throws IOException
Challenge
being returned by the server, or until there are no more keys in the
keychain.client
- the AsyncHttpClient
to which the Signer
will be attachedsigner
- the Signer
used for login and subsequent signature authenticationloginRequest
- the login Request
to be executed and replayed while rotating the keychainFuture
expecting a Response
IOException
- if a request throws an exceptionpublic static <T> Future<T> login(com.ning.http.client.AsyncHttpClient client, Signer signer, com.ning.http.client.Request loginRequest, com.ning.http.client.AsyncCompletionHandler<T> responseHandler) throws IOException
Challenge
being returned by the server, or until there are no more keys in the
keychain.T
- type parameter for completion handlerclient
- the AsyncHttpClient
to which the Signer
will be attachedsigner
- the Signer
used for login and subsequent signature authenticationloginRequest
- the login Request
to be executed and replayed while rotating the keychainresponseHandler
- an AsyncCompletionHandler
of type T
Future
of type T
IOException
- if thrown by a login requestpublic static <T> Future<T> login(com.ning.http.client.AsyncHttpClient client, Signer signer, com.ning.http.client.Request loginRequest, com.ning.http.client.AsyncCompletionHandler<T> responseHandler, com.ning.http.client.SignatureCalculator calcBefore) throws IOException
Challenge
being returned by the server, or until there are no more keys in the
keychain.T
- type parameter for completion handlerclient
- the AsyncHttpClient
to which the Signer
will be attachedsigner
- the Signer
used for login and subsequent signature authenticationloginRequest
- the login Request
to be executed and replayed while rotating the keychainresponseHandler
- an AsyncCompletionHandler
of type T
calcBefore
- provide another SignatureCalculator
to call (such as a Content-MD5 generator) prior to
generating the signature for authentication.Future
of type T
IOException
- if thrown by a login requestprotected static String getRequestPath(com.ning.http.client.Request request)
public static void calculateSignature(Signer signer, com.ning.http.client.Request request, com.ning.http.client.RequestBuilderBase<?> requestBuilder)
Copyright © 2013-2017. All Rights Reserved.