com.myJava.file.driver
Class EncryptedFileSystemDriver

java.lang.Object
  extended by com.myJava.file.driver.AbstractFileSystemDriver
      extended by com.myJava.file.driver.AbstractLinkableFileSystemDriver
          extended by com.myJava.file.driver.EncryptedFileSystemDriver
All Implemented Interfaces:
FileSystemDriver, LinkableFileSystemDriver

public class EncryptedFileSystemDriver
extends AbstractLinkableFileSystemDriver

Linkable driver that adds encryption features

Author:
Olivier PETRUCCI

Areca Build ID : 7299034069467778562

Nested Class Summary
protected static class EncryptedFileSystemDriver.FileFilterAdapter
           
protected static class EncryptedFileSystemDriver.FilenameFilterAdapter
           
 
Field Summary
protected  java.io.File directoryRoot
           
protected  boolean encryptNames
           
protected  javax.crypto.Cipher fileNameDecryptionCipher
           
protected  javax.crypto.Cipher fileNameEncryptionCipher
           
protected  java.security.spec.AlgorithmParameterSpec iv
           
protected  java.security.Key key
           
protected  java.lang.String transformation
           
 
Fields inherited from class com.myJava.file.driver.AbstractLinkableFileSystemDriver
predecessor
 
Fields inherited from class com.myJava.file.driver.AbstractFileSystemDriver
CHECK_PATH
 
Fields inherited from interface com.myJava.file.driver.FileSystemDriver
ACCESS_EFFICIENCY_AVERAGE, ACCESS_EFFICIENCY_GOOD, ACCESS_EFFICIENCY_POOR
 
Constructor Summary
EncryptedFileSystemDriver(java.io.File directoryRoot, java.lang.String transformation, java.security.spec.AlgorithmParameterSpec iv, java.security.Key key, boolean encryptNames)
           
 
Method Summary
 void applyMetaData(FileMetaData p, java.io.File f)
          Applies the attributes provided as argument
 boolean canRead(java.io.File file)
           
 boolean canWrite(java.io.File file)
           
 boolean createNewFile(java.io.File file)
           
protected  java.io.File decryptFileName(java.io.File file)
           
protected  java.lang.String decryptFileName(java.lang.String shortName)
          Decrypts the file or directory name (without parent directory)
 boolean delete(java.io.File file)
           
 void deleteOnExit(java.io.File f)
           
 boolean directFileAccessSupported()
           
protected  java.io.File encryptFileName(java.io.File file)
           
 boolean equals(java.lang.Object o)
           
 boolean exists(java.io.File file)
           
 java.io.InputStream getCachedFileInputStream(java.io.File file)
          Ensures that a local copy of the file exists and return an InputStream on this file
 java.io.OutputStream getCachedFileOutputStream(java.io.File file)
          Returns an OutputStream for the given File
This outputStream will be cached, and written only during call to "flush"
 java.io.File getDirectoryRoot()
           
 java.io.InputStream getFileInputStream(java.io.File file)
           
 java.io.OutputStream getFileOutputStream(java.io.File file)
           
 java.io.OutputStream getFileOutputStream(java.io.File file, boolean append)
           
 java.io.OutputStream getFileOutputStream(java.io.File file, boolean append, OutputStreamListener listener)
           
 FileCacheableInformations getInformations(java.io.File file)
          Returns a global set of file informations (length, lastmodified, ...)
 FileMetaData getMetaData(java.io.File f, boolean onlyBasicAttributes)
          Returns the file's attributes
 FileSystemDriver getPredecessor()
          Gets the predecessor.
 int hashCode()
           
 boolean isContentSensitive()
          Returns true if the driver is sensitive to the content.
 boolean isDirectory(java.io.File file)
           
 boolean isEncryptNames()
           
 boolean isFile(java.io.File file)
           
 boolean isHidden(java.io.File file)
           
 long lastModified(java.io.File file)
           
 long length(java.io.File file)
           
 java.lang.String[] list(java.io.File file)
           
 java.lang.String[] list(java.io.File file, java.io.FilenameFilter filter)
           
 java.io.File[] listFiles(java.io.File file)
           
 java.io.File[] listFiles(java.io.File file, java.io.FileFilter filter)
           
 java.io.File[] listFiles(java.io.File file, java.io.FilenameFilter filter)
           
 boolean mkdir(java.io.File file)
           
 boolean mkdirs(java.io.File file)
           
 boolean renameTo(java.io.File source, java.io.File dest)
           
 boolean setLastModified(java.io.File file, long time)
           
 void setPredecessor(FileSystemDriver predecessor)
          Sets the predecessor.
 boolean setReadOnly(java.io.File file)
           
