@Test(expected = LoginCanceledException.class) public void testConnectInvalidKey() throws Exception { final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Collections.singleton(new DriveProtocol()))); final Profile profile = new ProfilePlistReader(factory).read( this.getClass().getResourceAsStream("/Google Drive.cyberduckprofile")); final Host host = new Host(profile, "www.googleapis.com", new Credentials()); final DriveSession session = new DriveSession(host, new DefaultX509TrustManager(), new DefaultX509KeyManager()); new LoginConnectionService(new DisabledLoginCallback() { @Override public Credentials prompt(final Host bookmark, final String username, final String title, final String reason, final LoginOptions options) throws LoginCanceledException { if("https: return new VaultCredentials("t"); } throw new LoginCanceledException(); } }, new DisabledHostKeyCallback(), new DisabledPasswordStore(), new DisabledProgressListener() ).connect(session, PathCache.empty(), new DisabledCancelCallback()); assertTrue(session.isConnected()); session.close(); assertFalse(session.isConnected()); }
@Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); }
DriveSession extends HttpSession<Drive> { @Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); } }
DriveSession extends HttpSession<Drive> { @Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); } DriveSession(final Host host, final X509TrustManager trust, final X509KeyManager key); }
DriveSession extends HttpSession<Drive> { @Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); } DriveSession(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); HttpClient getHttpClient(); @Override @SuppressWarnings("unchecked") T _getFeature(Class<T> type); }
DriveSession extends HttpSession<Drive> { @Override protected Drive connect(final Proxy proxy, final HostKeyCallback callback, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(configuration.build(), host.getProtocol()) .withRedirectUri(host.getProtocol().getOAuthRedirectUrl()); configuration.addInterceptorLast(authorizationService); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(new RateLimitingHttpRequestInterceptor(new DefaultHttpRateLimiter( PreferencesFactory.get().getInteger("googledrive.limit.requests.second") ))); this.transport = new ApacheHttpTransport(configuration.build()); final UseragentProvider ua = new PreferencesUseragentProvider(); return new Drive.Builder(transport, new JacksonFactory(), new UserAgentHttpRequestInitializer(ua)) .setApplicationName(ua.get()) .build(); } DriveSession(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); HttpClient getHttpClient(); @Override @SuppressWarnings("unchecked") T _getFeature(Class<T> type);  }