Class OAuthAccessTokenHolder
java.lang.Object
org.openstreetmap.josm.data.oauth.OAuthAccessTokenHolder
Class holding OAuth access token key and secret.
- Since:
- 12686 (moved from
gui.preferences.serverpackage)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static OAuthAccessTokenHolderprivate booleanprivate final Map<String,Map<OAuthVersion, IOAuthToken>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears the content of this holdergetAccessToken(String api, OAuthVersion version) Replies the access token.static OAuthAccessTokenHolderReplies the unique instance.voidinit(CredentialsAgent cm) Initializes the content of this holder from the Access Token managed by the credential manager.booleanReplies true if current access token should be saved to the preferences file.voidsave(CredentialsAgent cm) Saves the content of this holder to the preferences and a credential store managed by a credential manager.voidsetAccessToken(String api, IOAuthToken token) Sets the access token hold by this holder.voidsetSaveToPreferences(boolean saveToPreferences) Sets whether the current access token should be saved to the preferences file.
-
Field Details
-
instance
-
saveToPreferences
-
tokenMap
-
-
Constructor Details
-
OAuthAccessTokenHolder
public OAuthAccessTokenHolder()
-
-
Method Details
-
getInstance
Replies the unique instance.- Returns:
- The unique instance of
OAuthAccessTokenHolder
-
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
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-trueto save to preferences file
-
getAccessToken
Replies the access token.- Parameters:
api- The api the token is forversion- The OAuth version the token is for- Returns:
- the access token, can be
null - Since:
- 18650
-
setAccessToken
Sets the access token hold by this holder.- Parameters:
api- The api the token is fortoken- the access token. Can be null to clear the content in this holder.- Since:
- 18650
-
init
Initializes the content of this holder from the Access Token managed by the credential manager.- Parameters:
cm- the credential manager. Must not be null.- Throws:
IllegalArgumentException- if cm is null
-
save
Saves the content of this holder to the preferences and a credential store managed by a credential manager.- Parameters:
cm- the credentials manager. Must not be null.- Throws:
IllegalArgumentException- if cm is null
-
clear
Clears the content of this holder
-