@Test public void testConnect() throws Exception { assertTrue(session.isConnected()); session.close(); assertFalse(session.isConnected()); }
@Override protected StoregateApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(), host).withRedirectUri(CYBERDUCK_REDIRECT_URI.equals(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); authorizationService.withParameter("prompt", "login"); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(authorizationService); final CloseableHttpClient apache = configuration.build(); final StoregateApiClient client = new StoregateApiClient(apache); final int timeout = PreferencesFactory.get().getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig() .register(new InputStreamProvider()) .register(MultiPartFeature.class) .register(new JSON()) .register(JacksonFeature.class) .connectorProvider(new HttpComponentsProvider(apache)))); client.setUserAgent(new PreferencesUseragentProvider().get()); return client; }
StoregateSession extends HttpSession<StoregateApiClient> { @Override protected StoregateApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(), host).withRedirectUri(CYBERDUCK_REDIRECT_URI.equals(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); authorizationService.withParameter("prompt", "login"); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(authorizationService); final CloseableHttpClient apache = configuration.build(); final StoregateApiClient client = new StoregateApiClient(apache); final int timeout = PreferencesFactory.get().getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig() .register(new InputStreamProvider()) .register(MultiPartFeature.class) .register(new JSON()) .register(JacksonFeature.class) .connectorProvider(new HttpComponentsProvider(apache)))); client.setUserAgent(new PreferencesUseragentProvider().get()); return client; } }
StoregateSession extends HttpSession<StoregateApiClient> { @Override protected StoregateApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(), host).withRedirectUri(CYBERDUCK_REDIRECT_URI.equals(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); authorizationService.withParameter("prompt", "login"); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(authorizationService); final CloseableHttpClient apache = configuration.build(); final StoregateApiClient client = new StoregateApiClient(apache); final int timeout = PreferencesFactory.get().getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig() .register(new InputStreamProvider()) .register(MultiPartFeature.class) .register(new JSON()) .register(JacksonFeature.class) .connectorProvider(new HttpComponentsProvider(apache)))); client.setUserAgent(new PreferencesUseragentProvider().get()); return client; } StoregateSession(final Host host, final X509TrustManager trust, final X509KeyManager key); }
StoregateSession extends HttpSession<StoregateApiClient> { @Override protected StoregateApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(), host).withRedirectUri(CYBERDUCK_REDIRECT_URI.equals(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); authorizationService.withParameter("prompt", "login"); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(authorizationService); final CloseableHttpClient apache = configuration.build(); final StoregateApiClient client = new StoregateApiClient(apache); final int timeout = PreferencesFactory.get().getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig() .register(new InputStreamProvider()) .register(MultiPartFeature.class) .register(new JSON()) .register(JacksonFeature.class) .connectorProvider(new HttpComponentsProvider(apache)))); client.setUserAgent(new PreferencesUseragentProvider().get()); return client; } StoregateSession(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override void login(final Proxy proxy, final LoginCallback controller, final CancelCallback cancel); List<RootFolder> roots(); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type); }
StoregateSession extends HttpSession<StoregateApiClient> { @Override protected StoregateApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt) { final HttpClientBuilder configuration = builder.build(proxy, this, prompt); authorizationService = new OAuth2RequestInterceptor(builder.build(proxy, this, prompt).addInterceptorLast(new HttpRequestInterceptor() { @Override public void process(final HttpRequest request, final HttpContext context) { request.addHeader(HttpHeaders.AUTHORIZATION, String.format("Basic %s", Base64.encodeToString(String.format("%s:%s", host.getProtocol().getOAuthClientId(), host.getProtocol().getOAuthClientSecret()).getBytes(StandardCharsets.UTF_8), false))); } }).build(), host).withRedirectUri(CYBERDUCK_REDIRECT_URI.equals(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : Scheme.isURL(host.getProtocol().getOAuthRedirectUrl()) ? host.getProtocol().getOAuthRedirectUrl() : new HostUrlProvider().withUsername(false).withPath(true).get( host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getOAuthRedirectUrl()) ); authorizationService.withParameter("prompt", "login"); configuration.setServiceUnavailableRetryStrategy(new OAuth2ErrorResponseInterceptor(host, authorizationService, prompt)); configuration.addInterceptorLast(authorizationService); final CloseableHttpClient apache = configuration.build(); final StoregateApiClient client = new StoregateApiClient(apache); final int timeout = PreferencesFactory.get().getInteger("connection.timeout.seconds") * 1000; client.setConnectTimeout(timeout); client.setBasePath(new HostUrlProvider().withUsername(false).withPath(true).get(host.getProtocol().getScheme(), host.getPort(), null, host.getHostname(), host.getProtocol().getContext())); client.setHttpClient(ClientBuilder.newClient(new ClientConfig() .register(new InputStreamProvider()) .register(MultiPartFeature.class) .register(new JSON()) .register(JacksonFeature.class) .connectorProvider(new HttpComponentsProvider(apache)))); client.setUserAgent(new PreferencesUseragentProvider().get()); return client; } StoregateSession(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override void login(final Proxy proxy, final LoginCallback controller, final CancelCallback cancel); List<RootFolder> roots(); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type);  }