Class LocalFileService

java.lang.Object
com.gigaspaces.security.fs.LocalFileService
All Implemented Interfaces:
FileService

public class LocalFileService extends Object implements FileService
A FileService responsible for reading and writing to a file on the local file-system. The file path can be specified by providing a FILE_PATH_PROPERTY_KEY property, or defaults to FILE_PATH_DEFAULT_VAL if none was specified.

The file-path property can be either a direct path to a file, or resource in the classpath.

Since:
7.0.1
Author:
Moran Avigdor
  • Field Details

    • FILE_PATH_PROPERTY_KEY

      public static final String FILE_PATH_PROPERTY_KEY
      The property key identifying the security file
      See Also:
    • FILE_PATH_DEFAULT_VAL

      public static final String FILE_PATH_DEFAULT_VAL
      The default value of the file-path is non was specified
      See Also:
  • Constructor Details

    • LocalFileService

      public LocalFileService()
  • Method Details

    • init

      public void init(Properties properties) throws IOException
      Description copied from interface: FileService
      Initialize the FileService implementation with the properties supplied to the SecurityManager.
      Specified by:
      init in interface FileService
      Throws:
      IOException
    • fileExists

      public boolean fileExists()
      Description copied from interface: FileService
      Checks the existence of the file
      Specified by:
      fileExists in interface FileService
      Returns:
      true if and only if the file exists; false otherwise.
    • readFromFile

      public byte[] readFromFile() throws IOException
      Description copied from interface: FileService
      Reads from a file, returning a byte array representation of the contents.
      Specified by:
      readFromFile in interface FileService
      Returns:
      a file as a byte array.
      Throws:
      IOException - If any exception occurred while reading from a file.
    • writeToFile

      public void writeToFile(byte[] bytes) throws IOException
      Description copied from interface: FileService
      Write to a file a byte array representation of the contents.
      Specified by:
      writeToFile in interface FileService
      Parameters:
      bytes - contents as a byte array.
      Throws:
      IOException - If any exception occurred while writing to a file.
    • lastModified

      public long lastModified()
      Description copied from interface: FileService
      The last time the file was modified. This serves as an indication for refreshing internal cache of the file contents. By comparing the last saved modification time and the current modification time. -1 should be returned to force a refresh. Same value should be returned to avoid a refresh.
      Specified by:
      lastModified in interface FileService
      Returns:
      A long value representing the time the file was last modified.