AeroGear Android Library 1.1.0

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

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

public class HttpBasicAuthenticationModule
extends AbstractAuthenticationModule

This class provides Authentication using HTTP Basic 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
HttpBasicAuthenticationModule(URL baseURL)
           
 
Method Summary
 void enroll(Map<String,String> userData, Callback<HeaderAndBody> callback)
          Enrolling is not supported using http basic.
 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)
          This method stores username and password.
 void logout(Callback<Void> callback)
          This method clears the username and password from the module, sets isLoggedIn to false, and removes all cookies associated with baseURL This method always calls Callback.onSuccess(java.lang.Object)
 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

HttpBasicAuthenticationModule

public HttpBasicAuthenticationModule(URL baseURL)
Parameters:
baseURL - The base URL shared by a Pipe.
Method Detail

getBaseURL

public URL getBaseURL()

getLoginEndpoint

public String getLoginEndpoint()

getLogoutEndpoint

public String getLogoutEndpoint()

getEnrollEndpoint

public String getEnrollEndpoint()

isLoggedIn

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

login

public void login(String username,
                  String password,
                  Callback<HeaderAndBody> callback)
This method stores username and password. Additionally, it sets isLoggedIn to true and calls Callback.onSuccess(java.lang.Object).

Specified by:
login in interface AuthenticationModule
Overrides:
login in class AbstractAuthenticationModule
Parameters:
username -
password -
callback -

logout

public void logout(Callback<Void> callback)
This method clears the username and password from the module, sets isLoggedIn to false, and removes all cookies associated with baseURL This method always calls Callback.onSuccess(java.lang.Object)

Specified by:
logout in interface AuthenticationModule
Overrides:
logout in class AbstractAuthenticationModule
Parameters:
callback -

enroll

public void enroll(Map<String,String> userData,
                   Callback<HeaderAndBody> callback)
Enrolling is not supported using http basic. This method will call Callback.onFailure(java.lang.Exception) and pass it a UnsupportedOperationException.

Specified by:
enroll in interface AuthenticationModule
Overrides:
enroll in class AbstractAuthenticationModule
Parameters:
userData - this value is ignored.
callback -

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.