Package io.github.mastodonContentMover
Class ClientCredentialStore
java.lang.Object
io.github.mastodonContentMover.ClientCredentialStore
Holds in an XML-persistable object the application-level API credentials for the tool
with respective Mastodon instances, using
Uses the singleton model, as only 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.
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 Summary
Modifier and TypeMethodDescriptionvoidaddCredentials(String instance, String clientKey, String clientSecret) Adds aclient-keyandclient-secretpair 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 thisClientCredentialStoreobject and saves its state to file in an XML format using JAXB.getCredentials(String instance) Retrieves aclient-keyandclient-secretpair that grant application-level API read and write access for the tool on a Mastodon instance, specified by hostname or address, contained within aClientCredentialSetobject, from the data store within thisClientCredentialStoreobject.static ClientCredentialStoreObtains a reference to the currently instantiatedClientCredentialStoresingleton object, or instantiates one if that has not already been done.
-
Method Details
-
getSingletonInstance
public static ClientCredentialStore getSingletonInstance() throws jakarta.xml.bind.JAXBException, IOExceptionObtains a reference to the currently instantiatedClientCredentialStoresingleton object, or instantiates one if that has not already been done.- Returns:
- a reference to an
ClientCredentialStoreobject - 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 aclient-keyandclient-secretpair 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 thisClientCredentialStoreobject and saves its state to file in an XML format using JAXB.
Theclient-keyandclient-secretpair are stored using aClientCredentialSetobject.- Parameters:
instance- the hostname or address of the Mastodon instanceclientKey- theclient-keyfor the tool on the Mastodon instanceclientSecret- theclient-secretfor 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 aclient-keyandclient-secretpair that grant application-level API read and write access for the tool on a Mastodon instance, specified by hostname or address, contained within aClientCredentialSetobject, from the data store within thisClientCredentialStoreobject.- Parameters:
instance- the hostname or address of the Mastodon instance- Returns:
- a
ClientCredentialSetobject containing theclient-keyandclient-secretpair 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
-