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 booleanenabledprivate java.util.Collection<Pair<java.lang.String,java.net.Authenticator.RequestorType>>failedCredentialsprivate static DefaultAuthenticatorINSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description privateDefaultAuthenticator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddFailedCredentialHost(java.lang.String host)Marks for this host that the authentication failed, i.e., theCredentialsManagerwill show a dialog at the next time.static DefaultAuthenticatorgetInstance()Returns the unique instanceprotected java.net.PasswordAuthenticationgetPasswordAuthentication()Called by the Java HTTP stack when either the OSM API server or a proxy requires authentication.booleanisEnabled()Determines whether this authenticator is enabled, i.e., providespassword authenticationviaCredentialsManager.booleanremoveFailedCredentialHost(java.lang.String host)Un-marks the failed authentication attempt for the hostvoidsetEnabled(boolean enabled)Enabled/disables this authenticator, i.e., decides whether it should providepassword authenticationviaCredentialsManager.-
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:
getPasswordAuthenticationin classjava.net.Authenticator
-
isEnabled
public boolean isEnabled()
Determines whether this authenticator is enabled, i.e., providespassword authenticationviaCredentialsManager.- Returns:
- whether this authenticator is enabled
-
setEnabled
public void setEnabled(boolean enabled)
Enabled/disables this authenticator, i.e., decides whether it should providepassword authenticationviaCredentialsManager.- 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., theCredentialsManagerwill 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)
-
-