public class UserAccount extends Object
Accounts via
UserAccountManager. Each instance of UserAccount must be created with name and
password that are essential for creation of instance of Account.
There can be specified also additional data for each user account instance either via putData(String, String)
or setDataBundle(Bundle) including authentication tokens via putAuthToken(String, String).
Note, that getAuthTokenTypes() method should always return array of token types
that are specific for a particular type of UserAccount implementation. This array is used by
UserAccountManager to iterate types Map (getAuthTokens()) and obtain all token
data from it and store it for the associated Account via AccountManager.setAuthToken(Account, String, String).
| Modifier and Type | Field and Description |
|---|---|
protected static String[] |
AUTH_TOKEN_TYPES
Array specifying set of default authentication token types.
|
protected String |
mName
Name specified for this user account.
|
protected String |
mPassword
Password specified for this user account.
|
static String |
TOKEN_TYPE_O_AUTH
Type key for the OAuth token.
|
| Constructor and Description |
|---|
UserAccount(String name)
Same as
UserAccount(String, String) with null password. |
UserAccount(String name,
String password)
Creates a new instance of UserAccount with the specified name and password.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
String |
getAuthToken(String tokenType)
Returns the authentication token specified for this user account for the requested tokenType.
|
protected Map<String,String> |
getAuthTokens()
Returns the map with authentication tokens specified for this user account mapped to theirs
types.
|
protected String[] |
getAuthTokenTypes()
Returns the types of authentication tokens specific for this user account.
|
String |
getData(String key)
Returns the data value contained within data bundle of this user account under the specified
key.
|
Bundle |
getDataBundle()
Returns the data bundle of this user account
|
String |
getName()
Returns the name specified for this user account.
|
String |
getOAuthToken()
Same as
getAuthToken(String) with TOKEN_TYPE_O_AUTH as tokenType. |
String |
getPassword()
Returns the password specified for this user account.
|
boolean |
hasAuthToken(String tokenType)
Checks whether there is authentication token specified for this user account for the specified
tokenType.
|
boolean |
hasData(String key)
Checks whether this account has data with the specified key associated.
|
int |
hashCode() |
void |
putAuthToken(String tokenType,
String token)
Puts the given token into authentication tokens of this user account under the
specified tokenType as key.
|
void |
putData(String key,
String data)
Puts the given data into data bundle of this user account under the specified
key.
|
void |
putOAuthToken(String authToken)
Same as
putAuthToken(String, String) with TOKEN_TYPE_O_AUTH as tokenType. |
void |
removeData(String key)
Removes the data specified for this account for the specified key.
|
void |
setDataBundle(Bundle dataBundle)
Sets a data bundle for this user account.
|
void |
setPassword(String password)
Sets a new password for this account.
|
public static final String TOKEN_TYPE_O_AUTH
protected static final String[] AUTH_TOKEN_TYPES
Contains single TOKEN_TYPE_O_AUTH key.
protected final String mName
protected String mPassword
public UserAccount(@NonNull String name)
UserAccount(String, String) with null password.name - The desired name for the new account.@NonNull public final String getName()
UserAccount(String),
UserAccount(String, String)public final void setPassword(@Nullable String password)
password - The desired new password. May be null to clear the current one.UserAccount(String, String),
getPassword()@Nullable public final String getPassword()
null.setPassword(String)public void putData(@NonNull String key, @Nullable String data)
key - The key under which to map the given data value.data - The desired data to put into bundle.getData(String),
getDataBundle()public boolean hasData(@NonNull String key)
key - The key of the desired data to check.True if this account has data with the key, false otherwise.putData(String, String)@Nullable public String getData(@NonNull String key)
key - The key for which to obtain the desired data.null if there is no such value mapped for
that key.putData(String, String),
hasData(String),
getDataBundle()public void removeData(@NonNull String key)
key - The key for which to remove the desired data.putData(String, String),
hasData(String)public void setDataBundle(@Nullable Bundle dataBundle)
dataBundle - The desired bundle with user data. May be null to clear the current
bundle.putData(String, String),
getData(String)@Nullable public Bundle getDataBundle()
setDataBundle(Bundle) or separately
via putData(String, String) or null if there is no data bundle available.setDataBundle(Bundle),
getData(String)public void putOAuthToken(@Nullable String authToken)
putAuthToken(String, String) with TOKEN_TYPE_O_AUTH as tokenType.authToken - The desired OAuth token. May be null to clear the previous one.public void putAuthToken(@Nullable String tokenType, @Nullable String token)
tokenType - The desired type of the given token.token - The desired authentication token. May be null to clear the previous one.getAuthToken(String),
getAuthTokens()public boolean hasAuthToken(@Nullable String tokenType)
tokenType - Type of the desired token to check if it is specified for this account.True if putAuthToken(String, String) has been called with the
tokenType, false otherwise.@Nullable public String getOAuthToken()
getAuthToken(String) with TOKEN_TYPE_O_AUTH as tokenType.@Nullable public String getAuthToken(@Nullable String tokenType)
tokenType - Type of the desired token to obtain.null if there is no token specified
for that type.@Nullable protected String[] getAuthTokenTypes()
@Nullable protected Map<String,String> getAuthTokens()
null if there are no tokens specified
yet.putAuthToken(String, String),
getAuthToken(String)