Search in sources :

Example 21 with ConnectionCanceledException

use of ch.cyberduck.core.exception.ConnectionCanceledException in project cyberduck by iterate-ch.

the class SSLExceptionMappingService method map.

/**
 * close_notify(0),
 * unexpected_message(10),
 * bad_record_mac(20),
 * decryption_failed_RESERVED(21),
 * record_overflow(22),
 * decompression_failure(30),
 * handshake_failure(40),
 * no_certificate_RESERVED(41),
 * bad_certificate(42),
 * unsupported_certificate(43),
 * certificate_revoked(44),
 * certificate_expired(45),
 * certificate_unknown(46),
 * illegal_parameter(47),
 * unknown_ca(48),
 * access_denied(49),
 * decode_error(50),
 * decrypt_error(51),
 * export_restriction_RESERVED(60),
 * protocol_version(70),
 * insufficient_security(71),
 * internal_error(80),
 * user_canceled(90),
 * no_renegotiation(100),
 * unsupported_extension(110),
 */
@Override
public BackgroundException map(final SSLException failure) {
    final StringBuilder buffer = new StringBuilder();
    for (Throwable cause : ExceptionUtils.getThrowableList(failure)) {
        if (cause instanceof SocketException) {
            // Connection has been shutdown: javax.net.ssl.SSLException: java.net.SocketException: Broken pipe
            return new DefaultSocketExceptionMappingService().map((SocketException) cause);
        }
    }
    final String message = failure.getMessage();
    for (Alert alert : Alert.values()) {
        if (StringUtils.containsIgnoreCase(message, alert.name())) {
            this.append(buffer, alert.getDescription());
            break;
        }
    }
    if (failure instanceof SSLHandshakeException) {
        if (ExceptionUtils.getRootCause(failure) instanceof CertificateException) {
            log.warn(String.format("Ignore certificate failure %s and drop connection", failure.getMessage()));
            // Server certificate not accepted
            return new ConnectionCanceledException(failure);
        }
        if (ExceptionUtils.getRootCause(failure) instanceof EOFException) {
            // SSL peer shut down incorrectly
            return this.wrap(failure, buffer);
        }
        return new SSLNegotiateException(buffer.toString(), failure);
    }
    if (ExceptionUtils.getRootCause(failure) instanceof GeneralSecurityException) {
        this.append(buffer, ExceptionUtils.getRootCause(failure).getMessage());
        return new InteroperabilityException(buffer.toString(), failure);
    }
    this.append(buffer, message);
    return new InteroperabilityException(buffer.toString(), failure);
}
Also used : SocketException(java.net.SocketException) InteroperabilityException(ch.cyberduck.core.exception.InteroperabilityException) SSLNegotiateException(ch.cyberduck.core.exception.SSLNegotiateException) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) GeneralSecurityException(java.security.GeneralSecurityException) CertificateException(java.security.cert.CertificateException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) DefaultSocketExceptionMappingService(ch.cyberduck.core.DefaultSocketExceptionMappingService) EOFException(java.io.EOFException)

Example 22 with ConnectionCanceledException

use of ch.cyberduck.core.exception.ConnectionCanceledException in project cyberduck by iterate-ch.

the class WriteLifecycleWorker method run.

@Override
public Boolean run(final Session<?> session) throws BackgroundException {
    final Lifecycle feature = session.getFeature(Lifecycle.class);
    if (log.isDebugEnabled()) {
        log.debug(String.format("Run with feature %s", feature));
    }
    final PathContainerService container = session.getFeature(PathContainerService.class);
    for (Path file : this.getContainers(container, files)) {
        if (this.isCanceled()) {
            throw new ConnectionCanceledException();
        }
        this.write(feature, file);
    }
    return true;
}
Also used : Path(ch.cyberduck.core.Path) PathContainerService(ch.cyberduck.core.PathContainerService) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) Lifecycle(ch.cyberduck.core.features.Lifecycle)

Example 23 with ConnectionCanceledException

use of ch.cyberduck.core.exception.ConnectionCanceledException in project cyberduck by iterate-ch.

the class SearchWorker method search.

private AttributedList<Path> search(final Search search, final Path workdir) throws BackgroundException {
    if (this.isCanceled()) {
        throw new ConnectionCanceledException();
    }
    final AttributedList<Path> list;
    if (!search.isRecursive() && cache.isCached(workdir)) {
        list = new AttributedList<>(cache.get(workdir));
    } else {
        // Get filtered list from search
        list = search.search(workdir, new RecursiveSearchFilter(filter), new WorkerListProgressListener(this, listener));
        if (search.isRecursive()) {
            return list;
        } else {
            cache.put(workdir, new AttributedList<>(list));
        }
    }
    final Set<Path> removal = new HashSet<>();
    for (final Path file : list) {
        if (file.isDirectory()) {
            if (log.isDebugEnabled()) {
                log.debug(String.format("Recursively search in %s", file));
            }
            final AttributedList<Path> children = this.search(search, file);
            list.addAll(children);
            if (children.isEmpty()) {
                removal.add(file);
            }
        }
    }
    return list.filter(new NullFilter<Path>() {

        @Override
        public boolean accept(final Path file) {
            return !removal.contains(file);
        }
    }).filter(new RecursiveSearchFilter(filter));
}
Also used : Path(ch.cyberduck.core.Path) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) NullFilter(ch.cyberduck.core.NullFilter) HashSet(java.util.HashSet)

