Interface FileService

All Known Implementing Classes:
LocalFileService, URLFileService

public interface FileService
Defines an interface for accessing UserDetails and RoleDetails stored in a file. The contents read from the service are cached and refreshed by comparing the last modification time.
Since:
7.0.1
Author:
Moran Avigdor
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The property key identifying the FileService implementation class name
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks the existence of the file
    void
    init(Properties properties)
    Initialize the FileService implementation with the properties supplied to the SecurityManager.
    long
    The last time the file was modified.
    byte[]
    Reads from a file, returning a byte array representation of the contents.
    void
    writeToFile(byte[] bytes)
    Write to a file a byte array representation of the contents.
  • Field Details

    • FILE_SERVICE_CLASS_PROPERTY_KEY

      static final String FILE_SERVICE_CLASS_PROPERTY_KEY
      The property key identifying the FileService implementation class name
      See Also:
  • Method Details

    • init

      void init(Properties properties) throws IOException
      Initialize the FileService implementation with the properties supplied to the SecurityManager.
      Throws:
      IOException
    • fileExists

      boolean fileExists()
      Checks the existence of the file
      Returns:
      true if and only if the file exists; false otherwise.
    • readFromFile

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

      void writeToFile(byte[] bytes) throws IOException
      Write to a file a byte array representation of the contents.
      Parameters:
      bytes - contents as a byte array.
      Throws:
      IOException - If any exception occurred while writing to a file.
    • lastModified

      long lastModified()
      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.
      Returns:
      A long value representing the time the file was last modified.