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);
}
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;
}
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));
}
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());
}
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());
}
Aggregations