Example 24 with ConnectionCanceledException

use of ch.cyberduck.core.exception.ConnectionCanceledException in project cyberduck by iterate-ch.

the class SessionBackgroundActionTest method testGetExceptionConnectionCanceledException.

@Test
public void testGetExceptionConnectionCanceledException() {
    SessionBackgroundAction<Void> a = new SessionBackgroundAction<Void>(new StatelessSessionPool(new TestLoginConnectionService(), new NullSession(new Host(new TestProtocol(), "t")), new DisabledTranscriptListener(), new DefaultVaultRegistry(new DisabledPasswordCallback())), new DisabledAlertCallback(), new DisabledProgressListener()) {

        @Override
        public Void run(final Session<?> session) throws BackgroundException {
            throw new ConnectionCanceledException();
        }
    };
    try {
        a.call();
        fail();
    } catch (BackgroundException e) {
    // Ignore
    }
    assertFalse(a.hasFailed());
}
Also used : DisabledProgressListener(ch.cyberduck.core.DisabledProgressListener) TestProtocol(ch.cyberduck.core.TestProtocol) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) NullSession(ch.cyberduck.core.NullSession) Host(ch.cyberduck.core.Host) StatelessSessionPool(ch.cyberduck.core.pool.StatelessSessionPool) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) TestLoginConnectionService(ch.cyberduck.core.TestLoginConnectionService) DefaultVaultRegistry(ch.cyberduck.core.vault.DefaultVaultRegistry) DisabledPasswordCallback(ch.cyberduck.core.DisabledPasswordCallback) BackgroundException(ch.cyberduck.core.exception.BackgroundException) NullSession(ch.cyberduck.core.NullSession) Session(ch.cyberduck.core.Session) Test(org.junit.Test)

Example 25 with ConnectionCanceledException

use of ch.cyberduck.core.exception.ConnectionCanceledException in project cyberduck by iterate-ch.

the class CertificateStoreX509KeyManagerTest method testChooseClientAliasStartcom.

@Test
public void testChooseClientAliasStartcom() throws Exception {
    final AtomicBoolean choose = new AtomicBoolean();
    final X509KeyManager m = new CertificateStoreX509KeyManager(new DisabledCertificateIdentityCallback(), new Host(new TestProtocol(), "test2.cyberduck.ch"), new DisabledCertificateStore() {

        @Override
        public X509Certificate choose(final CertificateIdentityCallback prompt, final String[] keyTypes, final Principal[] issuers, final Host bookmark) throws ConnectionCanceledException {
            for (Principal issuer : issuers) {
                assertEquals("CN=StartCom Class 2 Primary Intermediate Client CA", issuer.getName());
            }
            choose.set(true);
            throw new ConnectionCanceledException();
        }
    }).init();
    assertNull(m.chooseClientAlias(new String[] { "RSA", "DSA" }, new Principal[] { new X500Principal("CN=StartCom Class 2 Primary Intermediate Client CA") }, new Socket("test.cyberduck.ch", 443)));
    assertTrue(choose.get());
}
Also used : TestProtocol(ch.cyberduck.core.TestProtocol) ConnectionCanceledException(ch.cyberduck.core.exception.ConnectionCanceledException) DisabledCertificateStore(ch.cyberduck.core.DisabledCertificateStore) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) Host(ch.cyberduck.core.Host) CertificateIdentityCallback(ch.cyberduck.core.CertificateIdentityCallback) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) X500Principal(javax.security.auth.x500.X500Principal) X500Principal(javax.security.auth.x500.X500Principal) BasicUserPrincipal(org.apache.http.auth.BasicUserPrincipal) Principal(java.security.Principal) Socket(java.net.Socket) Test(org.junit.Test)

Aggregations

ConnectionCanceledException (ch.cyberduck.core.exception.ConnectionCanceledException)66 Path (ch.cyberduck.core.Path)28 BackgroundException (ch.cyberduck.core.exception.BackgroundException)17 ArrayList (java.util.ArrayList)16 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)12 IOException (java.io.IOException)11 ExecutionException (java.util.concurrent.ExecutionException)11 Future (java.util.concurrent.Future)11 ThreadPool (ch.cyberduck.core.threading.ThreadPool)10 Test (org.junit.Test)9 ListService (ch.cyberduck.core.ListService)8 PathContainerService (ch.cyberduck.core.PathContainerService)8 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)7 HashMap (java.util.HashMap)7 DefaultIOExceptionMappingService (ch.cyberduck.core.DefaultIOExceptionMappingService)6 IntegrationTest (ch.cyberduck.test.IntegrationTest)6 AttributedList (ch.cyberduck.core.AttributedList)5 Host (ch.cyberduck.core.Host)5 LinkedHashMap (java.util.LinkedHashMap)5 ChecksumException (ch.cyberduck.core.exception.ChecksumException)4