Package com.google.api.client.util.store
Class FileDataStoreFactory
java.lang.Object
com.google.api.client.util.store.AbstractDataStoreFactory
com.google.api.client.util.store.FileDataStoreFactory
- All Implemented Interfaces:
DataStoreFactory
Thread-safe file implementation of a credential store.
For security purposes, the file's permissions are set such that the file is only accessible by the file's owner.
Note: this class is not compatible with Android lower than API level 26 (Oreo). For an implementation compatible with Android invalid input: '<' 26, please use com.google.api.client.extensions.android.util.store.FileDataStoreFactory which is provided by com.google.http-client:google-http-client-android.
- Since:
- 1.16
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
File data store that inherits from the abstract memory data store because the key-value pairs are stored in a memory cache, and saved in the file (seeFileDataStoreFactory.FileDataStore.save()
when changing values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final File
Directory to store data.private static final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <V extends Serializable>
DataStore<V> Returns a new instance of a type-specific data store based on the given unique ID.final File
Returns the data directory.private static void
Attempts to set the given file's permissions such that it can only be read, written, and executed by the file's owner.private static void
Methods inherited from class com.google.api.client.util.store.AbstractDataStoreFactory
getDataStore
-
Field Details
-
IS_WINDOWS
private static final boolean IS_WINDOWS -
dataDirectory
Directory to store data.
-
-
Constructor Details
-
FileDataStoreFactory
- Parameters:
dataDirectory
- data directory- Throws:
IOException
-
-
Method Details
-
getDataDirectory
Returns the data directory. -
createDataStore
Description copied from class:AbstractDataStoreFactory
Returns a new instance of a type-specific data store based on the given unique ID.The
DataStore.getId()
must match theid
parameter from this method.- Specified by:
createDataStore
in classAbstractDataStoreFactory
- Type Parameters:
V
- serializable type of the mapped value- Parameters:
id
- unique ID to refer to typed data store- Throws:
IOException
-
setPermissionsToOwnerOnly
Attempts to set the given file's permissions such that it can only be read, written, and executed by the file's owner.- Parameters:
file
- the file's permissions to modify- Throws:
IOException
- if the permissions can't be set
-
setPermissionsToOwnerOnlyWindows
- Throws:
IOException
-