Class DefaultSecureFS

java.lang.Object
com.artifex.solib.DefaultSecureFS
All Implemented Interfaces:
SOSecureFS

public class DefaultSecureFS extends Object implements SOSecureFS
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.artifex.solib.SOSecureFS

    SOSecureFS.FileAttributes
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    closeFile(Object handle)
    This method closes an open file within the secure container.
    boolean
    copyFile(String src, String dst)
    This method copies a file to a new location within the secure container..

    Both source and destination file paths will reside within the secure container and be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    This method creates a directory, and all non-existent directories in the supplied path, within the secure container.

    The path will be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    This method creates a file within the secure container.

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    This method deletes a file from within the secure container..

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    This method tests for the existence of a file within the secure container.

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    This method returns the relevant attributes of the file located at the supplied path.
    This method opens an existing file, in the secure container, for reading.

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    This method opens an existing file, in the secure container, for updating.

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    This method opens an existing file, in the secure container, for writing.

    The file path will be constructed using the secure container identifier used in isSecurePath(String).
    long
    This method obtains the length of a file within the secure container.
    long
    This method obtains the offset, from the start of the file , of the file pointer.
    Return the physical root of the secure container.
    Return the 'tag' to indicate the file is suitable for decryption.
    final String
    This method returns the directory to be used to store temporary files created during file translation/saving.

    This directory must reside within the secure container as identified in isSecurePath(String).
    boolean
    This method determines whether the supplied file path resides within the secure container.

    The path may be a pseudo path on which a mapping can be performed to access the actual file.
    int
    readFromFile(Object handle, byte[] buf)
    This method reads data from a file located within the secure container.
    boolean
    This method recursively deletes the supplied directory, and it's sub-directories, located within the secure container.

    The path will be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    This method renames a file within the secure container.

    Both source and destination file paths will reside within the secure container and be constructed using the secure container identifier used in isSecurePath(String).
    boolean
    seekToFileOffset(Object handle, long offset)
    This method moves the file pointer to the requested offset from 0.
    boolean
    setFileLength(Object handle, long length)
    This method sets the file length of a file located within the secure container.
    boolean
    syncFile(Object handle)
    This method forces buffered data to be written to the underlying device.
    int
    writeToFile(Object handle, byte[] buf)
    This method writes data to a file located within the secure container.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultSecureFS

      public DefaultSecureFS()
  • Method Details

    • getSecurePath

      public String getSecurePath()
      Return the physical root of the secure container.
      Specified by:
      getSecurePath in interface SOSecureFS
      Returns:
      The physical path to the secure container.
    • getSecurePrefix

      public String getSecurePrefix()
      Return the 'tag' to indicate the file is suitable for decryption.
      Specified by:
      getSecurePrefix in interface SOSecureFS
      Returns:
      The secure 'tag' string.
    • isSecurePath

      public boolean isSecurePath(String path)
      This method determines whether the supplied file path resides within the secure container.

      The path may be a pseudo path on which a mapping can be performed to access the actual file. For example "/SECURE/filename".
      Specified by:
      isSecurePath in interface SOSecureFS
      Parameters:
      path - The file path to be analysed.
      Returns:
      True if the file resides within the secure container.
      False otherwise.
    • getTempPath

      public final String getTempPath()
      This method returns the directory to be used to store temporary files created during file translation/saving.

      This directory must reside within the secure container as identified in isSecurePath(String).
      Specified by:
      getTempPath in interface SOSecureFS
      Returns:
      The (pseudo) path to the temporary directory.
    • getFileAttributes

      public SOSecureFS.FileAttributes getFileAttributes(String path)
      This method returns the relevant attributes of the file located at the supplied path. The path will reference a file within the secure container.

      The attributes should refer to the properties of the decrypted file.

      The (pseudo) path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      getFileAttributes in interface SOSecureFS
      Parameters:
      path - The path to the file to obtain attributes for.
      Returns:
      A reference to a SOSecureFS.FileAttributes object.
      null on error.
    • renameFile

      public boolean renameFile(String src, String dst)
      This method renames a file within the secure container.

      Both source and destination file paths will reside within the secure container and be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      renameFile in interface SOSecureFS
      Parameters:
      src - The path to the file to be renamed.
      dst - The path to the destination file.
      Returns:
      True on success. False on failure.
    • copyFile

      public boolean copyFile(String src, String dst)
      This method copies a file to a new location within the secure container..

      Both source and destination file paths will reside within the secure container and be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      copyFile in interface SOSecureFS
      Parameters:
      src - The path to the file to be copied.
      dst - The path to the destination file.
      Returns:
      True on success. False on failure.
    • deleteFile

      public boolean deleteFile(String path)
      This method deletes a file from within the secure container..

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      deleteFile in interface SOSecureFS
      Parameters:
      path - The path to the file to be deleted.
      Returns:
      True on success. False on failure.
    • fileExists

      public boolean fileExists(String path)
      This method tests for the existence of a file within the secure container.

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      fileExists in interface SOSecureFS
      Parameters:
      path - The path to the file to be checked.
      Returns:
      True if the file exists. False otherwise.
    • recursivelyRemoveDirectory

      public boolean recursivelyRemoveDirectory(String path)
      This method recursively deletes the supplied directory, and it's sub-directories, located within the secure container.

      The path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      recursivelyRemoveDirectory in interface SOSecureFS
      Parameters:
      path - The path to the directory to be deleted.
      Returns:
      True on success. False on failure.
    • createDirectory

      public boolean createDirectory(String path)
      This method creates a directory, and all non-existent directories in the supplied path, within the secure container.

      The path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      createDirectory in interface SOSecureFS
      Parameters:
      path - The path to the directory to be created.
      Returns:
      True on success. False on failure.
    • createFile

      public boolean createFile(String path)
      This method creates a file within the secure container.

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      createFile in interface SOSecureFS
      Parameters:
      path - The path to the file to be created.
      Returns:
      True on success. False on failure.
    • getFileHandleForReading

      public Object getFileHandleForReading(String path)
      This method opens an existing file, in the secure container, for reading.

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      getFileHandleForReading in interface SOSecureFS
      Parameters:
      path - The path to the file to be opened.
      Returns:
      The file handle object on success.
      null on error.
    • getFileHandleForWriting

      public Object getFileHandleForWriting(String path)
      This method opens an existing file, in the secure container, for writing.

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      getFileHandleForWriting in interface SOSecureFS
      Parameters:
      path - The path to the file to be opened.
      Returns:
      The file handle object on success.
      null on error.
    • getFileHandleForUpdating

      public Object getFileHandleForUpdating(String path)
      This method opens an existing file, in the secure container, for updating.

      The file path will be constructed using the secure container identifier used in isSecurePath(String).
      Specified by:
      getFileHandleForUpdating in interface SOSecureFS
      Parameters:
      path - The path to the file to be opened.
      Returns:
      The file handle object on success.
      null on error.
    • setFileLength

      public boolean setFileLength(Object handle, long length)
      This method sets the file length of a file located within the secure container.
      Specified by:
      setFileLength in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used..
      Returns:
      True on success. False on failure.
    • closeFile

      public boolean closeFile(Object handle)
      This method closes an open file within the secure container.
      Specified by:
      closeFile in interface SOSecureFS
      Parameters:
      handle - The file handle object to be closed.
      Returns:
      True on success. False on failure.
    • readFromFile

      public int readFromFile(Object handle, byte[] buf)
      This method reads data from a file located within the secure container.
      Specified by:
      readFromFile in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used..
      buf - The buffer to put the read data in.
      Returns:
      The amount of data placed in the buffer.
      0 on EOF
      -1 on error.
    • writeToFile

      public int writeToFile(Object handle, byte[] buf)
      This method writes data to a file located within the secure container.
      Specified by:
      writeToFile in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used.
      buf - The buffer containing the data.
      Returns:
      The amount of data written. -1 on error.
    • syncFile

      public boolean syncFile(Object handle)
      This method forces buffered data to be written to the underlying device.
      Specified by:
      syncFile in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used.
      Returns:
      True on success. False on failure.
    • getFileLength

      public long getFileLength(Object handle)
      This method obtains the length of a file within the secure container.

      The length returned is that of the decrypted file.
      Specified by:
      getFileLength in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used.
      Returns:
      The file length. -1 on error.
    • getFileOffset

      public long getFileOffset(Object handle)
      This method obtains the offset, from the start of the file , of the file pointer.

      The offset returned relates to the decrypted file.
      Specified by:
      getFileOffset in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used.
      Returns:
      The file pointer offset. -1 on error.
    • seekToFileOffset

      public boolean seekToFileOffset(Object handle, long offset)
      This method moves the file pointer to the requested offset from 0.

      The offset relates to the decrypted file.
      Specified by:
      seekToFileOffset in interface SOSecureFS
      Parameters:
      handle - The file handle object to be used.
      Returns:
      True on success. False on failure.