Package io.github.mastodonContentMover
Class UserCredentialStore
java.lang.Object
io.github.mastodonContentMover.UserCredentialStore
Holds in an XML-persistable object the user-level API access tokens for user accounts
on respective Mastodon instances.
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.
Uses the singleton model, as only one
UserCredentialStore
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addCredentials
(String instance, String username, String accessToken) Adds a user-level API access token for a specified user account on a Mastodon instance specified by hostname or address to the object data store within thisUserCredentialStore
object and saves its state to file in an XML format using JAXB.getAccessToken
(String instance, String username) Retrieves a user-level API access token for a specified user account on a Mastodon instance specified by hostname or address from the object data store within thisUserCredentialStore
instance.static UserCredentialStore
Obtains a reference to the currently instantiatedUserCredentialStore
singleton object, or instantiates one if that has not already been done.
-
Method Details
-
getSingletonInstance
public static UserCredentialStore getSingletonInstance() throws jakarta.xml.bind.JAXBException, IOExceptionObtains a reference to the currently instantiatedUserCredentialStore
singleton object, or instantiates one if that has not already been done.- Returns:
- a reference to an
UserCredentialStore
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 username, String accessToken) throws jakarta.xml.bind.JAXBException, IOException Adds a user-level API access token for a specified user account on a Mastodon instance specified by hostname or address to the object data store within thisUserCredentialStore
object and saves its state to file in an XML format using JAXB.
The user account and instance data is stored by one-way concatenation of the instance address and user account name, separated with an underscore, which is then used as a key that maps to the access token.- Parameters:
instance
- the hostname or address of the Mastodon instanceusername
- the username for the account on the Mastodon instanceaccessToken
- a user-level API access token- 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
-
getAccessToken
Retrieves a user-level API access token for a specified user account on a Mastodon instance specified by hostname or address from the object data store within thisUserCredentialStore
instance.- Parameters:
instance
- the hostname or address of the Mastodon instanceusername
- the username for the account on the Mastodon instance- Returns:
- a user-level API access token for the specified user account and instance
- Since:
- 0.01.00
-