Constructor
new SalmonFile(drive, realFile)
Provides a file handle that can be used to create encrypted files.
Requires a virtual drive that supports the underlying filesystem, see JavaFile implementation.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
drive |
null | The file virtual system that will be used with file operations | |
realFile |
The real file |
- Source:
Classes
Methods
(async) copy(dir, OnProgressListener)
Copy a file to another directory.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
dir |
Target directory. | ||
OnProgressListener |
null | Observer to notify when copy progress changes. |
- Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
(async) copyRecursively(dest, progressListener, autoRename, onFailed)
Copy a directory recursively
Parameters:
Name | Type | Default | Description |
---|---|---|---|
dest |
The destination directory | ||
progressListener |
null | The progress listener | |
autoRename |
null | The autorename function | |
onFailed |
null | Callback when copy has failed |
- Source:
(async) createDirectory(dirName, key, dirNameNonce)
Creates a directory under this directory
Parameters:
Name | Type | Default | Description |
---|---|---|---|
dirName |
The name of the directory to be created | ||
key |
null | The key that will be used to encrypt the directory name | |
dirNameNonce |
null | The nonce to be used for encrypting the directory name |
- Source:
(async) createFile(realFilename, key, fileNameNonce, fileNonce)
Create a file under this directory
Parameters:
Name | Type | Default | Description |
---|---|---|---|
realFilename |
The real file name of the file (encrypted) | ||
key |
null | The key that will be used for encryption | |
fileNameNonce |
null | The nonce for the encrypting the filename | |
fileNonce |
null | The nonce for the encrypting the file contents |
- Source:
(async) delete()
Delete this file.
- Source:
(async) exists()
Returns true if this file exists
- Source:
(async) getBaseName()
Returns the basename for the file
- Source:
getBlockSize()
Return the AES block size for encryption / decryption
- Source:
(async) getChild(filename)
Get a child with this filename.
Parameters:
Name | Type | Description |
---|---|---|
filename |
The filename to search for |
- Source:
Throws:
-
SalmonSecurityException Thrown when error with security
-
IntegrityException Thrown if the data are corrupt or tampered with.
-
IOException Thrown if there is an IO error.
-
SalmonAuthException Thrown when error during authorization
Returns:
(async) getChildrenCount()
Get the count of files and subdirectories
- Source:
Returns:
(async) getDecryptedFilename(filename, key, nonce)
Return the decrypted filename of a real filename
Parameters:
Name | Type | Default | Description |
---|---|---|---|
filename |
The filename of a real file | ||
key |
null | The encryption key if the file doesn't belong to a drive | |
nonce |
null | The nonce if the file doesn't belong to a drive |
- Source:
getDrive()
Get the drive.
- Source:
Returns:
(async) getEncryptedFilename(filename, key, nonce)
Return the encrypted filename of a virtual filename
Parameters:
Name | Type | Default | Description |
---|---|---|---|
filename |
The virtual filename | ||
key |
null | The encryption key if the file doesn't belong to a drive | |
nonce |
null | The nonce if the file doesn't belong to a drive |
- Source:
getEncryptionKey()
Returns the current encryption key
- Source:
(async) getFileChunkSize()
Get the file chunk size from the header.
- Source:
Throws:
IOException Throws exceptions if the format is corrupt.
Returns:
The chunk size.
(async) getFileNonce()
Returns the initial vector that is used for encryption / decryption
- Source:
getHashKey()
Retrieve the current hash key that is used to encrypt / decrypt the file contents.
- Source:
(async) getHeader()
Get the custom SalmonHeader from this file.
- Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
(async) getInputStream()
Retrieves a SalmonStream that will be used for decrypting the file contents.
- Source:
Throws:
-
IOException Thrown if there is an IO error.
-
SalmonSecurityException Thrown when error with security
-
IntegrityException Thrown if the data are corrupt or tampered with.
Returns:
getIntegrity()
Return if integrity is set
- Source:
(async) getLastDateTimeModified()
Returns the last date modified in milliseconds
- Source:
(async) getMinimumPartSize()
Returns the minimum part size that can be encrypted / decrypted in parallel
aligning to the integrity chunk size if available.
- Source:
(async) getOutputStream(nonce)
Get a SalmonStream for encrypting/writing contents to this file.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
nonce |
null | Nonce to be used for encryption. Note that each file should have a unique nonce see SalmonDrive#getNextNonce(). |
- Source:
Throws:
Exception
Returns:
The output stream.
(async) getParent()
Returns the virtual parent directory
- Source:
(async) getPath()
Return the path of the real file stored
- Source:
getRealFile()
Return the real file
- Source:
getRealPath()
Return the path of the real file
- Source:
getRequestedChunkSize()
Return the current chunk size requested that will be used for integrity
- Source:
getRequestedNonce()
Get the nonce that is used for encryption/decryption of this file.
- Source:
Returns:
(async) getSize()
Return the virtual size of the file excluding the header and hash signatures.
- Source:
getTag()
Get the file tag.
- Source:
Returns:
The file tag.
(async) isDirectory()
Returns True if this is a directory
- Source:
(async) isFile()
Returns true if this is a file
- Source:
(async) listFiles()
Lists files and directories under this directory
- Source:
(async) mkdir()
Create this directory. Currently Not Supported
- Source:
(async) move(dir, OnProgressListener)
Move file to another directory.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
dir |
Target directory. | ||
OnProgressListener |
null | Observer to notify when move progress changes. |
- Source:
Throws:
IOException Thrown if there is an IO error.
Returns:
(async) moveRecursively(dest, progressListener, autoRename, onFailed)
Move a directory recursively
Parameters:
Name | Type | Description |
---|---|---|
dest |
The destination directory | |
progressListener |
The progress listener | |
autoRename |
The autorename function | |
onFailed |
Callback when move has failed |
- Source:
(async) rename(newFilename, nonce)
Rename the virtual file name
Parameters:
Name | Type | Default | Description |
---|---|---|---|
newFilename |
The new filename this file will be renamed to | ||
nonce |
null | The nonce to use |
- Source:
setAllowOverwrite(value)
Warning! Allow overwriting on a current stream. Overwriting is not a good idea because it will re-use the same IV.
This is not recommended if you use the stream on storing files or generally data if prior version can be inspected by others.
You should only use this setting for initial encryption with parallel streams and not for overwriting!
Parameters:
Name | Type | Description |
---|---|---|
value |
True to allow overwriting operations |
- Source:
(async) setApplyIntegrity(integrity, hashKey, requestChunkSize)
Appy integrity when writing to file.
Parameters:
Name | Type | Description |
---|---|---|
integrity |
True to apply integrity | |
hashKey |
The hash key | |
requestChunkSize |
0 use default file chunk. A positive number to specify integrity chunks. |
- Source:
setEncryptionKey(encryptionKey)
Sets the encryption key
Parameters:
Name | Type | Description |
---|---|---|
encryptionKey |
The AES encryption key to be used |
- Source:
setRequestedNonce(nonce)
Set the nonce for encryption/decryption for this file.
Parameters:
Name | Type | Description |
---|---|---|
nonce |
Nonce to be used. |
- Source:
Throws:
SalmonSecurityException Thrown when error with security
setTag(tag)
Set the tag for this file.
Parameters:
Name | Type | Description |
---|---|---|
tag |
- Source:
(async) setVerifyIntegrity(integrity, hashKey)
Enabled verification of file integrity during read() and write()
Parameters:
Name | Type | Description |
---|---|---|
integrity |
True if enable integrity verification | |
hashKey |
The hash key to be used for verification |
- Source: