Search in sources :

Example 51 with DefaultX509KeyManager

use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.

the class SpectraObjectListServiceTest method testListNotfound.

@Test(expected = NotfoundException.class)
public void testListNotfound() throws Exception {
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("notfound.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
    new SpectraObjectListService(session).list(container, new DisabledListProgressListener());
    session.close();
}
Also used : Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 52 with DefaultX509KeyManager

use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.

the class SpectraWriteFeatureTest method testOverwriteZeroSized.

@Test
public void testOverwriteZeroSized() throws Exception {
    final Host host = new Host(new SpectraProtocol() {

        @Override
        public Scheme getScheme() {
            return Scheme.http;
        }
    }, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
    final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    // Make 0-byte file
    new SpectraTouchFeature(session).touch(test, new TransferStatus());
    // Replace content
    final byte[] content = RandomUtils.nextBytes(1023);
    final TransferStatus status = new TransferStatus().withLength(content.length);
    status.setChecksum(new CRC32ChecksumCompute().compute(new ByteArrayInputStream(content), status));
    final SpectraBulkService bulk = new SpectraBulkService(session);
    bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(test), status.exists(true)), new DisabledConnectionCallback());
    final OutputStream out = new SpectraWriteFeature(session).write(test, status, new DisabledConnectionCallback());
    assertNotNull(out);
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out);
    out.close();
    new SpectraDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) CRC32ChecksumCompute(ch.cyberduck.core.io.CRC32ChecksumCompute) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Path(ch.cyberduck.core.Path) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) ByteArrayInputStream(java.io.ByteArrayInputStream) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 53 with DefaultX509KeyManager

use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.

the class MicrosoftIISDAVLockFeatureTest method testLock.

@Test
public void testLock() throws Exception {
    final Host host = new Host(new DAVProtocol(), "winbuild.iterate.ch", new Credentials(System.getProperties().getProperty("webdav.iis.user"), System.getProperties().getProperty("webdav.iis.password")));
    host.setDefaultPath("/WebDAV");
    final DAVSession session = new DAVSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = "test".getBytes(StandardCharsets.UTF_8);
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(content, out);
    out.close();
    status.setLength(content.length);
    final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final HttpUploadFeature upload = new DAVUploadFeature(session);
    upload.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), status, new DisabledConnectionCallback());
    final String lock = new DAVLockFeature(session).lock(test);
    assertTrue(new MicrosoftIISDAVFindFeature(session).find(test));
    final PathAttributes attributes = new MicrosoftIISDAVListService(session, new MicrosoftIISDAVAttributesFinderFeature(session)).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes();
    assertEquals(content.length, attributes.getSize(), 0L);
    assertEquals(content.length, new DAVWriteFeature(session).append(test, status.withRemote(attributes)).size, 0L);
    {
        final byte[] buffer = new byte[content.length];
        IOUtils.readFully(new MicrosoftIISDAVReadFeature(session).read(test, new TransferStatus(), new DisabledConnectionCallback()), buffer);
        assertArrayEquals(content, buffer);
    }
    {
        final byte[] buffer = new byte[content.length - 1];
        final InputStream in = new MicrosoftIISDAVReadFeature(session).read(test, new TransferStatus().withLength(content.length - 1L).append(true).withOffset(1L), new DisabledConnectionCallback());
        IOUtils.readFully(in, buffer);
        in.close();
        final byte[] reference = new byte[content.length - 1];
        System.arraycopy(content, 1, reference, 0, content.length - 1);
        assertArrayEquals(reference, buffer);
    }
    new DAVLockFeature(session).unlock(test, lock);
    new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) OutputStream(java.io.OutputStream) DAVSession(ch.cyberduck.core.dav.DAVSession) DAVDeleteFeature(ch.cyberduck.core.dav.DAVDeleteFeature) DAVWriteFeature(ch.cyberduck.core.dav.DAVWriteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DAVLockFeature(ch.cyberduck.core.dav.DAVLockFeature) Path(ch.cyberduck.core.Path) 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) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) HttpUploadFeature(ch.cyberduck.core.http.HttpUploadFeature) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DAVProtocol(ch.cyberduck.core.dav.DAVProtocol) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Credentials(ch.cyberduck.core.Credentials) DAVUploadFeature(ch.cyberduck.core.dav.DAVUploadFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 54 with DefaultX509KeyManager

use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.

the class MicrosoftIISDAVReadFeatureTest method testReadMicrosoft.

@Test
public void testReadMicrosoft() throws Exception {
    final Host host = new Host(new DAVProtocol(), "winbuild.iterate.ch", new Credentials(System.getProperties().getProperty("webdav.iis.user"), System.getProperties().getProperty("webdav.iis.password")));
    host.setDefaultPath("/WebDAV");
    final DAVSession session = new DAVSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
    final Local local = new Local(System.getProperty("java.io.tmpdir"), new AlphanumericRandomStringService().random());
    final byte[] content = RandomUtils.nextBytes(1023);
    final OutputStream out = local.getOutputStream(false);
    assertNotNull(out);
    IOUtils.write(content, out);
    out.close();
    new DAVUploadFeature(session).upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(), new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
    assertTrue(new MicrosoftIISDAVFindFeature(session).find(test));
    assertEquals(content.length, new MicrosoftIISDAVListService(session, new MicrosoftIISDAVAttributesFinderFeature(session)).list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(), 0L);
    final TransferStatus status = new TransferStatus();
    status.setLength(-1L);
    final InputStream in = new MicrosoftIISDAVReadFeature(session).read(test, status, new DisabledConnectionCallback());
    assertNotNull(in);
    final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length);
    new StreamCopier(status, status).transfer(in, buffer);
    final byte[] reference = new byte[content.length];
    System.arraycopy(content, 0, reference, 0, content.length);
    assertArrayEquals(reference, buffer.toByteArray());
    in.close();
    new DAVDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
Also used : Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) DAVSession(ch.cyberduck.core.dav.DAVSession) DAVDeleteFeature(ch.cyberduck.core.dav.DAVDeleteFeature) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Path(ch.cyberduck.core.Path) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) InputStream(java.io.InputStream) Local(ch.cyberduck.core.Local) Host(ch.cyberduck.core.Host) DefaultHomeFinderService(ch.cyberduck.core.shared.DefaultHomeFinderService) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) BandwidthThrottle(ch.cyberduck.core.io.BandwidthThrottle) DAVProtocol(ch.cyberduck.core.dav.DAVProtocol) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DAVTouchFeature(ch.cyberduck.core.dav.DAVTouchFeature) Credentials(ch.cyberduck.core.Credentials) DAVUploadFeature(ch.cyberduck.core.dav.DAVUploadFeature) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) StreamCopier(ch.cyberduck.core.io.StreamCopier) AbstractDAVTest(ch.cyberduck.core.dav.AbstractDAVTest) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 55 with DefaultX509KeyManager

