Package org.openstreetmap.josm.io.auth
Class DefaultAuthenticator
- java.lang.Object
-
- java.net.Authenticator
-
- org.openstreetmap.josm.io.auth.DefaultAuthenticator
-
public final class DefaultAuthenticator extends java.net.Authenticator
This is the default authenticator used in JOSM. It delegates lookup of credentials for the OSM API and an optional proxy server to the currently configuredCredentialsManager
.- Since:
- 2641
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
enabled
private java.util.Collection<Pair<java.lang.String,java.net.Authenticator.RequestorType>>
failedCredentials
private static DefaultAuthenticator
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
DefaultAuthenticator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addFailedCredentialHost(java.lang.String host)
Marks for this host that the authentication failed, i.e., theCredentialsManager
will show a dialog at the next time.static DefaultAuthenticator
getInstance()
Returns the unique instanceprotected java.net.PasswordAuthentication
getPasswordAuthentication()
Called by the Java HTTP stack when either the OSM API server or a proxy requires authentication.boolean
isEnabled()
Determines whether this authenticator is enabled, i.e., providespassword authentication
viaCredentialsManager
.boolean
removeFailedCredentialHost(java.lang.String host)
Un-marks the failed authentication attempt for the hostvoid
setEnabled(boolean enabled)
Enabled/disables this authenticator, i.e., decides whether it should providepassword authentication
viaCredentialsManager
.-
Methods inherited from class java.net.Authenticator
getDefault, getRequestingHost, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingScheme, getRequestingSite, getRequestingURL, getRequestorType, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthenticationInstance, setDefault
-
-
-
-
Field Detail
-
INSTANCE
private static final DefaultAuthenticator INSTANCE
-
failedCredentials
private final java.util.Collection<Pair<java.lang.String,java.net.Authenticator.RequestorType>> failedCredentials
-
enabled
private boolean enabled
-
-
Constructor Detail
-
DefaultAuthenticator
private DefaultAuthenticator()
-
-
Method Detail
-
getInstance
public static DefaultAuthenticator getInstance()
Returns the unique instance- Returns:
- The unique instance
-
getPasswordAuthentication
protected java.net.PasswordAuthentication getPasswordAuthentication()
Called by the Java HTTP stack when either the OSM API server or a proxy requires authentication.- Overrides:
getPasswordAuthentication
in classjava.net.Authenticator
-
isEnabled
public boolean isEnabled()
Determines whether this authenticator is enabled, i.e., providespassword authentication
viaCredentialsManager
.- Returns:
- whether this authenticator is enabled
-
setEnabled
public void setEnabled(boolean enabled)
Enabled/disables this authenticator, i.e., decides whether it should providepassword authentication
viaCredentialsManager
.- Parameters:
enabled
- whether this authenticator should be enabled
-
addFailedCredentialHost
public boolean addFailedCredentialHost(java.lang.String host)
Marks for this host that the authentication failed, i.e., theCredentialsManager
will show a dialog at the next time.- Parameters:
host
- the host to mark- Returns:
- as per
Collection.add(Object)
-
removeFailedCredentialHost
public boolean removeFailedCredentialHost(java.lang.String host)
Un-marks the failed authentication attempt for the host- Parameters:
host
- the host to un-mark- Returns:
- as per
Collection.remove(Object)
-
-