protected  boolean shallWrappPredecessor(FileSystemDriver predecessor)
           
 java.lang.String toString()
           
 
Methods inherited from class com.myJava.file.driver.AbstractLinkableFileSystemDriver
flush, getAbsoluteFile, getAbsolutePath, getAccessEfficiency, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, mount, supportsLongFileNames, unmount
 
Methods inherited from class com.myJava.file.driver.AbstractFileSystemDriver
checkFilePath, createSymbolicLink, isAbsolute, normalizeIfNeeded
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.myJava.file.driver.FileSystemDriver
createSymbolicLink, isAbsolute
 

Field Detail

directoryRoot

protected java.io.File directoryRoot

key

protected java.security.Key key

transformation

protected java.lang.String transformation

iv

protected java.security.spec.AlgorithmParameterSpec iv

fileNameEncryptionCipher

protected javax.crypto.Cipher fileNameEncryptionCipher

fileNameDecryptionCipher

protected javax.crypto.Cipher fileNameDecryptionCipher

encryptNames

protected boolean encryptNames
Constructor Detail

EncryptedFileSystemDriver

public EncryptedFileSystemDriver(java.io.File directoryRoot,
                                 java.lang.String transformation,
                                 java.security.spec.AlgorithmParameterSpec iv,
                                 java.security.Key key,
                                 boolean encryptNames)
Method Detail

setPredecessor

public void setPredecessor(FileSystemDriver predecessor)
Sets the predecessor.
On Windows systems, this predecessor is wrapped by a HashFileSystemDriver to ensure that paths sizes won't exceed 256 characters.

Overrides:
setPredecessor in class AbstractLinkableFileSystemDriver

getPredecessor

public FileSystemDriver getPredecessor()
Gets the predecessor.
On Windows systems, this predecessor is wrapped by a HashFileSystemDriver to ensure that paths sizes won't exceed 256 characters.
The Driver which is returned by this method is thus this HashFileSystemDriver's predecessor.

Specified by:
getPredecessor in interface LinkableFileSystemDriver
Overrides:
getPredecessor in class AbstractLinkableFileSystemDriver

shallWrappPredecessor

protected boolean shallWrappPredecessor(FileSystemDriver predecessor)

getDirectoryRoot

public java.io.File getDirectoryRoot()

canRead

public boolean canRead(java.io.File file)

canWrite

public boolean canWrite(java.io.File file)

getInformations

public FileCacheableInformations getInformations(java.io.File file)
Description copied from interface: FileSystemDriver
Returns a global set of file informations (length, lastmodified, ...)


getMetaData

public FileMetaData getMetaData(java.io.File f,
                                boolean onlyBasicAttributes)
                         throws java.io.IOException
Description copied from interface: FileSystemDriver
Returns the file's attributes

Specified by:
getMetaData in interface FileSystemDriver
Overrides:
getMetaData in class AbstractFileSystemDriver
Throws:
java.io.IOException

createNewFile

public boolean createNewFile(java.io.File file)
                      throws java.io.IOException
Specified by:
createNewFile in interface FileSystemDriver
Overrides:
createNewFile in class AbstractFileSystemDriver
Throws:
java.io.IOException

delete

public boolean delete(java.io.File file)
Specified by:
delete in interface FileSystemDriver
Overrides:
delete in class AbstractFileSystemDriver

exists

public boolean exists(java.io.File file)
Specified by:
exists in interface FileSystemDriver
Overrides:
exists in class AbstractFileSystemDriver

deleteOnExit

public void deleteOnExit(java.io.File f)
Specified by:
deleteOnExit in interface FileSystemDriver
Overrides:
deleteOnExit in class AbstractFileSystemDriver

isDirectory

public boolean isDirectory(java.io.File file)
Specified by:
isDirectory in interface FileSystemDriver
Overrides:
isDirectory in class AbstractFileSystemDriver

isFile

public boolean isFile(java.io.File file)
Specified by:
isFile in interface FileSystemDriver
Overrides:
isFile in class AbstractFileSystemDriver

isHidden

public boolean isHidden(java.io.File file)
Specified by:
isHidden in interface FileSystemDriver
Overrides:
isHidden in class AbstractFileSystemDriver

lastModified

