Interface CredentialsAgent

  • All Known Implementing Classes:
    AbstractCredentialsAgent, CredentialsManager, JosmPreferencesCredentialAgent

    public interface CredentialsAgent
    A CredentialsAgent manages two credentials:
    • the credential for Authenticator.RequestorType.SERVER which is equal to the OSM API credentials in JOSM
    • the credential for Authenticator.RequestorType.PROXY which is equal to the credentials for an optional HTTP proxy server a user may use
    In addition, it manages an OAuth Access Token for accessing the OSM server.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default 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.
      java.awt.Component getPreferencesDecorationPanel()
      Provide a Panel that is shown below the API password / username fields in the JOSM Preferences.
      java.net.PasswordAuthentication lookup​(java.net.Authenticator.RequestorType requestorType, java.lang.String host)
      Looks up the credentials for a given type.
      IOAuthToken lookupOAuthAccessToken​(java.lang.String host)
      Lookup the current OAuth Access Token to access the specified server.
      void purgeCredentialsCache​(java.net.Authenticator.RequestorType requestorType)
      Purges the internal credentials cache for the given requestor type.
      default void purgeCredentialsCache​(java.net.Authenticator.RequestorType requestorType, java.lang.String host)
      Purges the internal credentials cache for the given requestor type and host.
      void store​(java.net.Authenticator.RequestorType requestorType, java.lang.String host, java.net.PasswordAuthentication credentials)
      Saves the credentials in credentials for the given service type.
      void storeOAuthAccessToken​(java.lang.String host, IOAuthToken accessToken)
      Stores the OAuth Access Token accessToken.
    • 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.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

        void store​(java.net.Authenticator.RequestorType requestorType,
                   java.lang.String host,
                   java.net.PasswordAuthentication credentials)
            throws CredentialsAgentException
        Saves the credentials in credentials for the given service type.
        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

        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.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
      • 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
      • 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.PROXY for a proxy server, Authenticator.RequestorType.SERVER for 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.PROXY for a proxy server, Authenticator.RequestorType.SERVER for 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