Search in sources :

Example 21 with LoginConnectionService

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

the class AzureCopyFeatureTest method testCopySharedAccessSignature.

@Test
@Ignore
public void testCopySharedAccessSignature() throws Exception {
    final Host host = new Host(new AzureProtocol() {

        @Override
        public boolean isUsernameConfigurable() {
            return false;
        }

        @Override
        public boolean isPasswordConfigurable() {
            return false;
        }

        @Override
        public boolean isTokenConfigurable() {
            return true;
        }
    }, "kahy9boj3eib.blob.core.windows.net", new Credentials(null, null, "?sv=2017-07-29&ss=bfqt&srt=sco&sp=rwdlacup&se=2030-05-20T04:29:30Z&st=2018-05-09T20:29:30Z&spr=https&sig=bMKAZ3tXmX%2B56%2Bb5JhHAeWnMOpMp%2BoYlHDIAZVAjHzE%3D"));
    final AzureSession session = new AzureSession(host);
    new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener()).connect(session, new DisabledCancelCallback());
    final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new AzureTouchFeature(session, null).touch(test, new TransferStatus());
    final Path copy = new Path(container, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    new AzureCopyFeature(session, null).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener());
    assertTrue(new AzureFindFeature(session, null).find(test));
    assertTrue(new AzureFindFeature(session, null).find(copy));
    new AzureDeleteFeature(session, null).delete(Arrays.asList(test, copy), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledStreamListener(ch.cyberduck.core.io.DisabledStreamListener) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 22 with LoginConnectionService

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

the class OneDriveMeContextLoginTest method setup.

@Before
public void setup() throws Exception {
    final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new OneDriveProtocol())));
    final Profile profile = new ProfilePlistReader(factory).read(this.getClass().getResourceAsStream("/Microsoft OneDrive.cyberduckprofile"));
    final Host host = new Host(profile, profile.getDefaultHostname(), new Credentials("cyberduck"));
    session = new OneDriveSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager());
    final LoginConnectionService login = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) {
            fail(reason);
            return null;
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore() {

        @Override
        public String getPassword(Scheme scheme, int port, String hostname, String user) {
            if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Access Token")) {
                return System.getProperties().getProperty("onedrive.accesstoken");
            }
            if (user.endsWith("Microsoft OneDrive (cyberduck) OAuth2 Refresh Token")) {
                return System.getProperties().getProperty("onedrive.refreshtoken");
            }
            return null;
        }

        @Override
        public String getPassword(String hostname, String user) {
            return super.getPassword(hostname, user);
        }
    }, new DisabledProgressListener());
    login.check(session, new DisabledCancelCallback());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) ProfilePlistReader(ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader) Profile(ch.cyberduck.core.Profile) ProtocolFactory(ch.cyberduck.core.ProtocolFactory) 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) DefaultX509TrustManager(ch.cyberduck.core.ssl.DefaultX509TrustManager) Before(org.junit.Before)

Example 23 with LoginConnectionService

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

the class SpectraBulkServiceTest method testPreDownloadFolderOnly.

@Test
public void testPreDownloadFolderOnly() 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());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    final Set<UUID> keys = new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory))), new TransferStatus()), new DisabledConnectionCallback());
    assertTrue(keys.isEmpty());
    session.close();
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) UUID(java.util.UUID) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 24 with LoginConnectionService

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

the class SpectraBulkServiceTest method testPreDownloadNotFound.

@Test(expected = NotfoundException.class)
public void testPreDownloadNotFound() 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());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    new SpectraBulkService(session).pre(Transfer.Type.download, Collections.singletonMap(new TransferItem(new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file))), new TransferStatus().withLength(1L)), new DisabledConnectionCallback());
    session.close();
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 25 with LoginConnectionService

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

the class SpectraBulkServiceTest method testPreUploadSingleFile.

@Test
public void testPreUploadSingleFile() 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());
    final LoginConnectionService service = new LoginConnectionService(new DisabledLoginCallback() {

        @Override
        public void warn(final Host bookmark, final String title, final String message, final String continueButton, final String disconnectButton, final String preference) {
        // 
        }
    }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener());
    service.connect(session, new DisabledCancelCallback());
    final Map<TransferItem, TransferStatus> files = new HashMap<>();
    final TransferStatus status = new TransferStatus();
    final Path file = new Path(String.format("/cyberduck/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file));
    files.put(new TransferItem(file), status.withLength(1L));
    final SpectraBulkService bulk = new SpectraBulkService(session);
    bulk.pre(Transfer.Type.upload, files, new DisabledConnectionCallback());
    assertFalse(status.getParameters().isEmpty());
    assertNotNull(status.getParameters().get("job"));
    bulk.query(Transfer.Type.upload, file, status);
    new SpectraDeleteFeature(session).delete(Collections.singletonList(file), 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) HashMap(java.util.HashMap) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) Path(ch.cyberduck.core.Path) LoginConnectionService(ch.cyberduck.core.LoginConnectionService) Host(ch.cyberduck.core.Host) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) DisabledPasswordStore(ch.cyberduck.core.DisabledPasswordStore) TransferItem(ch.cyberduck.core.transfer.TransferItem) Credentials(ch.cyberduck.core.Credentials) DisabledConnectionCallback(ch.cyberduck.core.DisabledConnectionCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)39 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)39 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)39 DisabledProgressListener (ch.cyberduck.core.DisabledProgressListener)39 LoginConnectionService (ch.cyberduck.core.LoginConnectionService)39 Credentials (ch.cyberduck.core.Credentials)35 Host (ch.cyberduck.core.Host)35 DisabledPasswordStore (ch.cyberduck.core.DisabledPasswordStore)33 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)30 LoginOptions (ch.cyberduck.core.LoginOptions)27 IntegrationTest (ch.cyberduck.test.IntegrationTest)21 Test (org.junit.Test)21 Before (org.junit.Before)18 Profile (ch.cyberduck.core.Profile)16 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)16 ProfilePlistReader (ch.cyberduck.core.serializer.impl.dd.ProfilePlistReader)16 DefaultX509TrustManager (ch.cyberduck.core.ssl.DefaultX509TrustManager)15 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)15 Scheme (ch.cyberduck.core.Scheme)13 LoginCanceledException (ch.cyberduck.core.exception.LoginCanceledException)9