Package org.openstreetmap.josm.io.auth
Interface CredentialsAgent
-
- All Known Implementing Classes:
AbstractCredentialsAgent,CredentialsManager,JosmPreferencesCredentialAgent
public interface CredentialsAgent
A CredentialsAgent manages two credentials:- the credential for
Authenticator.RequestorType.SERVERwhich is equal to the OSM API credentials in JOSM - the credential for
Authenticator.RequestorType.PROXYwhich is equal to the credentials for an optional HTTP proxy server a user may use
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description CredentialsAgentResponsegetCredentials(java.net.Authenticator.RequestorType requestorType, java.lang.String host, boolean noSuccessWithLastResponse)Returns the credentials needed to to access host.java.awt.ComponentgetPreferencesDecorationPanel()Provide a Panel that is shown below the API password / username fields in the JOSM Preferences.java.net.PasswordAuthenticationlookup(java.net.Authenticator.RequestorType requestorType, java.lang.String host)Looks up the credentials for a given type.IOAuthTokenlookupOAuthAccessToken(java.lang.String host)Lookup the current OAuth Access Token to access the specified server.voidpurgeCredentialsCache(java.net.Authenticator.RequestorType requestorType)Purges the internal credentials cache for the given requestor type.default voidpurgeCredentialsCache(java.net.Authenticator.RequestorType requestorType, java.lang.String host)Purges the internal credentials cache for the given requestor type and host.voidstore(java.net.Authenticator.RequestorType requestorType, java.lang.String host, java.net.PasswordAuthentication credentials)Saves the credentials incredentialsfor the given service type.voidstoreOAuthAccessToken(java.lang.String host, IOAuthToken accessToken)Stores the OAuth Access TokenaccessToken.
-
-
-
Method Detail
-
lookup
java.net.PasswordAuthentication lookup(java.net.Authenticator.RequestorType requestorType, java.lang.String host) throws CredentialsAgentException
Looks up the credentials for a given type.- 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
void store(java.net.Authenticator.RequestorType requestorType, java.lang.String host, java.net.PasswordAuthentication credentials) throws CredentialsAgentException
Saves the credentials incredentialsfor the given service type.- 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
CredentialsAgentResponse getCredentials(java.net.Authenticator.RequestorType requestorType, java.lang.String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException
Returns the credentials needed to to access host.- 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
@Nullable IOAuthToken lookupOAuthAccessToken(java.lang.String host) throws CredentialsAgentException
Lookup the current OAuth Access Token to access the specified server. Replies null, if no Access Token is currently managed by this CredentialAgent.- 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- Since:
- 18650
-
storeOAuthAccessToken
void storeOAuthAccessToken(java.lang.String host, IOAuthToken accessToken) throws CredentialsAgentException
Stores the OAuth Access TokenaccessToken.- 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 bystoreOAuthAccessToken(String, IOAuthToken).- Throws:
CredentialsAgentException- if something goes wrong- Since:
- 18650
-
purgeCredentialsCache
void purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType)
Purges the internal credentials cache for the given requestor type.- Parameters:
requestorType- the type of service.Authenticator.RequestorType.PROXYfor a proxy server,Authenticator.RequestorType.SERVERfor other servers.- Since:
- 12992
-
purgeCredentialsCache
default void purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType, java.lang.String host)
Purges the internal credentials cache for the given requestor type and host.- Parameters:
requestorType- the type of service.host- the host.Authenticator.RequestorType.PROXYfor a proxy server,Authenticator.RequestorType.SERVERfor other servers.
-
getPreferencesDecorationPanel
java.awt.Component getPreferencesDecorationPanel()
Provide a Panel that is shown below the API password / username fields in the JOSM Preferences. (E.g. a warning that password is saved unencrypted.)- Returns:
- Panel
-
-