Search in sources :

Example 11 with Credentials

use of ch.cyberduck.core.Credentials in project cyberduck by iterate-ch.

the class SDSDelegatingMoveFeatureTest method testMoveToEncryptedDataRoom.

@Test
public void testMoveToEncryptedDataRoom() 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());
    room2.setAttributes(new SDSAttributesFinderFeature(session, nodeid).find(room2));
    final byte[] content = RandomUtils.nextBytes(32769);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);
    final Path test = new Path(room2, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final SDSMultipartWriteFeature writer = 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(room1, 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());
    assertFalse(new SDSFindFeature(session, nodeid).find(new Path(test).withAttributes(PathAttributes.EMPTY)));
    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) Node(ch.cyberduck.core.sds.io.swagger.client.model.Node) LoginOptions(ch.cyberduck.core.LoginOptions) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) 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) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) 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 12 with Credentials

use of ch.cyberduck.core.Credentials in project cyberduck by iterate-ch.

the class SDSDirectS3MultipartWriteFeatureTest method testWriteEncrypted.

@Test
public void testWriteEncrypted() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final Path room = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    final byte[] content = RandomUtils.nextBytes(new HostPreferences(session.getHost()).getInteger("sds.upload.multipart.chunksize") + 1);
    final Path test = new Path(room, new NFDNormalizer().normalize(String.format("รค%s", new AlphanumericRandomStringService().random())).toString(), EnumSet.of(Path.Type.file));
    {
        final TripleCryptWriteFeature writer = new TripleCryptWriteFeature(session, nodeid, new SDSDirectS3MultipartWriteFeature(session, nodeid));
        final TransferStatus status = new TransferStatus();
        status.setLength(content.length);
        status.setChecksum(new MD5ChecksumCompute().compute(new ByteArrayInputStream(content), new TransferStatus()));
        status.setTimestamp(1632127025217L);
        final StatusOutputStream<Node> out = writer.write(test, status, new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(status, status).transfer(new ByteArrayInputStream(content), out);
    }
    assertNotNull(test.attributes().getVersionId());
    assertTrue(new DefaultFindFeature(session).find(test));
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attr = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(test.attributes().getVersionId(), attr.getVersionId());
    assertEquals(1632127025217L, attr.getModificationDate());
    assertEquals(1632127025217L, new DefaultAttributesFinderFeature(session).find(test).getModificationDate());
    final byte[] compare = new byte[content.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(test, new TransferStatus().withLength(content.length), new DisabledConnectionCallback() {

        @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);
    String previousVersion = test.attributes().getVersionId();
    // Overwrite
    {
        final byte[] change = RandomUtils.nextBytes(256);
        final TransferStatus status = new TransferStatus();
        status.setLength(change.length);
        final TripleCryptWriteFeature writer = new TripleCryptWriteFeature(session, nodeid, new SDSDirectS3MultipartWriteFeature(session, nodeid));
        final StatusOutputStream<Node> out = writer.write(test, status.exists(true), new DisabledConnectionCallback());
        assertNotNull(out);
        new StreamCopier(status, status).transfer(new ByteArrayInputStream(change), out);
        assertNotEquals(test.attributes().getVersionId(), out.getStatus());
    }
    assertNotEquals(attr.getRevision(), new SDSAttributesFinderFeature(session, nodeid).find(test));
    // Read with previous version must fail
    try {
        test.attributes().withVersionId(previousVersion);
        new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(test, new TransferStatus(), new DisabledConnectionCallback() {

            @Override
            public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) {
                return new VaultCredentials("eth[oh8uv4Eesij");
            }
        });
        fail();
    } catch (NotfoundException e) {
    // Expected
    }
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(room), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) LoginOptions(ch.cyberduck.core.LoginOptions) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) TripleCryptWriteFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptWriteFeature) Path(ch.cyberduck.core.Path) NotfoundException(ch.cyberduck.core.exception.NotfoundException) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) StatusOutputStream(ch.cyberduck.core.io.StatusOutputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Host(ch.cyberduck.core.Host) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) HostPreferences(ch.cyberduck.core.preferences.HostPreferences) MD5ChecksumCompute(ch.cyberduck.core.io.MD5ChecksumCompute) NFDNormalizer(ch.cyberduck.core.unicode.NFDNormalizer) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) 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 13 with Credentials

