public class OAuthAccessTokenHolder extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
accessTokenKey |
private java.lang.String |
accessTokenSecret |
private static OAuthAccessTokenHolder |
instance |
private boolean |
saveToPreferences |
Constructor and Description |
---|
OAuthAccessTokenHolder() |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the content of this holder
|
boolean |
containsAccessToken()
Replies true if this holder contains an complete access token, consisting of an
Access Token Key and an Access Token Secret.
|
OAuthToken |
getAccessToken()
Replies the access token.
|
java.lang.String |
getAccessTokenKey()
Replies the access token key.
|
java.lang.String |
getAccessTokenSecret()
Replies the access token secret.
|
static OAuthAccessTokenHolder |
getInstance()
Replies the unique instance.
|
void |
init(Preferences pref,
CredentialsAgent cm)
Initializes the content of this holder from the Access Token managed by the
credential manager.
|
boolean |
isSaveToPreferences()
Replies true if current access token should be saved to the preferences file.
|
void |
save(Preferences preferences,
CredentialsAgent cm)
Saves the content of this holder to the preferences and a credential store managed
by a credential manager.
|
void |
setAccessToken(OAuthToken token)
Sets the access token hold by this holder.
|
void |
setAccessToken(java.lang.String accessTokenKey,
java.lang.String accessTokenSecret)
Sets the access token hold by this holder.
|
void |
setAccessTokenKey(java.lang.String accessTokenKey)
Sets the access token key.
|
void |
setAccessTokenSecret(java.lang.String accessTokenSecret)
Sets the access token secret.
|
void |
setSaveToPreferences(boolean saveToPreferences)
Sets whether the current access token should be saved to the preferences file.
|
private static OAuthAccessTokenHolder instance
private boolean saveToPreferences
private java.lang.String accessTokenKey
private java.lang.String accessTokenSecret
public OAuthAccessTokenHolder()
public static OAuthAccessTokenHolder getInstance()
OAuthAccessTokenHolder
public boolean isSaveToPreferences()
public void setSaveToPreferences(boolean saveToPreferences)
saveToPreferences
- true
to save to preferences filepublic java.lang.String getAccessTokenKey()
public void setAccessTokenKey(java.lang.String accessTokenKey)
accessTokenKey
- the access token keypublic java.lang.String getAccessTokenSecret()
public void setAccessTokenSecret(java.lang.String accessTokenSecret)
accessTokenSecret
- access token secret, or nullpublic OAuthToken getAccessToken()
null
public void setAccessToken(java.lang.String accessTokenKey, java.lang.String accessTokenSecret)
accessTokenKey
- the access token keyaccessTokenSecret
- the access token secretpublic void setAccessToken(OAuthToken token)
token
- the access token. Can be null to clear the content in this holder.public boolean containsAccessToken()
public void init(Preferences pref, CredentialsAgent cm)
pref
- the preferences. Must not be null.cm
- the credential manager. Must not be null.java.lang.IllegalArgumentException
- if cm is nullpublic void save(Preferences preferences, CredentialsAgent cm)
preferences
- the preferences. Must not be null.cm
- the credentials manager. Must not be null.java.lang.IllegalArgumentException
- if preferences is nulljava.lang.IllegalArgumentException
- if cm is nullpublic void clear()