private void initProxy(AuthenticatorFacade system, Configuration config) { // register credentials Optional<String> login = config.get(HTTP_PROXY_USER); if (login.isPresent()) { system.setDefaultAuthenticator(new ProxyAuthenticator(login.get(), config.get(HTTP_PROXY_PASSWORD).orElse(null))); } }
public DefaultHttpDownloader(Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) { this.readTimeout = readTimeout; this.connectTimeout = connectTimeout; downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, null); }
public DefaultHttpDownloader(Server server, Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) { this.readTimeout = readTimeout; this.connectTimeout = connectTimeout; downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, server.getVersion()); }
public DefaultHttpDownloader(Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) { this.readTimeout = readTimeout; this.connectTimeout = connectTimeout; downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, null); }
private void initProxy(AuthenticatorFacade system, Configuration config) { // register credentials Optional<String> login = config.get(HTTP_PROXY_USER); if (login.isPresent()) { system.setDefaultAuthenticator(new ProxyAuthenticator(login.get(), config.get(HTTP_PROXY_PASSWORD).orElse(null))); } }
@Test public void configure_http_proxy_credentials() { DefaultHttpDownloader.AuthenticatorFacade system = mock(DefaultHttpDownloader.AuthenticatorFacade.class); MapSettings settings = new MapSettings(); settings.setProperty("https.proxyHost", "1.2.3.4"); settings.setProperty("http.proxyUser", "the_login"); settings.setProperty("http.proxyPassword", "the_passwd"); new DefaultHttpDownloader.BaseHttpDownloader(system, settings.asConfig(), null); verify(system).setDefaultAuthenticator(argThat(authenticator -> { DefaultHttpDownloader.ProxyAuthenticator a = (DefaultHttpDownloader.ProxyAuthenticator) authenticator; PasswordAuthentication authentication = a.getPasswordAuthentication(); return authentication.getUserName().equals("the_login") && new String(authentication.getPassword()).equals("the_passwd"); })); }
public DefaultHttpDownloader(Server server, Configuration config, @Nullable Integer connectTimeout, @Nullable Integer readTimeout) { this.readTimeout = readTimeout; this.connectTimeout = connectTimeout; downloader = new BaseHttpDownloader(new AuthenticatorFacade(), config, server.getVersion()); }