use of ch.cyberduck.core.Credentials in project cyberduck by iterate-ch.

the class SDSDirectS3UploadFeatureTest method testTripleCryptUploadBelowMultipartSize.

@Test
public void testTripleCryptUploadBelowMultipartSize() throws Exception {
    final SDSNodeIdProvider nodeid = new SDSNodeIdProvider(session);
    final SDSDirectS3UploadFeature feature = new SDSDirectS3UploadFeature(session, nodeid, new SDSDirectS3WriteFeature(session, nodeid));
    final Path room = new SDSDirectoryFeature(session, nodeid).createRoom(new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume)), true);
    final Path test = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] random = RandomUtils.nextBytes(578);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(random, out);
    out.close();
    final TransferStatus status = new TransferStatus();
    status.setFilekey(nodeid.getFileKey());
    status.setLength(random.length);
    final SDSEncryptionBulkFeature bulk = new SDSEncryptionBulkFeature(session, nodeid);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test, local), status), new DisabledConnectionCallback());
    feature.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledLoginCallback());
    assertTrue(status.isComplete());
    assertNotNull(status.getResponse());
    assertTrue(new SDSFindFeature(session, nodeid).find(test));
    final PathAttributes attributes = new SDSAttributesFinderFeature(session, nodeid).find(test);
    assertEquals(random.length, attributes.getSize());
    final byte[] compare = new byte[random.length];
    final InputStream stream = new TripleCryptReadFeature(session, nodeid, new SDSReadFeature(session, nodeid)).read(test, new TransferStatus(), new DisabledConnectionCallback() {

        @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(random, compare);
    new SDSDeleteFeature(session, nodeid).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    local.delete();
}
Also used : Delete(ch.cyberduck.core.features.Delete) OutputStream(java.io.OutputStream) LoginOptions(ch.cyberduck.core.LoginOptions) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Path(ch.cyberduck.core.Path) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) PathAttributes(ch.cyberduck.core.PathAttributes) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) TripleCryptReadFeature(ch.cyberduck.core.sds.triplecrypt.TripleCryptReadFeature) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) TransferItem(ch.cyberduck.core.transfer.TransferItem) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) VaultCredentials(ch.cyberduck.core.vault.VaultCredentials) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 14 with Credentials

use of ch.cyberduck.core.Credentials in project cyberduck by iterate-ch.

the class AbstractS3DirectSDSTest method setup.

@Before
public void setup() throws Exception {
    session = new SDSSession(new Host(new SDSProtocol(), "duck.dracoon.com", new Credentials(System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key"))), new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.enableMetrics();
    final LoginConnectionService connect = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
            throw new LoginCanceledException();
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    connect.check(session, new DisabledCancelCallback());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) LoginOptions(ch.cyberduck.core.LoginOptions) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) Before(org.junit.Before)

Example 15 with Credentials

use of ch.cyberduck.core.Credentials in project cyberduck by iterate-ch.

the class AbstractSDSTest method setup.

@Before
public void setup() throws Exception {
    session = new SDSSession(new Host(new SDSProtocol(), "duck.dracoon.com", new Credentials(System.getProperties().getProperty("sds.user"), System.getProperties().getProperty("sds.key"))), new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.enableMetrics();
    final LoginConnectionService connect = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String title, final String reason, final LoginOptions options) throws LoginCanceledException {
            throw new LoginCanceledException();
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    connect.check(session, new DisabledCancelCallback());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) LoginCanceledException(ch.cyberduck.core.exception.LoginCanceledException) Host(ch.cyberduck.core.Host) LoginOptions(ch.cyberduck.core.LoginOptions) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) Before(org.junit.Before)

Aggregations

Credentials (ch.cyberduck.core.Credentials)252 Host (ch.cyberduck.core.Host)201 Test (org.junit.Test)189 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)165 IntegrationTest (ch.cyberduck.test.IntegrationTest)156 Path (ch.cyberduck.core.Path)138 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)137 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)134 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)103 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)95 LoginOptions (ch.cyberduck.core.LoginOptions)92 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)84 Delete (ch.cyberduck.core.features.Delete)76 Local (ch.cyberduck.core.Local)60 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)56 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)55 ProfilePlistReader (ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader)55 Scheme (ch.cyberduck.core.Scheme)52 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)51 Profile (ch.cyberduck.core.Profile)50