Search in sources :

Example 1 with EncryptRoomRequest

use of ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest in project cyberduck by iterate-ch.

the class SDSDelegatingCopyFeatureTest method testCopyFileWithRenameBetweenEncryptedDataRooms.

@Test
public void testCopyFileWithRenameBetweenEncryptedDataRooms() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final Path room1 = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    room1.attributes().getAcl().addAll(new Acl.EmailUser(System.getProperties().getProperty("sds.user")), SDSPermissionsFeature.DELETE_ROLE);
    final Path room2 = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final EncryptRoomRequest encrypt = new EncryptRoomRequest();
    encrypt.setIsEncrypted(true);
    new NodesApi(session.getClient()).encryptRoom(encrypt, Long.parseLong(new SDSNodeIdProvider(session).getVersionId(room2, new DisabledListProgressListener())), StringUtils.EMPTY, null);
    room2.attributes().withCustom(KEY_ENCRYPTED, String.valueOf(true));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path test = new Path(room1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session, nodeid);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status), new DisabledConnectionCallback());
    final TripleCryptWriteFeature writer = new TripleCryptWriteFeature(session, nodeid, new SDSMultipartWriteFeature(session, nodeid));
    final StatusOutputStream<Node> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final Path target = new Path(room2, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSCopyFeature feature = new SDSCopyFeature(session, nodeid);
    assertNotNull(new SDSDelegatingCopyFeature(session, nodeid, feature).copy(test, target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    }, new DisabledStreamListener()).attributes().getVersionId());
    assertFalse(feature.isSupported(test, target));
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    assertTrue(new SDSFindFeature(session, nodeid).find(target));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SDSDeleteFeature(session, nodeid).delete(Arrays.asList(room1, room2), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) LoginOptions(ch.cyberduck.core.LoginOptions) NodesApi(ch.cyberduck.core.sds.io.swagger.client.api.NodesApi) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) TripleCryptWriteFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptWriteFeature) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Host(ch.cyberduck.core.Host) Acl(ch.cyberduck.core.Acl) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) EncryptRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with EncryptRoomRequest

use of ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest in project cyberduck by iterate-ch.

the class SDSDelegatingMoveFeatureTest method testMoveEncryptedDataRoom.

@Test
public void testMoveEncryptedDataRoom() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final String roomName = new AlphanumericRandomStringService().random();
    final Path room = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(roomName, EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final EncryptRoomRequest encrypt = new EncryptRoomRequest();
    encrypt.setIsEncrypted(true);
    new NodesApi(session.getClient()).encryptRoom(encrypt, Long.parseLong(new SDSNodeIdProvider(session).getVersionId(room, new DisabledListProgressListener())), StringUtils.EMPTY, null);
    final AttributedList<Path> list = new SDSListService(session, nodeid).list(room.getParent(), new DisabledListProgressListener());
    final Path encrypted = list.get(room);
    // create file inside encrypted room
    final Path folder = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(encrypted, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.directory)), new TransferStatus());
    final Path renamed = new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume));
    new SDSDelegatingMoveFeature(session, nodeid, new SDSMoveFeature(session, nodeid)).move(encrypted, renamed, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
    assertEquals(0, session.getMetrics().get(Copy.class));
    assertFalse(new SDSFindFeature(session, nodeid).find(new Path(roomName, EnumSet.of(Path.Type.directory, Path.Type.volume))));
    assertTrue(new SDSFindFeature(session, nodeid).find(renamed));
    assertTrue(new SDSFindFeature(session, nodeid).find(new Path(renamed, folder.getName(), EnumSet.of(Path.Type.directory, Path.Type.directory))));
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(renamed), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) EncryptRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest) NodesApi(ch.cyberduck.core.sds.io.swagger.client.api.NodesApi) Copy(ch.cyberduck.core.features.Copy) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with EncryptRoomRequest

use of ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest in project cyberduck by iterate-ch.

the class SDSDelegatingMoveFeatureTest method testMoveBetweenEncryptedDataRooms.

@Test
public void testMoveBetweenEncryptedDataRooms() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final Path room1 = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    room1.setAttributes(new SDSAttributesFinderFeature(session, nodeid).find(room1));
    final Path room2 = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final EncryptRoomRequest encrypt = new EncryptRoomRequest();
    encrypt.setIsEncrypted(true);
    new NodesApi(session.getClient()).encryptRoom(encrypt, Long.parseLong(new SDSNodeIdProvider(session).getVersionId(room2, new DisabledListProgressListener())), StringUtils.EMPTY, null);
    room2.attributes().withCustom(KEY_ENCRYPTED, String.valueOf(true));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path test = new Path(room1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session, nodeid);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status), new DisabledConnectionCallback());
    final TripleCryptWriteFeature writer = new TripleCryptWriteFeature(session, nodeid, new SDSMultipartWriteFeature(session, nodeid));
    final StatusOutputStream<Node> out = writer.write(test, status, new DisabledConnectionCallback());
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final Path target = new Path(room2, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new SDSDelegatingMoveFeature(session, nodeid, new SDSMoveFeature(session, nodeid)).move(test, target, new TransferStatus().withLength(content.length), new Delete.DisabledCallback(), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    });
    test.attributes().setVersionId(null);
    assertFalse(new SDSFindFeature(session, nodeid).find(test));
    assertTrue(new SDSFindFeature(session, nodeid).find(target));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SDSDeleteFeature(session, nodeid).delete(Arrays.asList(room1, room2), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) LoginOptions(ch.cyberduck.core.LoginOptions) NodesApi(ch.cyberduck.core.sds.io.swagger.client.api.NodesApi) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) TripleCryptWriteFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptWriteFeature) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Host(ch.cyberduck.core.Host) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) EncryptRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with EncryptRoomRequest

