com.duowan.mobile.netroid.toolbox
Class AndroidAuthenticator

java.lang.Object
  extended by com.duowan.mobile.netroid.toolbox.AndroidAuthenticator
All Implemented Interfaces:
Authenticator

public class AndroidAuthenticator
extends java.lang.Object
implements Authenticator

An Authenticator that uses AccountManager to get auth tokens of a specified type for a specified account.


Constructor Summary
AndroidAuthenticator(android.content.Context context, android.accounts.Account account, java.lang.String authTokenType)
          Creates a new authenticator.
AndroidAuthenticator(android.content.Context context, android.accounts.Account account, java.lang.String authTokenType, boolean notifyAuthFailure)
          Creates a new authenticator.
 
Method Summary
 android.accounts.Account getAccount()
          Returns the Account being used by this authenticator.
 java.lang.String getAuthToken()
          Synchronously retrieves an auth token.
 void invalidateAuthToken(java.lang.String authToken)
          Invalidates the provided auth token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndroidAuthenticator

public AndroidAuthenticator(android.content.Context context,
                            android.accounts.Account account,
                            java.lang.String authTokenType)
Creates a new authenticator.

Parameters:
context - Context for accessing AccountManager
account - Account to authenticate as
authTokenType - Auth token type passed to AccountManager

AndroidAuthenticator

public AndroidAuthenticator(android.content.Context context,
                            android.accounts.Account account,
                            java.lang.String authTokenType,
                            boolean notifyAuthFailure)
Creates a new authenticator.

Parameters:
context - Context for accessing AccountManager
account - Account to authenticate as
authTokenType - Auth token type passed to AccountManager
notifyAuthFailure - Whether to raise a notification upon auth failure
Method Detail

getAccount

public android.accounts.Account getAccount()
Returns the Account being used by this authenticator.


getAuthToken

public java.lang.String getAuthToken()
                              throws AuthFailureError
Description copied from interface: Authenticator
Synchronously retrieves an auth token.

Specified by:
getAuthToken in interface Authenticator
Throws:
AuthFailureError - If authentication did not succeed

invalidateAuthToken

public void invalidateAuthToken(java.lang.String authToken)
Description copied from interface: Authenticator
Invalidates the provided auth token.

Specified by:
invalidateAuthToken in interface Authenticator