Package org.openstreetmap.josm.io.auth
Class AbstractCredentialsAgent
- java.lang.Object
-
- org.openstreetmap.josm.io.auth.AbstractCredentialsAgent
-
- All Implemented Interfaces:
CredentialsAgent
- Direct Known Subclasses:
JosmPreferencesCredentialAgent
public abstract class AbstractCredentialsAgent extends java.lang.Object implements CredentialsAgent
Partial implementation of theCredentialsAgent
interface.Provides a memory cache for the credentials and means to query the information from the user.
- Since:
- 4246
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
AbstractCredentialsAgent.CredentialsProvider
Synchronous credentials provider.
-
Field Summary
Fields Modifier and Type Field Description private static AbstractCredentialsAgent.CredentialsProvider
credentialsProvider
protected java.util.Map<Pair<java.net.Authenticator.RequestorType,java.lang.String>,java.net.PasswordAuthentication>
memoryCredentialsCache
-
Constructor Summary
Constructors Constructor Description AbstractCredentialsAgent()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CredentialsAgentResponse
getCredentials(java.net.Authenticator.RequestorType requestorType, java.lang.String host, boolean noSuccessWithLastResponse)
Returns the credentials needed to to access host.abstract java.lang.String
getSaveUsernameAndPasswordCheckboxText()
Provide the text for a checkbox that offers to save the username and password that has been entered by the user.void
purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType)
Purges the internal credentials cache for the given requestor type.void
purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType, java.lang.String host)
Purges the internal credentials cache for the given requestor type and host.static void
setCredentialsProvider(AbstractCredentialsAgent.CredentialsProvider provider)
Sets the global credentials provider.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openstreetmap.josm.io.auth.CredentialsAgent
getPreferencesDecorationPanel, lookup, lookupOAuthAccessToken, store, storeOAuthAccessToken
-
-
-
-
Field Detail
-
credentialsProvider
private static volatile AbstractCredentialsAgent.CredentialsProvider credentialsProvider
-
memoryCredentialsCache
protected java.util.Map<Pair<java.net.Authenticator.RequestorType,java.lang.String>,java.net.PasswordAuthentication> memoryCredentialsCache
-
-
Constructor Detail
-
AbstractCredentialsAgent
public AbstractCredentialsAgent()
-
-
Method Detail
-
setCredentialsProvider
public static void setCredentialsProvider(AbstractCredentialsAgent.CredentialsProvider provider)
Sets the global credentials provider.- Parameters:
provider
- credentials provider. Called if no credentials are cached. Can be used for user login prompt
-
getCredentials
public CredentialsAgentResponse getCredentials(java.net.Authenticator.RequestorType requestorType, java.lang.String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException
Description copied from interface:CredentialsAgent
Returns the credentials needed to to access host.- Specified by:
getCredentials
in interfaceCredentialsAgent
- Parameters:
requestorType
- the type of service.Authenticator.RequestorType.SERVER
for the OSM API server,Authenticator.RequestorType.PROXY
for 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
-
purgeCredentialsCache
public final void purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType)
Description copied from interface:CredentialsAgent
Purges the internal credentials cache for the given requestor type.- Specified by:
purgeCredentialsCache
in interfaceCredentialsAgent
- Parameters:
requestorType
- the type of service.Authenticator.RequestorType.PROXY
for a proxy server,Authenticator.RequestorType.SERVER
for other servers.
-
purgeCredentialsCache
public void purgeCredentialsCache(java.net.Authenticator.RequestorType requestorType, java.lang.String host)
Description copied from interface:CredentialsAgent
Purges the internal credentials cache for the given requestor type and host.- Specified by:
purgeCredentialsCache
in interfaceCredentialsAgent
- Parameters:
requestorType
- the type of service.host
- the host.Authenticator.RequestorType.PROXY
for a proxy server,Authenticator.RequestorType.SERVER
for other servers.
-
getSaveUsernameAndPasswordCheckboxText
public abstract java.lang.String getSaveUsernameAndPasswordCheckboxText()
Provide the text for a checkbox that offers to save the username and password that has been entered by the user.- Returns:
- checkbox text
-
-