use of ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest in project cyberduck by iterate-ch.

the class SDSDirectoryFeature method createRoom.

protected Path createRoom(final Path room, final boolean encrypt) throws BackgroundException, ApiException {
    final CreateRoomRequest roomRequest = new CreateRoomRequest();
    roomRequest.setParentId(null);
    final UserAccountWrapper user = session.userAccount();
    roomRequest.addAdminIdsItem(user.getId());
    roomRequest.setAdminGroupIds(null);
    if (!room.getParent().isRoot()) {
        roomRequest.setParentId(Long.parseLong(nodeid.getVersionId(room.getParent(), new DisabledListProgressListener())));
    }
    roomRequest.setName(room.getName());
    final Node node = new NodesApi(session.getClient()).createRoom(roomRequest, StringUtils.EMPTY, null);
    nodeid.cache(room, node.getId().toString());
    if (encrypt) {
        final EncryptRoomRequest options = new EncryptRoomRequest();
        options.setIsEncrypted(true);
        return room.withType(EnumSet.of(Path.Type.directory, Path.Type.volume)).withAttributes(new SDSAttributesAdapter(session).toAttributes(new NodesApi(session.getClient()).encryptRoom(options, Long.valueOf(nodeid.getVersionId(room, new DisabledListProgressListener())), StringUtils.EMPTY, null)));
    } else {
        return room.withType(EnumSet.of(Path.Type.directory, Path.Type.volume)).withAttributes(new SDSAttributesAdapter(session).toAttributes(node));
    }
}
Also used : NodesApi(ch.cyberduck.core.sds.io.swagger.client.api.NodesApi) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) CreateRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.CreateRoomRequest) EncryptRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest)

Example 5 with EncryptRoomRequest

use of ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest in project cyberduck by iterate-ch.

the class SDSDelegatingCopyFeatureTest method testCopyFileSameNameBetweenEncryptedDataRooms.

@Test
public void testCopyFileSameNameBetweenEncryptedDataRooms() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final Path room1 = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    room1.attributes().getAcl().addAll(new Acl.EmailUser(System.getProperties().getProperty("sds.user")), SDSPermissionsFeature.DELETE_ROLE);
    final Path room2 = new SDSDirectoryFeature(session, nodeid).mkdir(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
    final EncryptRoomRequest encrypt = new EncryptRoomRequest();
    encrypt.setIsEncrypted(true);
    new NodesApi(session.getClient()).encryptRoom(encrypt, Long.parseLong(new SDSNodeIdProvider(session).getVersionId(room2, new DisabledListProgressListener())), StringUtils.EMPTY, null);
    room2.attributes().withCustom(KEY_ENCRYPTED, String.valueOf(true));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path test = new Path(room1, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session, nodeid);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status), new DisabledConnectionCallback());
    final TripleCryptWriteFeature writer = new TripleCryptWriteFeature(session, nodeid, new SDSMultipartWriteFeature(session, nodeid));
    final StatusOutputStream<Node> out = writer.write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    final Path target = new Path(room2, test.getName(), EnumSet.of(Path.Type.file));
    final SDSCopyFeature feature = new SDSCopyFeature(session, nodeid);
    assertTrue(feature.isSupported(test, target));
    final Path copy = new SDSDelegatingCopyFeature(session, nodeid, feature).copy(test, target, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    }, new DisabledStreamListener());
    assertNotNull(copy.attributes().getVersionId());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    assertTrue(new SDSFindFeature(session, nodeid).find(target));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(copy, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String defaultButton, final String cancelButton, final String preference) {
        // 
        }

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
            return new VaultCredentials("eth[oh8uv4Eesij");
        }
    });
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new SDSDeleteFeature(session, nodeid).delete(Arrays.asList(room1, room2), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) LoginOptions(ch.cyberduck.core.LoginOptions) NodesApi(ch.cyberduck.core.sds.io.swagger.client.api.NodesApi) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) TripleCryptWriteFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptWriteFeature) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Host(ch.cyberduck.core.Host) Acl(ch.cyberduck.core.Acl) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) EncryptRoomRequest(ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)5 NodesApi (ch.cyberduck.core.sds.io.swagger.client.api.NodesApi)5 EncryptRoomRequest (ch.cyberduck.core.sds.io.swagger.client.model.EncryptRoomRequest)5 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)4 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)4 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)4 Path (ch.cyberduck.core.Path)4 Delete (ch.cyberduck.core.features.Delete)4 Node (ch.cyberduck.core.sds.io.swagger.client.model.Node)4 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)4 IntegrationTest (ch.cyberduck.test.IntegrationTest)4 Test (org.junit.Test)4 Credentials (ch.cyberduck.core.Credentials)3 Host (ch.cyberduck.core.Host)3 LoginOptions (ch.cyberduck.core.LoginOptions)3 StreamCopier (ch.cyberduck.core.io.StreamCopier)3 TripleCryptReadFeature (ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature)3 TripleCryptWriteFeature (ch.cyberduck.core.sds.triplecrypt.TripleCryptWriteFeature)3 TransferItem (ch.cyberduck.core.transfer.TransferItem)3 VaultCredentials (ch.cyberduck.core.vault.VaultCredentials)3