AeroGear Android Library 1.1.0

org.jboss.aerogear.android.authentication.impl
Class HttpDigestAuthenticationModule

java.lang.Object
  extended by org.jboss.aerogear.android.authentication.AbstractAuthenticationModule
      extended by org.jboss.aerogear.android.authentication.impl.HttpDigestAuthenticationModule
All Implemented Interfaces:
AuthenticationModule

public class HttpDigestAuthenticationModule
extends AbstractAuthenticationModule

This class provides Authentication using HTTP Digest As per the HTTP RFC this class will cache credentials and consumed by Pipe requests. This module assumes that credentials provided are valid and will never fail on login(java.lang.String, java.lang.String, org.jboss.aerogear.android.Callback) or AGSecurityAuthenticationModule.logout(org.jboss.aerogear.android.Callback). enroll(java.util.Map, org.jboss.aerogear.android.Callback) is not supported and will always fail.


Field Summary
 
Fields inherited from class org.jboss.aerogear.android.authentication.AbstractAuthenticationModule
THREAD_POOL_EXECUTOR
 
Constructor Summary
HttpDigestAuthenticationModule(URL baseURL, AuthenticationConfig config)
           
 
Method Summary
 void enroll(Map<String,String> userData, Callback<HeaderAndBody> callback)
          Will try to register a user with a service using userData.
 AuthorizationFields getAuthorizationFields()
          This method is called be Pipe implementations when they need security applied to their HttpProvider.
 AuthorizationFields getAuthorizationFields(URI requestUri, String method, byte[] requestBody)
          This method is called be Pipe implementations when they need security applied to their HttpProvider.
 URL getBaseURL()
           
 String getEnrollEndpoint()
           
 String getLoginEndpoint()
           
 String getLogoutEndpoint()
           
 boolean isLoggedIn()
           
 void login(String username, String password, Callback<HeaderAndBody> callback)
          Will try to log in a user using username and password.
 void logout(Callback<Void> callback)
          Performs a logout of the current user.
 boolean retryLogin()
          Some authorization schemes (HTTP Digest, OAUTH) have a mechanism for retrying a login to fetch fresh credentials after the credentials expire.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpDigestAuthenticationModule

public HttpDigestAuthenticationModule(URL baseURL,
                                      AuthenticationConfig config)
Parameters:
baseURL -
config -
Throws:
IllegalArgumentException - if an endpoint can not be appended to baseURL
Method Detail

getBaseURL

public URL getBaseURL()

getLoginEndpoint

public String getLoginEndpoint()

getLogoutEndpoint

public String getLogoutEndpoint()

getEnrollEndpoint

public String getEnrollEndpoint()

enroll

public void enroll(Map<String,String> userData,
                   Callback<HeaderAndBody> callback)
Description copied from interface: AuthenticationModule
Will try to register a user with a service using userData.

It will call the callbacks onSuccess with a parameter of a Map of the values returned by the enroll service or onFailure if there is an error

Specified by:
enroll in interface AuthenticationModule
Overrides:
enroll in class AbstractAuthenticationModule

login

public void login(String username,
                  String password,
                  Callback<HeaderAndBody> callback)
Description copied from interface: AuthenticationModule
Will try to log in a user using username and password.

It will call the callbacks onSuccess with a parameter of a Map of the values returned by the enroll service or onFailure if there is an error

Specified by:
login in interface AuthenticationModule
Overrides:
login in class AbstractAuthenticationModule

logout

public void logout(Callback<Void> callback)
Description copied from interface: AuthenticationModule
Performs a logout of the current user.

It will call callback.onSuccess with no value on success and callback.onFailure if there is an error.

Specified by:
logout in interface AuthenticationModule
Overrides:
logout in class AbstractAuthenticationModule

isLoggedIn

public boolean isLoggedIn()
Returns:
true if the module has been logged in successfully

getAuthorizationFields

public AuthorizationFields getAuthorizationFields()
Description copied from interface: AuthenticationModule
This method is called be Pipe implementations when they need security applied to their HttpProvider. The headers/data/query parameters returned should be applied to the Url and HttpProvider directly before a call.

Returns:
the current AuthorizationFields for security

getAuthorizationFields

public AuthorizationFields getAuthorizationFields(URI requestUri,
                                                  String method,
                                                  byte[] requestBody)
Description copied from interface: AuthenticationModule
This method is called be Pipe implementations when they need security applied to their HttpProvider. The headers/data/query parameters returned should be applied to the Url and HttpProvider directly before a call.

Parameters:
requestUri - the Request-Line URI.
method - the HTTP method being used
requestBody - the body of the request. This method promises to not modify the body.
Returns:
the current AuthorizationFields for security

retryLogin

public boolean retryLogin()
Description copied from interface: AuthenticationModule
Some authorization schemes (HTTP Digest, OAUTH) have a mechanism for retrying a login to fetch fresh credentials after the credentials expire. In the event of a 401 error, this method should retry the login. If the system does not support retrying or if the retry fails then it will return false. Otherwise it returns true and refreshes the various credentials. This method is blocking and it should NOT be called by the user directly.

Returns:
whether or not retrying the login succeeded.

AeroGear Android Library 1.1.0

Copyright © 2013 JBoss by Red Hat. All Rights Reserved.