10Duke Scale SDK for Java
|
TokenStore implementation that uses the file system to store license tokens.
Public Member Functions | |
FileSystemTokenStore (final TendukeScaleConfig config, final ObjectMapper mapper) | |
Creates a new instance of this class. | |
List< TokenStoreLicenseCheckoutResult > | all () |
Retrieves all currently held TokenStoreLicenseCheckoutResult objects. | |
List< TokenStoreLicenseCheckoutResult > | listByProductName (final String productName) |
Retrieves all TokenStoreLicenseCheckoutResult objects associated to given product name. | |
TokenStoreLicenseCheckoutResult | findByLeaseId (final String leaseId) |
Retrieves a TokenStoreLicenseCheckoutResult by its lease id. | |
void | save (final TokenStoreLicenseCheckoutResult checkoutResult) |
Stores a given TokenStoreLicenseCheckoutResult. | |
void | removeSafelyByLeaseId (final String leaseId) |
Removes a token by its lease id. | |
Public Member Functions inherited from tenduke.scale.api.TokenStore |
Protected Member Functions | |
String | readFile (final Path filePath) |
Reads the content of a file fully (expects String content encoded in UTF-8). | |
void | writeFile (final Path filePath, final String content) |
Writes content to a file. | |
void | deleteFile (final Path filePath) |
Deletes a token file. | |
String | tokenFileName (final String leaseId) |
Creates a file name to contain a license token by lease id. | |
String | tokenFileName (final JwtToken token) |
Creates a file name to contain a license token by lease id with fallback to using the JWT id (jti) incase lease id is blank. | |
tenduke.scale.client.FileSystemTokenStore.FileSystemTokenStore | ( | final TendukeScaleConfig | config, |
final ObjectMapper | mapper ) |
Creates a new instance of this class.
config | The configuration to use for settings. Configuration must have a valid value for token path: path to a directory that exists and allows writing files from the application using this class. |
mapper | JSON object mapper to use for serializing TokenStoreLicenseCheckoutResult objects. |
List< TokenStoreLicenseCheckoutResult > tenduke.scale.client.FileSystemTokenStore.all | ( | ) |
Retrieves all currently held TokenStoreLicenseCheckoutResult objects.
Implements tenduke.scale.api.TokenStore.
|
protected |
Deletes a token file.
filePath | Path to file that should be deleted. |
TokenStoreLicenseCheckoutResult tenduke.scale.client.FileSystemTokenStore.findByLeaseId | ( | final String | leaseId | ) |
Retrieves a TokenStoreLicenseCheckoutResult by its lease id.
leaseId | for filtering by lease id. |
Implements tenduke.scale.api.TokenStore.
List< TokenStoreLicenseCheckoutResult > tenduke.scale.client.FileSystemTokenStore.listByProductName | ( | final String | productName | ) |
Retrieves all TokenStoreLicenseCheckoutResult objects associated to given product name.
productName | for filtering by product name. |
Implements tenduke.scale.api.TokenStore.
|
protected |
Reads the content of a file fully (expects String content encoded in UTF-8).
filePath | Path to file that should be read. |
void tenduke.scale.client.FileSystemTokenStore.removeSafelyByLeaseId | ( | final String | leaseId | ) |
Removes a token by its lease id.
Does not throw errors if the leaseId is not found.
leaseId | used to identify the token. |
Implements tenduke.scale.api.TokenStore.
void tenduke.scale.client.FileSystemTokenStore.save | ( | final TokenStoreLicenseCheckoutResult | checkoutResult | ) |
Stores a given TokenStoreLicenseCheckoutResult.
checkoutResult | Object that contains the information used to checkout a license and the resulting license token to store. |
Implements tenduke.scale.api.TokenStore.
|
protected |
Creates a file name to contain a license token by lease id with fallback to using the JWT id (jti) incase lease id is blank.
token | The token to use for naming a file. |
|
protected |
Creates a file name to contain a license token by lease id.
leaseId | The lease id to use in the file name. |
|
protected |
Writes content to a file.
An error is thrown if file in the given path exists.
filePath | The file to write to. |
content | The content to write into the file. |