public long lastModified(java.io.File file)
Specified by:
lastModified in interface FileSystemDriver
Overrides:
lastModified in class AbstractFileSystemDriver

length

public long length(java.io.File file)
Specified by:
length in interface FileSystemDriver
Overrides:
length in class AbstractFileSystemDriver

isEncryptNames

public boolean isEncryptNames()

list

public java.lang.String[] list(java.io.File file,
                               java.io.FilenameFilter filter)
Specified by:
list in interface FileSystemDriver
Overrides:
list in class AbstractFileSystemDriver

list

public java.lang.String[] list(java.io.File file)
Specified by:
list in interface FileSystemDriver
Overrides:
list in class AbstractFileSystemDriver

listFiles

public java.io.File[] listFiles(java.io.File file,
                                java.io.FileFilter filter)
Specified by:
listFiles in interface FileSystemDriver
Overrides:
listFiles in class AbstractFileSystemDriver

listFiles

public java.io.File[] listFiles(java.io.File file,
                                java.io.FilenameFilter filter)
Specified by:
listFiles in interface FileSystemDriver
Overrides:
listFiles in class AbstractFileSystemDriver

listFiles

public java.io.File[] listFiles(java.io.File file)
Specified by:
listFiles in interface FileSystemDriver
Overrides:
listFiles in class AbstractFileSystemDriver

mkdir

public boolean mkdir(java.io.File file)
Specified by:
mkdir in interface FileSystemDriver
Overrides:
mkdir in class AbstractFileSystemDriver

mkdirs

public boolean mkdirs(java.io.File file)
Specified by:
mkdirs in interface FileSystemDriver
Overrides:
mkdirs in class AbstractFileSystemDriver

renameTo

public boolean renameTo(java.io.File source,
                        java.io.File dest)
Specified by:
renameTo in interface FileSystemDriver
Overrides:
renameTo in class AbstractFileSystemDriver

setLastModified

public boolean setLastModified(java.io.File file,
                               long time)
Specified by:
setLastModified in interface FileSystemDriver
Overrides:
setLastModified in class AbstractFileSystemDriver

setReadOnly

public boolean setReadOnly(java.io.File file)
Specified by:
setReadOnly in interface FileSystemDriver
Overrides:
setReadOnly in class AbstractFileSystemDriver

applyMetaData

public void applyMetaData(FileMetaData p,
                          java.io.File f)
                   throws java.io.IOException
Description copied from interface: FileSystemDriver
Applies the attributes provided as argument

Specified by:
applyMetaData in interface FileSystemDriver
Overrides:
applyMetaData in class AbstractFileSystemDriver
Throws:
java.io.IOException

getCachedFileInputStream

public java.io.InputStream getCachedFileInputStream(java.io.File file)
                                             throws java.io.IOException
Description copied from interface: FileSystemDriver
Ensures that a local copy of the file exists and return an InputStream on this file

Throws:
java.io.IOException

getFileInputStream

public java.io.InputStream getFileInputStream(java.io.File file)
                                       throws java.io.IOException
Throws:
java.io.IOException

getCachedFileOutputStream

public java.io.OutputStream getCachedFileOutputStream(java.io.File file)
                                               throws java.io.IOException
Description copied from interface: FileSystemDriver
Returns an OutputStream for the given File
This outputStream will be cached, and written only during call to "flush"

Throws:
java.io.IOException

getFileOutputStream

public java.io.OutputStream getFileOutputStream(java.io.File file)
                                         throws java.io.IOException
Throws:
java.io.IOException

getFileOutputStream

public java.io.OutputStream getFileOutputStream(java.io.File file,
                                                boolean append)
                                         throws java.io.IOException
Throws:
java.io.IOException

getFileOutputStream

public java.io.OutputStream getFileOutputStream(java.io.File file,
                                                boolean append,
                                                OutputStreamListener listener)
                                         throws java.io.IOException
Throws:
java.io.IOException

encryptFileName

protected java.io.File encryptFileName(java.io.File file)

decryptFileName

protected java.io.File decryptFileName(java.io.File file)

decryptFileName

protected java.lang.String decryptFileName(java.lang.String shortName)
Decrypts the file or directory name (without parent directory)


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class AbstractLinkableFileSystemDriver

directFileAccessSupported

public boolean directFileAccessSupported()

isContentSensitive

public boolean isContentSensitive()
Description copied from interface: FileSystemDriver
Returns true if the driver is sensitive to the content.
In other words, if the driver has a chance to fail during initialization if files pre-exist on its storage location