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 SummaryModifier and TypeMethodDescriptionvoidaddCredentials(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 thisUserCredentialStoreobject 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 thisUserCredentialStoreinstance.static UserCredentialStoreObtains a reference to the currently instantiatedUserCredentialStoresingleton object, or instantiates one if that has not already been done.
- 
Method Details- 
getSingletonInstancepublic static UserCredentialStore getSingletonInstance() throws jakarta.xml.bind.JAXBException, IOExceptionObtains a reference to the currently instantiatedUserCredentialStoresingleton object, or instantiates one if that has not already been done.- Returns:
- a reference to an UserCredentialStoreobject
- 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
 
- 
addCredentialspublic 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 thisUserCredentialStoreobject 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 instance
- username- the username for the account on the Mastodon instance
- accessToken- 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
 
- 
getAccessTokenRetrieves 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 thisUserCredentialStoreinstance.- Parameters:
- instance- the hostname or address of the Mastodon instance
- username- 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
 
 
-