Package org.openstreetmap.josm.io.auth
Class CredentialsManager
java.lang.Object
org.openstreetmap.josm.io.auth.CredentialsManager
- All Implemented Interfaces:
CredentialsAgent
CredentialManager is a factory for the single credential agent used.
Currently, it defaults to replying an instance of JosmPreferencesCredentialAgent.
- Since:
- 2641
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCredentials agent factory. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static CredentialsManager.CredentialsAgentFactoryprivate final CredentialsAgentThe credentials agent doing the real stuffprivate static CredentialsManager -
Constructor Summary
ConstructorsConstructorDescriptionCredentialsManager(CredentialsAgent delegate) Constructs a newCredentialsManager. -
Method Summary
Modifier and TypeMethodDescriptiongetCredentials(Authenticator.RequestorType requestorType, String host, boolean noSuccessWithLastResponse) Returns the credentials needed to to access host.final Class<? extends CredentialsAgent>Returns type of credentials agent backing this credentials manager.static CredentialsManagerReplies the single credential agent used in JOSMProvide a Panel that is shown below the API password / username fields in the JOSM Preferences.Returns the username for OSM APIgetUsername(String host) Returns the username for a given hostlookup(Authenticator.RequestorType requestorType, String host) Looks up the credentials for a given type.lookupOAuthAccessToken(String host) Lookup the current OAuth Access Token to access the specified server.voidpurgeCredentialsCache(Authenticator.RequestorType requestorType) Purges the internal credentials cache for the given requestor type.voidpurgeCredentialsCache(Authenticator.RequestorType requestorType, String host) Purges the internal credentials cache for the given requestor type and host.static voidPlugins can register a CredentialsAgentFactory, thereby overriding JOSM's default credentials agent.voidstore(Authenticator.RequestorType requestorType, String host, PasswordAuthentication credentials) Saves the credentials incredentialsfor the given service type.voidstoreOAuthAccessToken(String host, IOAuthToken accessToken) Stores the OAuth Access TokenaccessToken.
-
Field Details
-
instance
-
agentFactory
-
delegate
The credentials agent doing the real stuff
-
-
Constructor Details
-
CredentialsManager
Constructs a newCredentialsManager.- Parameters:
delegate- The credentials agent backing this credential manager. Must not benull
-
-
Method Details
-
getInstance
Replies the single credential agent used in JOSM- Returns:
- the single credential agent used in JOSM
-
registerCredentialsAgentFactory
public static void registerCredentialsAgentFactory(CredentialsManager.CredentialsAgentFactory agentFactory) Plugins can register a CredentialsAgentFactory, thereby overriding JOSM's default credentials agent.- Parameters:
agentFactory- The Factory that provides the custom CredentialsAgent. Can be null to clear the factory and switch back to default behavior.
-
getCredentialsAgentClass
Returns type of credentials agent backing this credentials manager.- Returns:
- The type of credentials agent
-
getUsername
Returns the username for OSM API- Returns:
- the username for OSM API
-
getUsername
Returns the username for a given host- Parameters:
host- The host for which username is wanted- Returns:
- The username for
host
-
lookup
public PasswordAuthentication lookup(Authenticator.RequestorType requestorType, String host) throws CredentialsAgentException Description copied from interface:CredentialsAgentLooks up the credentials for a given type.- Specified by:
lookupin interfaceCredentialsAgent- Parameters:
requestorType- the type of service.Authenticator.RequestorType.SERVERfor the OSM API server,Authenticator.RequestorType.PROXYfor a proxy serverhost- the hostname for these credentials- Returns:
- the credentials
- Throws:
CredentialsAgentException- if a problem occurs in a implementation of this interface
-
store
public void store(Authenticator.RequestorType requestorType, String host, PasswordAuthentication credentials) throws CredentialsAgentException Description copied from interface:CredentialsAgentSaves the credentials incredentialsfor the given service type.- Specified by:
storein interfaceCredentialsAgent- Parameters:
requestorType- the type of service.Authenticator.RequestorType.SERVERfor the OSM API server,Authenticator.RequestorType.PROXYfor a proxy serverhost- the hostname for these credentialscredentials- the credentials- Throws:
CredentialsAgentException- if a problem occurs in a implementation of this interface
-
getCredentials
public CredentialsAgentResponse getCredentials(Authenticator.RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException Description copied from interface:CredentialsAgentReturns the credentials needed to to access host.- Specified by:
getCredentialsin interfaceCredentialsAgent- Parameters:
requestorType- the type of service.Authenticator.RequestorType.SERVERfor the OSM API server,Authenticator.RequestorType.PROXYfor a proxy serverhost- the hostname for these credentialsnoSuccessWithLastResponse- true, if the last request with the supplied credentials failed; false otherwise. If true, implementations of this interface are advised to prompt the user for new credentials.- Returns:
- the credentials
- Throws:
CredentialsAgentException- if a problem occurs in a implementation of this interface
-
lookupOAuthAccessToken
Description copied from interface:CredentialsAgentLookup the current OAuth Access Token to access the specified server. Replies null, if no Access Token is currently managed by this CredentialAgent.- Specified by:
lookupOAuthAccessTokenin interfaceCredentialsAgent- Parameters:
host- The host to get OAuth credentials for- Returns:
- the current OAuth Access Token to access the specified server.
- Throws:
CredentialsAgentException- if something goes wrong
-
storeOAuthAccessToken
public void storeOAuthAccessToken(String host, IOAuthToken accessToken) throws CredentialsAgentException Description copied from interface:CredentialsAgentStores the OAuth Access TokenaccessToken.- Specified by:
storeOAuthAccessTokenin interfaceCredentialsAgent- Parameters:
host- The host the access token is foraccessToken- the access Token. null, to remove the Access Token. This will remove all IOAuthTokens not managed byCredentialsAgent.storeOAuthAccessToken(String, IOAuthToken).- Throws:
CredentialsAgentException- if something goes wrong
-
getPreferencesDecorationPanel
Description copied from interface:CredentialsAgentProvide a Panel that is shown below the API password / username fields in the JOSM Preferences. (E.g. a warning that password is saved unencrypted.)- Specified by:
getPreferencesDecorationPanelin interfaceCredentialsAgent- Returns:
- Panel
-
purgeCredentialsCache
Description copied from interface:CredentialsAgentPurges the internal credentials cache for the given requestor type.- Specified by:
purgeCredentialsCachein interfaceCredentialsAgent- Parameters:
requestorType- the type of service.Authenticator.RequestorType.PROXYfor a proxy server,Authenticator.RequestorType.SERVERfor other servers.
-
purgeCredentialsCache
Description copied from interface:CredentialsAgentPurges the internal credentials cache for the given requestor type and host.- Specified by:
purgeCredentialsCachein interfaceCredentialsAgent- Parameters:
requestorType- the type of service.host- the host.Authenticator.RequestorType.PROXYfor a proxy server,Authenticator.RequestorType.SERVERfor other servers.
-