Class FileSystemTokenStorage
java.lang.Object
org.codice.ddf.security.file.token.storage.FileSystemTokenStorage
- All Implemented Interfaces:
org.codice.ddf.security.token.storage.api.TokenStorage
public class FileSystemTokenStorage
extends Object
implements org.codice.ddf.security.token.storage.api.TokenStorage
-
Field Summary
Fields inherited from interface org.codice.ddf.security.token.storage.api.TokenStorage
ACCESS_TOKEN, CLIENT_ID, DISCOVERY_URL, EXPIRES_AT, REFRESH_TOKEN, SECRET, SOURCE_ID, STATE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintStores a user's or client's access token.intRemoves tokens associated with the given IDintRemoves tokens associated with the given ID for the specified sourcebooleanisAvailable(String id, String sourceId) Checks if tokens are availableorg.codice.ddf.security.token.storage.api.TokenInformationReads tokens associated with the given IDorg.codice.ddf.security.token.storage.api.TokenInformation.TokenEntryReads tokens associated with the given ID for the specified sourcevoidsetBaseDirectory(String baseDirectory)
-
Constructor Details
-
FileSystemTokenStorage
public FileSystemTokenStorage()
-
-
Method Details
-
getStateMap
- Specified by:
getStateMapin interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Returns:
- a map containing state UUIDs with their corresponding ID, source ID, discovery URL, client ID, and secret information. Clears out all the expired state information before returning the map.
-
create
public int create(String id, String sourceId, String accessToken, String refreshToken, String discoveryUrl) Stores a user's or client's access token. If it's a new user or client, creates a new entry. Otherwise, updates the existing data.- Specified by:
createin interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID used to store the tokenssourceId- the ID of the source the tokens are going to be used againstaccessToken- the access tokenrefreshToken- the refresh tokendiscoveryUrl- the metadata url of the OAuth provider protecting the source- Returns:
- an HTTP status code
-
read
Reads tokens associated with the given ID- Specified by:
readin interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID used to retrieve tokens- Returns:
- a
TokenInformationfilled with tokens
-
read
public org.codice.ddf.security.token.storage.api.TokenInformation.TokenEntry read(String id, String sourceId) Reads tokens associated with the given ID for the specified source- Specified by:
readin interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID used to retrieve tokenssourceId- the source ID the tokens correspond to- Returns:
- a
TokenInformation.TokenEntryfilled with tokens
-
isAvailable
Checks if tokens are available- Specified by:
isAvailablein interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID used to check if tokens are availablesourceId- the source ID the tokens correspond to- Returns:
- true if the tokens for the given ID and source are available and false if they are not
-
delete
Removes tokens associated with the given ID- Specified by:
deletein interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID associated with the tokens- Returns:
- an HTTP status code
-
delete
Removes tokens associated with the given ID for the specified source- Specified by:
deletein interfaceorg.codice.ddf.security.token.storage.api.TokenStorage- Parameters:
id- the ID associated with the tokenssourceId- the ID for the source the tokens are going to be used against- Returns:
- an HTTP status code
-
setBaseDirectory
- Throws:
IOException
-