use of ch.cyberduck.core.ssl.DefaultX509KeyManager in project cyberduck by iterate-ch.

the class FallbackAttributesFinderFeatureTest method testFindNoWebDAV.

@Test
public void testFindNoWebDAV() throws Exception {
    final DAVSession session = new DAVSession(new Host(new DAVSSLProtocol(), "ftp.gnu.org"), new DisabledX509TrustManager(), new DefaultX509KeyManager());
    session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
    session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
    // Handle 405 Method Not Allowed
    final AttributesFinder f = new FallbackAttributesFinderFeature(new DefaultAttributesFinderFeature(session), new DAVAttributesFinderFeature(session));
    final PathAttributes attr = f.find(new Path("/gnu/wget/wget-1.19.4.tar.gz", EnumSet.of(Path.Type.file)));
    assertNotNull(attr);
    assertNotEquals(PathAttributes.EMPTY, attr);
    assertEquals(4310657L, attr.getSize());
}
Also used : Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) DAVAttributesFinderFeature(ch.cyberduck.core.dav.DAVAttributesFinderFeature) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) PathAttributes(ch.cyberduck.core.PathAttributes) Host(ch.cyberduck.core.Host) DAVSSLProtocol(ch.cyberduck.core.dav.DAVSSLProtocol) DAVSession(ch.cyberduck.core.dav.DAVSession) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) FallbackAttributesFinderFeature(ch.cyberduck.core.FallbackAttributesFinderFeature) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)176 Test (org.junit.Test)155 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)145 Host (ch.cyberduck.core.Host)136 IntegrationTest (ch.cyberduck.test.IntegrationTest)124 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)111 Credentials (ch.cyberduck.core.Credentials)103 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)99 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)97 Path (ch.cyberduck.core.Path)86 Scheme (ch.cyberduck.core.Scheme)51 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)45 Delete (ch.cyberduck.core.features.Delete)40 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)36 LoginOptions (ch.cyberduck.core.LoginOptions)31 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)30 ProfilePlistReader (ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader)30 DefaultX509TrustManager (ch.cyberduck.core.ssl.DefaultX509TrustManager)30 TransferItem (ch.cyberduck.core.transfer.TransferItem)27 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)26