Search in sources :

Example 6 with EncryptedFolderMetadata

use of com.owncloud.android.datamodel.EncryptedFolderMetadata in project android by nextcloud.

the class EncryptionTestIT method encryptionMetadata.

/**
 * DecryptedFolderMetadata -> EncryptedFolderMetadata -> JSON -> encrypt
 * -> decrypt -> JSON -> EncryptedFolderMetadata -> DecryptedFolderMetadata
 */
@Test
public void encryptionMetadata() throws Exception {
    DecryptedFolderMetadata decryptedFolderMetadata1 = generateFolderMetadata();
    // encrypt
    EncryptedFolderMetadata encryptedFolderMetadata1 = EncryptionUtils.encryptFolderMetadata(decryptedFolderMetadata1, privateKey);
    // serialize
    String encryptedJson = EncryptionUtils.serializeJSON(encryptedFolderMetadata1);
    // de-serialize
    EncryptedFolderMetadata encryptedFolderMetadata2 = EncryptionUtils.deserializeJSON(encryptedJson, new TypeToken<EncryptedFolderMetadata>() {
    });
    // decrypt
    DecryptedFolderMetadata decryptedFolderMetadata2 = EncryptionUtils.decryptFolderMetaData(encryptedFolderMetadata2, privateKey);
    // compare
    assertTrue(compareJsonStrings(EncryptionUtils.serializeJSON(decryptedFolderMetadata1), EncryptionUtils.serializeJSON(decryptedFolderMetadata2)));
}
Also used : EncryptedFolderMetadata(com.owncloud.android.datamodel.EncryptedFolderMetadata) DecryptedFolderMetadata(com.owncloud.android.datamodel.DecryptedFolderMetadata) Test(org.junit.Test)

Aggregations

EncryptedFolderMetadata (com.owncloud.android.datamodel.EncryptedFolderMetadata)6 DecryptedFolderMetadata (com.owncloud.android.datamodel.DecryptedFolderMetadata)5 RequiresApi (android.support.annotation.RequiresApi)4 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)3 GetMetadataOperation (com.owncloud.android.lib.resources.files.GetMetadataOperation)3 HashMap (java.util.HashMap)3 ArbitraryDataProvider (com.owncloud.android.datamodel.ArbitraryDataProvider)2 LockFileOperation (com.owncloud.android.lib.resources.files.LockFileOperation)2 UpdateMetadataOperation (com.owncloud.android.lib.resources.files.UpdateMetadataOperation)2 IOException (java.io.IOException)2 Map (java.util.Map)2 SuppressLint (android.annotation.SuppressLint)1 Nullable (android.support.annotation.Nullable)1 TypeToken (com.google.gson.reflect.TypeToken)1 OCFile (com.owncloud.android.datamodel.OCFile)1 OCUpload (com.owncloud.android.db.OCUpload)1 OnDatatransferProgressListener (com.owncloud.android.lib.common.network.OnDatatransferProgressListener)1 OperationCancelledException (com.owncloud.android.lib.common.operations.OperationCancelledException)1 ChunkedUploadRemoteFileOperation (com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation)1 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)1