net.adamcin.httpsig.http.ning
Class AsyncUtil

java.lang.Object
  extended by net.adamcin.httpsig.http.ning.AsyncUtil

public final class AsyncUtil
extends Object


Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enableAuth

public static void enableAuth(com.ning.http.client.AsyncHttpClient client,
                              Signer signer)
Attaches the provided 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.

Parameters:
client - the AsyncHttpClient to use for
signer - the Signer to use for authentication. It's keys must be rotated separately.
Since:
1.0.0
See Also:
login(com.ning.http.client.AsyncHttpClient, net.adamcin.httpsig.api.Signer, com.ning.http.client.Request)

enableAuth

public 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. 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.

Parameters:
client - the AsyncHttpClient to use for
signer - 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.
Since:
1.0.4
See Also:
login(com.ning.http.client.AsyncHttpClient, net.adamcin.httpsig.api.Signer, com.ning.http.client.Request)

login

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
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.

Parameters:
client - the AsyncHttpClient to which the Signer will be attached
signer - the Signer used for login and subsequent signature authentication
loginRequest - the login Request to be executed and replayed while rotating the keychain
Returns:
a Future expecting a Response
Throws:
IOException - if a request throws an exception

login

public 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
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.

Type Parameters:
T - type parameter for completion handler
Parameters:
client - the AsyncHttpClient to which the Signer will be attached
signer - the Signer used for login and subsequent signature authentication
loginRequest - the login Request to be executed and replayed while rotating the keychain
responseHandler - an AsyncCompletionHandler of type T
Returns:
a Future of type T
Throws:
IOException - if thrown by a login request
Since:
1.0.0

login

public 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
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.

Type Parameters:
T - type parameter for completion handler
Parameters:
client - the AsyncHttpClient to which the Signer will be attached
signer - the Signer used for login and subsequent signature authentication
loginRequest - the login Request to be executed and replayed while rotating the keychain
responseHandler - an AsyncCompletionHandler of type T
calcBefore - provide another SignatureCalculator to call (such as a Content-MD5 generator) prior to generating the signature for authentication.
Returns:
a Future of type T
Throws:
IOException - if thrown by a login request
Since:
1.0.4

getRequestPath

protected static String getRequestPath(com.ning.http.client.Request request)

calculateSignature

public static void calculateSignature(Signer signer,
                                      com.ning.http.client.Request request,
                                      com.ning.http.client.RequestBuilderBase<?> requestBuilder)


Copyright © 2013-2014. All Rights Reserved.