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
public class FileDataStoreFactory extends AbstractDataStoreFactory
Thread-safe file implementation of a credential store.For security purposes, the file's permissions are set to be accessible only by the file's owner. Note that Java 1.5 does not support manipulating file permissions, and must be done manually or using the JNI.
- Since:
- 1.16
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classFileDataStoreFactory.FileDataStore<V extends java.io.Serializable>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
Fields Modifier and Type Field Description private java.io.FiledataDirectoryDirectory to store data.private static java.util.logging.LoggerLOGGER
-
Constructor Summary
Constructors Constructor Description FileDataStoreFactory(java.io.File dataDirectory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <V extends java.io.Serializable>
DataStore<V>createDataStore(java.lang.String id)Returns a new instance of a type-specific data store based on the given unique ID.java.io.FilegetDataDirectory()Returns the data directory.(package private) static voidsetPermissionsToOwnerOnly(java.io.File file)Attempts to set the given file's permissions such that it can only be read, written, and executed by the file's owner.-
Methods inherited from class com.google.api.client.util.store.AbstractDataStoreFactory
getDataStore
-
-
-
-
Method Detail
-
getDataDirectory
public final java.io.File getDataDirectory()
Returns the data directory.
-
createDataStore
protected <V extends java.io.Serializable> DataStore<V> createDataStore(java.lang.String id) throws java.io.IOException
Description copied from class:AbstractDataStoreFactoryReturns a new instance of a type-specific data store based on the given unique ID.The
DataStore.getId()must match theidparameter from this method.- Specified by:
createDataStorein classAbstractDataStoreFactory- Type Parameters:
V- serializable type of the mapped value- Parameters:
id- unique ID to refer to typed data store- Throws:
java.io.IOException
-
setPermissionsToOwnerOnly
static void setPermissionsToOwnerOnly(java.io.File file) throws java.io.IOExceptionAttempts 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:
java.io.IOException
-
-