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 TypeMethodDescriptionvoid
addCredentials
(String instance, String clientKey, String clientSecret) Adds aclient-key
andclient-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 thisClientCredentialStore
object and saves its state to file in an XML format using JAXB.getCredentials
(String instance) Retrieves aclient-key
andclient-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 aClientCredentialSet
object, from the data store within thisClientCredentialStore
object.static ClientCredentialStore
Obtains a reference to the currently instantiatedClientCredentialStore
singleton 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 instantiatedClientCredentialStore
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 aclient-key
andclient-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 thisClientCredentialStore
object and saves its state to file in an XML format using JAXB.
Theclient-key
andclient-secret
pair are stored using aClientCredentialSet
object.- Parameters:
instance
- the hostname or address of the Mastodon instanceclientKey
- theclient-key
for the tool on the Mastodon instanceclientSecret
- theclient-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 aclient-key
andclient-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 aClientCredentialSet
object, from the data store within thisClientCredentialStore
object.- Parameters:
instance
- the hostname or address of the Mastodon instance- Returns:
- a
ClientCredentialSet
object containing theclient-key
andclient-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
-