Search in sources :

Example 46 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class GraphTouchFeatureTest method testTouchLongFilenameEncrypted.

@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    assumeTrue(vaultVersion == CryptoVault.VAULT_VERSION_DEPRECATED);
    final Path home = new OneDriveHomeFinderService().find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = new CryptoTouchFeature<>(session, new DefaultTouchFeature<>(new GraphWriteFeature(session, fileid)), new GraphWriteFeature(session, fileid), cryptomator).touch(new Path(vault, new AlphanumericRandomStringService(130).random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    assertNotNull(test.attributes().getVault());
    assertTrue(new CryptoFindFeature(session, new GraphFindFeature(session, fileid), cryptomator).find(test));
    final PathAttributes attributes = new CryptoAttributesFeature(session, new GraphAttributesFinderFeature(session, fileid), cryptomator).find(test);
    assertNotNull(attributes.getFileId());
    assertEquals(test.attributes(), attributes);
    cryptomator.getFeature(session, Delete.class, new GraphDeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) GraphWriteFeature(ch.cyberduck.core.onedrive.features.GraphWriteFeature) GraphAttributesFinderFeature(ch.cyberduck.core.onedrive.features.GraphAttributesFinderFeature) PathAttributes(ch.cyberduck.core.PathAttributes) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DefaultTouchFeature(ch.cyberduck.core.shared.DefaultTouchFeature) OneDriveHomeFinderService(ch.cyberduck.core.onedrive.OneDriveHomeFinderService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) GraphDeleteFeature(ch.cyberduck.core.onedrive.features.GraphDeleteFeature) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) GraphFindFeature(ch.cyberduck.core.onedrive.features.GraphFindFeature) AbstractOneDriveTest(ch.cyberduck.core.onedrive.AbstractOneDriveTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 47 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class FTPWriteFeatureTest method testWrite.

@Test
public void testWrite() throws Exception {
    final TransferStatus status = new TransferStatus();
    final int length = 1048576;
    final byte[] content = RandomUtils.nextBytes(length);
    status.setLength(content.length);
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final CryptoWriteFeature<Void> writer = new CryptoWriteFeature<>(session, new FTPWriteFeature(session), cryptomator);
    final FileHeader header = cryptomator.getFileHeaderCryptor().create();
    status.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
    status.setNonces(new RotatingNonceGenerator(cryptomator.numberOfChunks(content.length)));
    status.setChecksum(writer.checksum(test, status).compute(new ByteArrayInputStream(content), status));
    status.setLength(content.length);
    final OutputStream out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    out.close();
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    final PathAttributes attr = new CryptoAttributesFeature(session, new FTPAttributesFinderFeature(session), cryptomator).find(test);
    assertEquals(content.length, new CryptoListService(session, new FTPListService(session, null, TimeZone.getDefault()), cryptomator).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize());
    assertEquals(content.length, new CryptoWriteFeature<>(session, new FTPWriteFeature(session), cryptomator).append(test, status.withRemote(attr)).size, 0L);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final InputStream in = new CryptoReadFeature(session, new FTPReadFeature(session), cryptomator).read(test, new TransferStatus(), new DisabledConnectionCallback());
    new StreamCopier(status, status).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    cryptomator.getFeature(session, Delete.class, new FTPDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) CryptoListService(ch.cyberduck.core.cryptomator.features.CryptoListService) CryptoWriteFeature(ch.cyberduck.core.cryptomator.features.CryptoWriteFeature) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) RotatingNonceGenerator(ch.cyberduck.core.cryptomator.random.RotatingNonceGenerator) FTPDeleteFeature(ch.cyberduck.core.ftp.FTPDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) FileHeader(org.cryptomator.cryptolib.api.FileHeader) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) FTPAttributesFinderFeature(ch.cyberduck.core.ftp.FTPAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) FTPWriteFeature(ch.cyberduck.core.ftp.FTPWriteFeature) FTPListService(ch.cyberduck.core.ftp.list.FTPListService) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) FTPReadFeature(ch.cyberduck.core.ftp.FTPReadFeature) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest) AbstractFTPTest(ch.cyberduck.core.ftp.AbstractFTPTest)

