use of ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback in project cyberduck by iterate-ch.
the class DAVSessionTest method testConnectRefused.
@Test(expected = ConnectionRefusedException.class)
public void testConnectRefused() throws Exception {
final Host host = new Host(new DAVSSLProtocol(), "localhost", 2121);
final DAVSession session = new DAVSession(host, new CertificateStoreX509TrustManager(new DisabledCertificateTrustCallback(), new DefaultTrustManagerHostnameCallback(host), new DefaultCertificateStore()), new CertificateStoreX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DefaultCertificateStore()));
try {
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
} catch (ConnectionRefusedException e) {
assertEquals("Connection failed", e.getMessage());
throw e;
}
}
use of ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback in project cyberduck by iterate-ch.
the class SessionPoolFactory method create.
public static SessionPool create(final Controller controller, final Host bookmark, final HostPasswordStore keychain, final LoginCallback login, final HostKeyCallback key, final ProgressListener listener, final TranscriptListener transcript, final Usage... usage) {
final LoginConnectionService connect = new LoginConnectionService(login, key, keychain, listener);
final CertificateStore certificates = CertificateStoreFactory.get();
return create(connect, transcript, bookmark, new KeychainX509TrustManager(CertificateTrustCallbackFactory.get(controller), new DefaultTrustManagerHostnameCallback(bookmark), certificates), new KeychainX509KeyManager(CertificateIdentityCallbackFactory.get(controller), bookmark, certificates), VaultRegistryFactory.create(keychain, login), usage);
}
use of ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback in project cyberduck by iterate-ch.
the class FreenetAuthenticatedUrlProvider method toUrl.
@Override
public DescriptiveUrl toUrl(final Host bookmark) {
try {
// Run password flow
final TokenResponse response;
try {
final Host target = new Host(new DAVSSLProtocol(), "oauth.freenet.de");
final X509TrustManager trust = new KeychainX509TrustManager(new DisabledCertificateTrustCallback(), new DefaultTrustManagerHostnameCallback(target), CertificateStoreFactory.get());
final X509KeyManager key = new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), target, CertificateStoreFactory.get());
final CloseableHttpClient client = new HttpConnectionPoolBuilder(target, new ThreadLocalHostnameDelegatingTrustManager(trust, target.getHostname()), key, ProxyFactory.get()).build(ProxyFactory.get().find(new ProxyHostUrlProvider().get(target)), new DisabledTranscriptListener(), new DisabledLoginCallback()).setUserAgent(new FreenetUserAgentProvider().get()).build();
final String username = bookmark.getCredentials().getUsername();
final String password;
if (StringUtils.isBlank(bookmark.getCredentials().getPassword())) {
password = PasswordStoreFactory.get().findLoginPassword(bookmark);
} else {
password = bookmark.getCredentials().getPassword();
}
response = new PasswordTokenRequest(new ApacheHttpTransport(client), new GsonFactory(), new GenericUrl("https://oauth.freenet.de/oauth/token"), username, password).setClientAuthentication(new BasicAuthentication("desktop_client", "6LIGIHuOSkznLomu5xw0EPPBJOXb2jLp")).setRequestInitializer(new UserAgentHttpRequestInitializer(new FreenetUserAgentProvider())).set("world", new HostPreferences(bookmark).getProperty("world")).set("webLogin", Boolean.TRUE).execute();
final FreenetTemporaryLoginResponse login = this.getLoginSession(client, response.getAccessToken());
return new DescriptiveUrl(URI.create(login.urls.login), DescriptiveUrl.Type.authenticated);
} catch (IOException e) {
throw new HttpExceptionMappingService().map(e);
}
} catch (BackgroundException e) {
log.warn(String.format("Failure %s retrieving authenticated URL for %s", e, bookmark));
return DescriptiveUrl.EMPTY;
}
}
use of ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback in project cyberduck by iterate-ch.
the class QloudsonicTransferAcceleration method configure.
@Override
public void configure(final boolean enable, final Path file) throws BackgroundException {
final Location.Name location = session.getFeature(Location.class).getLocation(file);
if (Location.unknown.equals(location)) {
throw new AccessDeniedException("Cannot read bucket location");
}
final UDTProxyConfigurator configurator = new UDTProxyConfigurator(location, this.provider(), new KeychainX509TrustManager(new DisabledCertificateTrustCallback(), new DefaultTrustManagerHostnameCallback(session.getHost()), new DisabledCertificateStore()), new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), session.getHost(), new DisabledCertificateStore()));
configurator.configure(session);
}
use of ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback in project cyberduck by iterate-ch.
the class S3ObjectListServiceTest method testLaxHostnameVerification.
@Test
public void testLaxHostnameVerification() throws Exception {
final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")));
final KeychainX509TrustManager trust = new KeychainX509TrustManager(new DisabledCertificateTrustCallback(), new DefaultTrustManagerHostnameCallback(host), new DisabledCertificateStore() {
@Override
public boolean verify(final CertificateTrustCallback prompt, final String hostname, final List<X509Certificate> certificates) throws CertificateException {
assertEquals("ch.s3.amazonaws.com", hostname);
return true;
}
});
final S3Session session = new S3Session(host, new DisabledX509TrustManager(), new KeychainX509KeyManager(new DisabledCertificateIdentityCallback(), host, new DisabledCertificateStore()));
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(), new DisabledProgressListener());
login.check(session, new DisabledCancelCallback());
new S3ObjectListService(session).list(new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume, Path.Type.directory)), new DisabledListProgressListener());
}
Aggregations