Search in sources :

Example 1 with DefaultTrustManagerHostnameCallback

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;
    }
}
Also used : ConnectionRefusedException(ch.cyberduck.core.exception.ConnectionRefusedException) CertificateStoreX509TrustManager(ch.cyberduck.core.ssl.CertificateStoreX509TrustManager) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) CertificateStoreX509KeyManager(ch.cyberduck.core.ssl.CertificateStoreX509KeyManager) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with DefaultTrustManagerHostnameCallback

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);
}
Also used : KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager)

Example 3 with DefaultTrustManagerHostnameCallback

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;
    }
}
Also used : UserAgentHttpRequestInitializer(ch.cyberduck.core.http.UserAgentHttpRequestInitializer) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) ProxyHostUrlProvider(ch.cyberduck.core.proxy.ProxyHostUrlProvider) GenericUrl(com.google.api.client.http.GenericUrl) DAVSSLProtocol(ch.cyberduck.core.dav.DAVSSLProtocol) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) HttpExceptionMappingService(ch.cyberduck.core.http.HttpExceptionMappingService) HttpConnectionPoolBuilder(ch.cyberduck.core.http.HttpConnectionPoolBuilder) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) X509KeyManager(ch.cyberduck.core.ssl.X509KeyManager) DisabledCertificateTrustCallback(ch.cyberduck.core.DisabledCertificateTrustCallback) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) GsonFactory(com.google.api.client.json.gson.GsonFactory) Host(ch.cyberduck.core.Host) IOException(java.io.IOException) DisabledTranscriptListener(ch.cyberduck.core.DisabledTranscriptListener) HostPreferences(ch.cyberduck.core.preferences.HostPreferences) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) TokenResponse(com.google.api.client.auth.oauth2.TokenResponse) X509TrustManager(ch.cyberduck.core.ssl.X509TrustManager) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) ThreadLocalHostnameDelegatingTrustManager(ch.cyberduck.core.ssl.ThreadLocalHostnameDelegatingTrustManager) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) BasicAuthentication(com.google.api.client.http.BasicAuthentication) PasswordTokenRequest(com.google.api.client.auth.oauth2.PasswordTokenRequest) ApacheHttpTransport(com.google.api.client.http.apache.v2.ApacheHttpTransport) BackgroundException(ch.cyberduck.core.exception.BackgroundException)

Example 4 with DefaultTrustManagerHostnameCallback

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);
}
Also used : AccessDeniedException(ch.cyberduck.core.exception.AccessDeniedException) DisabledCertificateStore(ch.cyberduck.core.DisabledCertificateStore) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) DisabledCertificateIdentityCallback(ch.cyberduck.core.DisabledCertificateIdentityCallback) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) DisabledCertificateTrustCallback(ch.cyberduck.core.DisabledCertificateTrustCallback) Location(ch.cyberduck.core.features.Location) UDTProxyConfigurator(ch.cyberduck.core.udt.UDTProxyConfigurator)

Example 5 with DefaultTrustManagerHostnameCallback

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());
}
Also used : DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) KeychainX509KeyManager(ch.cyberduck.core.ssl.KeychainX509KeyManager) CertificateException(java.security.cert.CertificateException) KeychainX509TrustManager(ch.cyberduck.core.ssl.KeychainX509TrustManager) X509Certificate(java.security.cert.X509Certificate) DefaultTrustManagerHostnameCallback(ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

DefaultTrustManagerHostnameCallback (ch.cyberduck.core.ssl.DefaultTrustManagerHostnameCallback)7 KeychainX509KeyManager (ch.cyberduck.core.ssl.KeychainX509KeyManager)5 KeychainX509TrustManager (ch.cyberduck.core.ssl.KeychainX509TrustManager)5 DisabledCertificateIdentityCallback (ch.cyberduck.core.DisabledCertificateIdentityCallback)3 DisabledCertificateTrustCallback (ch.cyberduck.core.DisabledCertificateTrustCallback)3 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)2 DisabledTranscriptListener (ch.cyberduck.core.DisabledTranscriptListener)2 AccessDeniedException (ch.cyberduck.core.exception.AccessDeniedException)2 BackgroundException (ch.cyberduck.core.exception.BackgroundException)2 HttpConnectionPoolBuilder (ch.cyberduck.core.http.HttpConnectionPoolBuilder)2 ProxyHostUrlProvider (ch.cyberduck.core.proxy.ProxyHostUrlProvider)2 CertificateStoreX509TrustManager (ch.cyberduck.core.ssl.CertificateStoreX509TrustManager)2 ThreadLocalHostnameDelegatingTrustManager (ch.cyberduck.core.ssl.ThreadLocalHostnameDelegatingTrustManager)2 X509KeyManager (ch.cyberduck.core.ssl.X509KeyManager)2 X509TrustManager (ch.cyberduck.core.ssl.X509TrustManager)2 IntegrationTest (ch.cyberduck.test.IntegrationTest)2 IOException (java.io.IOException)2 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)2 Test (org.junit.Test)2 DefaultIOExceptionMappingService (ch.cyberduck.core.DefaultIOExceptionMappingService)1