Example 48 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class DropboxDirectoryFeatureTest method testMakeDirectoryEncrypted.

@Test
public void testMakeDirectoryEncrypted() throws Exception {
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = cryptomator.getFeature(session, Directory.class, new DropboxDirectoryFeature(session)).mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    final PathAttributes attributes = new CryptoAttributesFeature(session, new DropboxAttributesFinderFeature(session), cryptomator).find(test);
    assertEquals(test.attributes().getSize(), attributes.getSize());
    cryptomator.getFeature(session, Delete.class, new DropboxDeleteFeature(session)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DropboxDeleteFeature(ch.cyberduck.core.dropbox.DropboxDeleteFeature) PathAttributes(ch.cyberduck.core.PathAttributes) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) DropboxDirectoryFeature(ch.cyberduck.core.dropbox.DropboxDirectoryFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DropboxAttributesFinderFeature(ch.cyberduck.core.dropbox.DropboxAttributesFinderFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) Directory(ch.cyberduck.core.features.Directory) AbstractDropboxTest(ch.cyberduck.core.AbstractDropboxTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 49 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class EueSingleUploadServiceTest method testUploadVault.

@Test
public void testUploadVault() throws Exception {
    final EueResourceIdProvider fileid = new EueResourceIdProvider(session);
    final Path container = new EueDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(AbstractPath.Type.directory)), new TransferStatus().withLength(0L));
    final Path vault = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = RandomUtils.nextBytes(502400);
    IOUtils.write(content, local.getOutputStream(false));
    final TransferStatus writeStatus = new TransferStatus();
    final FileHeader header = cryptomator.getFileHeaderCryptor().create();
    writeStatus.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
    writeStatus.setLength(content.length);
    final BytecountStreamListener count = new BytecountStreamListener();
    final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, new EueSingleUploadService(session, fileid, new EueWriteFeature(session, fileid)), new EueWriteFeature(session, fileid), cryptomator);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, writeStatus, null);
    assertEquals(content.length, count.getSent());
    assertTrue(writeStatus.isComplete());
    assertTrue(new CryptoFindFeature(session, new EueFindFeature(session, fileid), cryptomator).find(test));
    assertEquals(content.length, new CryptoAttributesFeature(session, new EueAttributesFinderFeature(session, fileid), cryptomator).find(test).getSize());
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final TransferStatus readStatus = new TransferStatus().withLength(content.length);
    final InputStream in = new CryptoReadFeature(session, new EueReadFeature(session, fileid), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
    new StreamCopier(readStatus, readStatus).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    cryptomator.getFeature(session, Delete.class, new EueDeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : EueDirectoryFeature(ch.cyberduck.core.eue.EueDirectoryFeature) Delete(ch.cyberduck.core.features.Delete) EueAttributesFinderFeature(ch.cyberduck.core.eue.EueAttributesFinderFeature) EueFindFeature(ch.cyberduck.core.eue.EueFindFeature) EueReadFeature(ch.cyberduck.core.eue.EueReadFeature) EueDeleteFeature(ch.cyberduck.core.eue.EueDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) FileHeader(org.cryptomator.cryptolib.api.FileHeader) CryptoUploadFeature(ch.cyberduck.core.cryptomator.features.CryptoUploadFeature) AbstractPath(ch.cyberduck.core.AbstractPath) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EueResourceIdProvider(ch.cyberduck.core.eue.EueResourceIdProvider) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) EueWriteFeature(ch.cyberduck.core.eue.EueWriteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) EueSingleUploadService(ch.cyberduck.core.eue.EueSingleUploadService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractEueSessionTest(ch.cyberduck.core.eue.AbstractEueSessionTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 50 with CryptoAttributesFeature

use of ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature in project cyberduck by iterate-ch.

the class EueThresholdUploadServiceTest method testUploadVault.

@Test
public void testUploadVault() throws Exception {
    final EueResourceIdProvider fileid = new EueResourceIdProvider(session);
    final Path container = new EueDirectoryFeature(session, fileid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus().withLength(0L));
    final Path vault = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault);
    cryptomator.create(session, new VaultCredentials("test"), new DisabledPasswordStore(), vaultVersion);
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = RandomUtils.nextBytes(8840780);
    IOUtils.write(content, local.getOutputStream(false));
    final TransferStatus writeStatus = new TransferStatus();
    final FileHeader header = cryptomator.getFileHeaderCryptor().create();
    writeStatus.setHeader(cryptomator.getFileHeaderCryptor().encryptHeader(header));
    writeStatus.setLength(content.length);
    final BytecountStreamListener count = new BytecountStreamListener();
    final CryptoUploadFeature feature = new CryptoUploadFeature<>(session, new EueThresholdUploadService(session, fileid, registry), new EueWriteFeature(session, fileid), cryptomator);
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), count, writeStatus, new DisabledConnectionCallback());
    assertEquals(content.length, count.getSent());
    assertTrue(writeStatus.isComplete());
    assertTrue(new CryptoFindFeature(session, new EueFindFeature(session, fileid), cryptomator).find(test));
    assertEquals(content.length, new CryptoAttributesFeature(session, new EueAttributesFinderFeature(session, fileid), cryptomator).find(test).getSize());
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    final TransferStatus readStatus = new TransferStatus().withLength(content.length);
    final InputStream in = new CryptoReadFeature(session, new EueReadFeature(session, fileid), cryptomator).read(test, readStatus, new DisabledConnectionCallback());
    new StreamCopier(readStatus, readStatus).transfer(in, buffer);
    assertArrayEquals(content, buffer.toByteArray());
    cryptomator.getFeature(session, Delete.class, new EueDeleteFeature(session, fileid)).delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : EueDirectoryFeature(ch.cyberduck.core.eue.EueDirectoryFeature) Delete(ch.cyberduck.core.features.Delete) EueAttributesFinderFeature(ch.cyberduck.core.eue.EueAttributesFinderFeature) EueFindFeature(ch.cyberduck.core.eue.EueFindFeature) EueReadFeature(ch.cyberduck.core.eue.EueReadFeature) EueDeleteFeature(ch.cyberduck.core.eue.EueDeleteFeature) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) CryptoReadFeature(ch.cyberduck.core.cryptomator.features.CryptoReadFeature) FileHeader(org.cryptomator.cryptolib.api.FileHeader) CryptoUploadFeature(ch.cyberduck.core.cryptomator.features.CryptoUploadFeature) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) ByteArrayOutputStream(java.io.ByteArrayOutputStream) EueResourceIdProvider(ch.cyberduck.core.eue.EueResourceIdProvider) BytecountStreamListener(ch.cyberduck.core.BytecountStreamListener) EueWriteFeature(ch.cyberduck.core.eue.EueWriteFeature) CryptoFindFeature(ch.cyberduck.core.cryptomator.features.CryptoFindFeature) CryptoAttributesFeature(ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) EueThresholdUploadService(ch.cyberduck.core.eue.EueThresholdUploadService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractEueSessionTest(ch.cyberduck.core.eue.AbstractEueSessionTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

CryptoAttributesFeature (ch.cyberduck.core.cryptomator.features.CryptoAttributesFeature)62 Delete (ch.cyberduck.core.features.Delete)62 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)62 DefaultVaultRegistry (ch.cyberduck.core.vault.DefaultVaultRegistry)62 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)62 IntegrationTest (ch.cyberduck.test.IntegrationTest)62 Test (org.junit.Test)62 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)60 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)60 DisabledPasswordCallback (ch.cyberduck.core.DisabledPasswordCallback)60 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)60 Path (ch.cyberduck.core.Path)60 CryptoFindFeature (ch.cyberduck.core.cryptomator.features.CryptoFindFeature)53 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)36 StreamCopier (ch.cyberduck.core.io.StreamCopier)34 CryptoReadFeature (ch.cyberduck.core.cryptomator.features.CryptoReadFeature)33 ByteArrayOutputStream (java.io.ByteArrayOutputStream)33 InputStream (java.io.InputStream)33 PathAttributes (ch.cyberduck.core.PathAttributes)24 Local (ch.cyberduck.core.Local)21