Class CredentialsManager

    • Constructor Detail

      • CredentialsManager

        public CredentialsManager​(CredentialsAgent delegate)
        Constructs a new CredentialsManager.
        Parameters:
        delegate - The credentials agent backing this credential manager. Must not be null
    • Method Detail

      • getInstance

        public static CredentialsManager 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

        public final java.lang.Class<? extends CredentialsAgentgetCredentialsAgentClass()
        Returns type of credentials agent backing this credentials manager.
        Returns:
        The type of credentials agent
      • getUsername

        public java.lang.String getUsername()
        Returns the username for OSM API
        Returns:
        the username for OSM API
      • getUsername

        public java.lang.String getUsername​(java.lang.String host)
        Returns the username for a given host
        Parameters:
        host - The host for which username is wanted
        Returns:
        The username for host
      • lookup

        public java.net.PasswordAuthentication lookup​(java.net.Authenticator.RequestorType requestorType,
                                                      java.lang.String host)
                                               throws CredentialsAgentException
        Description copied from interface: CredentialsAgent
        Looks up the credentials for a given type.
        Specified by:
        lookup in interface CredentialsAgent
        Parameters:
        requestorType - the type of service. Authenticator.RequestorType.SERVER for the OSM API server, Authenticator.RequestorType.PROXY for a proxy server
        host - the hostname for these credentials
        Returns:
        the credentials
        Throws:
        CredentialsAgentException - if a problem occurs in a implementation of this interface
      • store

        public void store​(java.net.Authenticator.RequestorType requestorType,
                          java.lang.String host,
                          java.net.PasswordAuthentication credentials)
                   throws CredentialsAgentException
        Description copied from interface: CredentialsAgent
        Saves the credentials in credentials for the given service type.
        Specified by:
        store in interface CredentialsAgent
        Parameters:
        requestorType - the type of service. Authenticator.RequestorType.SERVER for the OSM API server, Authenticator.RequestorType.PROXY for a proxy server
        host - the hostname for these credentials
        credentials - the credentials
        Throws:
        CredentialsAgentException - if a problem occurs in a implementation of this interface
      • 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 interface CredentialsAgent
        Parameters:
        requestorType - the type of service. Authenticator.RequestorType.SERVER for the OSM API server, Authenticator.RequestorType.PROXY for a proxy server
        host - the hostname for these credentials
        noSuccessWithLastResponse - 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 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 interface CredentialsAgent
        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 interface CredentialsAgent
        Parameters:
        requestorType - the type of service.
        host - the host. Authenticator.RequestorType.PROXY for a proxy server, Authenticator.RequestorType.SERVER for other servers.