AeroGear Android Library 1.1.0

org.jboss.aerogear.android.authentication.impl.loader
Class AuthenticationModuleAdapter

java.lang.Object
  extended by org.jboss.aerogear.android.authentication.impl.loader.AuthenticationModuleAdapter
All Implemented Interfaces:
android.app.LoaderManager.LoaderCallbacks<HeaderAndBody>, AuthenticationModule, LoaderAuthenticationModule

public class AuthenticationModuleAdapter
extends Object
implements LoaderAuthenticationModule, android.app.LoaderManager.LoaderCallbacks<HeaderAndBody>

This class manages the relationship between Android's Loader framework and requests to Authentication. This class acts as a proxy for an AuthenticationModule instance. This class instantiates the Loaders from android.content and will not work on devices < Android 3.0. For these devices see SupportAuthenticationModuleAdapter


Field Summary
 
Fields inherited from interface org.jboss.aerogear.android.authentication.impl.loader.LoaderAuthenticationModule
CALLBACK, METHOD, PARAMS, PASSWORD, USERNAME
 
Constructor Summary
AuthenticationModuleAdapter(android.app.Activity activity, AuthenticationModule module, String name)
           
AuthenticationModuleAdapter(android.app.Fragment fragment, android.content.Context applicationContext, AuthenticationModule module, String name)
           
 
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.
 android.content.Loader<HeaderAndBody> onCreateLoader(int id, android.os.Bundle bundle)
           
 void onLoaderReset(android.content.Loader<HeaderAndBody> loader)
           
 void onLoadFinished(android.content.Loader<HeaderAndBody> loader, HeaderAndBody data)
          This method will call the Callback for a enroll, login, or logout method on the main thread of the application.
 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

AuthenticationModuleAdapter

public AuthenticationModuleAdapter(android.app.Activity activity,
                                   AuthenticationModule module,
                                   String name)

AuthenticationModuleAdapter

public AuthenticationModuleAdapter(android.app.Fragment fragment,
                                   android.content.Context applicationContext,
                                   AuthenticationModule module,
                                   String name)
Method Detail

getBaseURL

public URL getBaseURL()
Specified by:
getBaseURL in interface AuthenticationModule

getLoginEndpoint

public String getLoginEndpoint()
Specified by:
getLoginEndpoint in interface AuthenticationModule

getLogoutEndpoint

public String getLogoutEndpoint()
Specified by:
getLogoutEndpoint in interface AuthenticationModule

getEnrollEndpoint

public String getEnrollEndpoint()
Specified by:
getEnrollEndpoint in interface AuthenticationModule

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

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

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

isLoggedIn

public boolean isLoggedIn()
Specified by:
isLoggedIn in interface AuthenticationModule
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.

Specified by:
getAuthorizationFields in interface AuthenticationModule
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.

Specified by:
getAuthorizationFields in interface AuthenticationModule
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.

Specified by:
retryLogin in interface AuthenticationModule
Returns:
whether or not retrying the login succeeded.

onCreateLoader

public android.content.Loader<HeaderAndBody> onCreateLoader(int id,
                                                            android.os.Bundle bundle)
Specified by:
onCreateLoader in interface android.app.LoaderManager.LoaderCallbacks<HeaderAndBody>

onLoadFinished

public void onLoadFinished(android.content.Loader<HeaderAndBody> loader,
                           HeaderAndBody data)
This method will call the Callback for a enroll, login, or logout method on the main thread of the application. If a callback is an instance of AbstractFragmentCallback or AbstractActivityCallback then it will also configure the reference to Fragment or FragmentActivity for the callback.

Specified by:
onLoadFinished in interface android.app.LoaderManager.LoaderCallbacks<HeaderAndBody>

onLoaderReset

public void onLoaderReset(android.content.Loader<HeaderAndBody> loader)
Specified by:
onLoaderReset in interface android.app.LoaderManager.LoaderCallbacks<HeaderAndBody>

AeroGear Android Library 1.1.0

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