6.1 Lock/Unlock File
6.1.1 Lock File
T he lockFile method of BayunCore class locks a file with default encryption-policy and key-generation-policy dictated by server settings.
Parameters
filePath : Path of the file to be locked.
success : Success block to be executed after file is successfully locked.
failure : Failure block to be executed if locking fails, returns
BayunError.
String fileURL = file.getAbsolutePath();
// Success Callback
Handler.Callback success = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
Log.d(TAG, "File locked successfully.");
return false;
}
}
// Failure Callback
Handler.Callback failure = new Handler.Callback() {
@Override
public boolean handleMessage(Message message) {
String error = message.getData().getString("BayunError", "");
Log.d(TAG, "Error locking file.");
return false;
}
};
bayunCore.lockFile(fileURL, success, failure);6.1.2 Lock File with Encryption Policy, Key Generation Policy
The lockFile method with encryption policy, key generation policy as parameters locks file with the encryption key dictated by the policy.
Parameters
filePath : Path of the file to be locked.
encryptionPolicy : BayunEncryptionPolicy determines the key for locking.
keyGenerationPolicy : BayunKeyGenerationPolicy determines the policy to generate the data encryption key.
groupId : GroupId is required if encryptionPolicy is
BayunEncryptionPolicyGroup.success : Success block to be executed after file is successfully locked.
failure : Failure block to be executed if locking fails, returns
BayunError.
6.1.3 Unlock File
The unlockFile method of BayunCore class unlocks a locked file.
Parameters
filePath : Path of the file to be unlocked.
success : Success block to be executed after file is successfully unlocked.
failure : Failure block to be executed if unlocking fails, returns
BayunError.
Last updated
Was this helpful?