org.openstreetmap.josm.gui.preferences.server
Class OAuthAccessTokenHolder

java.lang.Object
  extended by org.openstreetmap.josm.gui.preferences.server.OAuthAccessTokenHolder

public class OAuthAccessTokenHolder
extends java.lang.Object


Field Summary
private  java.lang.String accessTokenKey
           
private  java.lang.String accessTokenSecret
           
private static OAuthAccessTokenHolder instance
           
private  boolean saveToPreferences
           
 
Constructor Summary
OAuthAccessTokenHolder()
           
 
Method Summary
 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()
           
 java.lang.String getAccessTokenKey()
          Replies the access token key.
 java.lang.String getAccessTokenSecret()
          Replies the access token secret.
static OAuthAccessTokenHolder getInstance()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

private static OAuthAccessTokenHolder instance

saveToPreferences

private boolean saveToPreferences

accessTokenKey

private java.lang.String accessTokenKey

accessTokenSecret

private java.lang.String accessTokenSecret
Constructor Detail

OAuthAccessTokenHolder

public OAuthAccessTokenHolder()
Method Detail

getInstance

public static OAuthAccessTokenHolder getInstance()

isSaveToPreferences

public boolean isSaveToPreferences()
Replies true if current access token should be saved to the preferences file.

Returns:
true if current access token should be saved to the preferences file.

setSaveToPreferences

public void setSaveToPreferences(boolean saveToPreferences)
Sets whether the current access token should be saved to the preferences file. If true, the access token is saved in clear text to the preferences file. The same access token can therefore be used in multiple JOSM sessions. If false, the access token isn't saved to the preferences file. If JOSM is closed, the access token is lost and new token has to be generated by the OSM server the next time JOSM is used.

Parameters:
saveToPreferences -

getAccessTokenKey

public java.lang.String getAccessTokenKey()
Replies the access token key. null, if no access token key is currently set.

Returns:
the access token key

setAccessTokenKey

public void setAccessTokenKey(java.lang.String accessTokenKey)
Sets the access token key. Pass in null to remove the current access token key.

Parameters:
accessTokenKey - the access token key

getAccessTokenSecret

public java.lang.String getAccessTokenSecret()
Replies the access token secret. null, if no access token secret is currently set.

Returns:
the access token secret

setAccessTokenSecret

public void setAccessTokenSecret(java.lang.String accessTokenSecret)
Sets the access token secret. Pass in null to remove the current access token secret.

Parameters:
accessTokenSecret -

getAccessToken

public OAuthToken getAccessToken()

setAccessToken

public void setAccessToken(java.lang.String accessTokenKey,
                           java.lang.String accessTokenSecret)
Sets the access token hold by this holder.

Parameters:
accessTokenKey - the access token key
accessTokenSecret - the access token secret

setAccessToken

public void setAccessToken(OAuthToken token)
Sets the access token hold by this holder.

Parameters:
token - the access token. Can be null to clear the content in this holder.

containsAccessToken

public boolean containsAccessToken()
Replies true if this holder contains an complete access token, consisting of an Access Token Key and an Access Token Secret.

Returns:
true if this holder contains an complete access token

init

public void init(Preferences pref,
                 CredentialsAgent cm)
          throws java.lang.IllegalArgumentException
Initializes the content of this holder from the Access Token managed by the credential manager.

Parameters:
pref - the preferences. Must not be null.
cm - the credential manager. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if cm is null

save

public void save(Preferences preferences,
                 CredentialsAgent cm)
          throws java.lang.IllegalArgumentException
Saves the content of this holder to the preferences and a credential store managed by a credential manager.

Parameters:
preferences - the preferences. Must not be null.
cm - the credentials manager. Must not be null.
Throws:
java.lang.IllegalArgumentException - thrown if preferences is null
java.lang.IllegalArgumentException - thrown if cm is null

clear

public void clear()
Clears the content of this holder



JOSM