10Duke Scale SDK for Java
Loading...
Searching...
No Matches
tenduke.scale.client.FileSystemTokenStore Class Reference

Detailed Description

TokenStore implementation that uses the file system to store license tokens.

Inheritance diagram for tenduke.scale.client.FileSystemTokenStore:
tenduke.scale.api.TokenStore

Public Member Functions

 FileSystemTokenStore (final TendukeScaleConfig config, final ObjectMapper mapper)
 Creates a new instance of this class.
 
List< TokenStoreLicenseCheckoutResultall ()
 Retrieves all currently held TokenStoreLicenseCheckoutResult objects.
 
List< TokenStoreLicenseCheckoutResultlistByProductName (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.
 

Constructor & Destructor Documentation

◆ FileSystemTokenStore()

tenduke.scale.client.FileSystemTokenStore.FileSystemTokenStore ( final TendukeScaleConfig config,
final ObjectMapper mapper )

Creates a new instance of this class.

Parameters
configThe 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.
mapperJSON object mapper to use for serializing TokenStoreLicenseCheckoutResult objects.

Member Function Documentation

◆ all()

List< TokenStoreLicenseCheckoutResult > tenduke.scale.client.FileSystemTokenStore.all ( )

Retrieves all currently held TokenStoreLicenseCheckoutResult objects.

Returns
all tokens.

Implements tenduke.scale.api.TokenStore.

◆ deleteFile()

void tenduke.scale.client.FileSystemTokenStore.deleteFile ( final Path filePath)
protected

Deletes a token file.

Parameters
filePathPath to file that should be deleted.

◆ findByLeaseId()

TokenStoreLicenseCheckoutResult tenduke.scale.client.FileSystemTokenStore.findByLeaseId ( final String leaseId)

Retrieves a TokenStoreLicenseCheckoutResult by its lease id.

Parameters
leaseIdfor filtering by lease id.
Returns
The token matching the lease id or null.

Implements tenduke.scale.api.TokenStore.

◆ listByProductName()

List< TokenStoreLicenseCheckoutResult > tenduke.scale.client.FileSystemTokenStore.listByProductName ( final String productName)

Retrieves all TokenStoreLicenseCheckoutResult objects associated to given product name.

Parameters
productNamefor filtering by product name.
Returns
all tokens filtered by product name.

Implements tenduke.scale.api.TokenStore.

◆ readFile()

String tenduke.scale.client.FileSystemTokenStore.readFile ( final Path filePath)
protected

Reads the content of a file fully (expects String content encoded in UTF-8).

Parameters
filePathPath to file that should be read.
Returns
The file content.

◆ removeSafelyByLeaseId()

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.

Parameters
leaseIdused to identify the token.

Implements tenduke.scale.api.TokenStore.

◆ save()

void tenduke.scale.client.FileSystemTokenStore.save ( final TokenStoreLicenseCheckoutResult checkoutResult)

Stores a given TokenStoreLicenseCheckoutResult.

Parameters
checkoutResultObject that contains the information used to checkout a license and the resulting license token to store.

Implements tenduke.scale.api.TokenStore.

◆ tokenFileName() [1/2]

String tenduke.scale.client.FileSystemTokenStore.tokenFileName ( final JwtToken token)
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.

Parameters
tokenThe token to use for naming a file.
Returns
File name for the given token.

◆ tokenFileName() [2/2]

String tenduke.scale.client.FileSystemTokenStore.tokenFileName ( final String leaseId)
protected

Creates a file name to contain a license token by lease id.

Parameters
leaseIdThe lease id to use in the file name.
Returns
File name for the given lease id.

◆ writeFile()

void tenduke.scale.client.FileSystemTokenStore.writeFile ( final Path filePath,
final String content )
protected

Writes content to a file.

An error is thrown if file in the given path exists.

Parameters
filePathThe file to write to.
contentThe content to write into the file.

The documentation for this class was generated from the following file: