Class ClientCredentialStore

java.lang.Object
io.github.mastodonContentMover.ClientCredentialStore

public class ClientCredentialStore extends Object
Holds in an XML-persistable object the application-level API credentials for the tool with respective Mastodon instances, using ClientCredentialSet objects to store individual client-key and client-secret pairs.

Uses the singleton model, as only one ClientCredentialStore object is needed to hold all credentials and only one should be instantiated at a time. Synchronized methods will be synchronized on the singleton object (because there is only ever one).

TODO: Add a parameter that allows the tool to run without persisting any tokens (for user or client) for use in low-security environments.

Since:
0.01.00
See Also:
  • Method Details

    • getSingletonInstance

      public static ClientCredentialStore getSingletonInstance() throws jakarta.xml.bind.JAXBException, IOException
      Obtains a reference to the currently instantiated ClientCredentialStore singleton object, or instantiates one if that has not already been done.

      Returns:
      a reference to an ClientCredentialStore object

      Throws:
      jakarta.xml.bind.JAXBException - (TODO: add more info here on when this happens)
      IOException - (TODO: add more info here on when this happens)
      Since:
      0.01.00
    • addCredentials

      public void addCredentials(String instance, String clientKey, String clientSecret) throws jakarta.xml.bind.JAXBException, IOException
      Adds a client-key and client-secret pair that grant application-level API read and write access for the tool on a Mastodon instance, specified by hostname or address, to the data store within this ClientCredentialStore object and saves its state to file in an XML format using JAXB.

      The client-key and client-secret pair are stored using a ClientCredentialSet object.

      Parameters:
      instance - the hostname or address of the Mastodon instance
      clientKey - the client-key for the tool on the Mastodon instance
      clientSecret - the client-secret for the tool on the Mastodon instance

      Throws:
      jakarta.xml.bind.JAXBException - (TODO: add more info here on when this happens)
      IOException - (TODO: add more info here on when this happens)

      Since:
      0.01.00
    • getCredentials

      public ClientCredentialSet getCredentials(String instance) throws jakarta.xml.bind.JAXBException, IOException
      Retrieves a client-key and client-secret pair that grant application-level API read and write access for the tool on a Mastodon instance, specified by hostname or address, contained within a ClientCredentialSet object, from the data store within this ClientCredentialStore object.

      Parameters:
      instance - the hostname or address of the Mastodon instance

      Returns:
      a ClientCredentialSet object containing the client-key and client-secret pair for the tool on the specified Mastodon instance

      Throws:
      jakarta.xml.bind.JAXBException - (TODO: add more info here on when this happens)
      IOException - (TODO: add more info here on when this happens)

      Since:
      0.01.00