public HttpClientContext createContext() throws JHttpCException { return createContext( null ); }
public CloseableHttpClient createClient() throws JHttpCException { return createClient( null, null ); }
public CloseableHttpClient newClient() throws IndyClientException { try { return factory.createClient( location, defaultHeaders ); } catch ( JHttpCException e ) { throw new IndyClientException( "Indy request failed: %s", e, e.getMessage() ); } }
SiteConfigBuilder configBuilder = new SiteConfigBuilder( location.getName(), location.getUri() ); configBuilder.withAttributes( location.getAttributes() ) .withKeyCertPem( location.getKeyCertPem() ) .withServerCertPem( location.getServerCertPem() ) .withProxyHost( location.getProxyHost() ) .withProxyPort( location.getProxyPort() ) .withProxyUser( location.getProxyUser() ) .withRequestTimeoutSeconds( LocationUtils.getTimeoutSeconds( location ) ) .withUser( location.getUser() ) .withIgnoreHostnameVerification( location.isIgnoreHostnameVerification() ) .withMaxConnections( maxConnections ); configBuilder.withTrustType( SiteTrustType.getType( location.getTrustType().name() ) ); SiteConfig config = configBuilder.build(); return httpFactory.createClient( config ); return httpFactory.createClient(); throw new TransferLocationException( location, "Failed to initialize http client: %s", e, e.getMessage() );
@PostConstruct private void postConstruct() { try { PasswordManager emptyPasswordManager = new MemoryPasswordManager(); SiteConfig sc = new SiteConfigBuilder().withId("Carto") .withUri(config.getConfig().getCartographerServerUrl()) .withRequestTimeoutSeconds(config.getConfig().getAproxRequestTimeout()).build(); HttpFactory httpFactory = new HttpFactory(emptyPasswordManager); cartographer = new CartographerRESTClient(sc, httpFactory); } catch (ConfigurationParseException | ClientHttpException e) { throw new IllegalStateException("Could not initialize Cartographer Client.", e); } }
SSLConnectionSocketFactory fac = (SSLConnectionSocketFactory) location.getAttribute( SSL_FACTORY_ATTRIB ); if ( fac != null ) final String kcPem = location.getKeyCertPem(); final String kcPass = passwords == null ? null : passwords.lookup( new PasswordKey( location, PasswordType.KEY ) ); if ( kcPem != null ) location.getUri() ); throw new JHttpCException( "Location: " + location.getUri() + " is misconfigured! Key password cannot be empty." ); ks = SSLUtils.readKeyAndCert( kcPem, kcPass ); logger.trace( "Keystore contains the following certificates: {}", new CertEnumerator( ks, kcPass ) ); location.getUri(), e.getMessage() ), e ); throw new JHttpCException( "Failed to initialize SSL connection for repository: " + location.getUri() ); location.getUri(), e.getMessage() ), e ); throw new JHttpCException( "Failed to initialize SSL connection for repository: " + location.getUri() ); location.getUri(), e.getMessage() ), e ); throw new JHttpCException( "Failed to initialize SSL connection for repository: " + location.getUri() ); location.getUri(), e.getMessage() ), e ); throw new JHttpCException( "Failed to initialize SSL connection for repository: " + location.getUri() ); throw new JHttpCException( "Failed to read client SSL key/certificate from: %s. Reason: %s", e,
HttpClientContext prototype = location.getClientContextPrototype(); if ( prototype != null ) copyContextPrototype( prototype, ctx ); RequestConfig reqConf = location.getRequestConfig(); if ( reqConf == null ) location.getConnectionPoolTimeoutSeconds() ); location.getConnectionPoolTimeoutSeconds() ) .build(); CookieStore cookieStore = (CookieStore) location.getAttribute( COOKIE_STORE ); if ( cookieStore == null ) location.setAttribute( COOKIE_STORE, cookieStore ); as = new AuthScope( location.getHost(), location.getPort() ); throw new JHttpCException( "Failed to parse site URL for host and port: %s (site id: %s). Reason: %s", e, location.getUri(), location.getId(), e.getMessage() ); if ( location.getUser() != null ) ctx = authenticator.decoratePrototypeContext( as, location, PasswordType.USER, ctx ); if ( location.getProxyHost() != null && location.getProxyUser() != null )
builder = authenticator.decorateClientBuilder( builder ); SiteConnectionConfig connConfig = new SiteConnectionConfig( location ); final SSLConnectionSocketFactory sslFac = createSSLSocketFactory( location ); if ( sslFac != null ) connConfig.withSSLConnectionSocketFactory( sslFac ); ConnectionManagerTracker managerWrapper = connectionCache.getTrackerFor( connConfig ); logger.debug( "Using connection manager tracker: {}", managerWrapper ); builder.setConnectionManager( managerWrapper.acquire() ); if ( location.getProxyHost() != null ) new HttpHost( location.getProxyHost(), getProxyPort( location ) ) ); builder.setRoutePlanner( planner ); final int timeout = 1000 * location.getRequestTimeoutSeconds(); builder.setDefaultRequestConfig( RequestConfig.custom() client = new TrackedHttpClient( builder.build(), managerWrapper );
public IndyClientHttp( final IndyClientAuthenticator authenticator, final IndyObjectMapper mapper, SiteConfig location, String apiVersion ) throws IndyClientException { this.objectMapper = mapper; this.location = location; baseUrl = location.getUri(); checkBaseUrl( baseUrl ); addApiVersionHeader( apiVersion ); factory = new HttpFactory( authenticator ); }
String url = UrlUtils.buildUrl( siteConfig.getUri(), extraPath ); logger.trace( "Unadorned URL: '{}'", url ); siteConfig.getUri(), Arrays.asList( extraPath ), e.getMessage() ); try client = httpFactory.createClient( siteConfig );
public HttpClientContext newContext() throws IndyClientException { try { return factory.createContext( location ); } catch ( JHttpCException e ) { throw new IndyClientException( "Indy request failed: %s", e, e.getMessage() ); } }
public KojiClient( KojiConfig config, PasswordManager passwordManager, ExecutorService executorService, MetricRegistry metricRegistry ) throws KojiClientException { this.config = config; this.httpFactory = new HttpFactory( passwordManager ); this.executorService = executorService; this.metricRegistry = metricRegistry; setup(); }
@PostConstruct public void setup() { passwordManager = new org.commonjava.maven.galley.auth.AttributePasswordManager(); http = new HttpImpl( passwordManager ); httpFactory = new HttpFactory( new AttributePasswordManager( siteConfigLookup ) ); }
aliases.add( "certificate" + certIdx ); extractAliases( certificate, aliases ); throw new JHttpCException( "Failed to decrypt key/certificate: %s", e, e.getMessage() );
@Override public void close() { logger.debug( "Shutting down indy client HTTP manager" ); try { factory.close(); } catch ( IOException e ) { logger.debug( "Shutting down indy client HTTP factory error", e ); // log and return quietly } }
/** * Create http client and apply site config. * @param siteId ID to represent the site. It is generally the hostname of target site. * @return * @throws IndyHttpException */ public CloseableHttpClient createClient( final String siteId ) throws IndyHttpException { try { return httpFactory.createClient( siteConfigLookup.lookup( siteId ) ); } catch ( JHttpCException e ) { throw new IndyHttpException( "Failed to create http client: %s", e, e.getMessage() ); } }
public IndyClientHttp( final PasswordManager passwordManager, final IndyObjectMapper mapper, SiteConfig location, String apiVersion ) throws IndyClientException { this.objectMapper = mapper; this.location = location; baseUrl = location.getUri(); checkBaseUrl( baseUrl ); addApiVersionHeader( apiVersion ); factory = new HttpFactory( passwordManager ); }
/** * Create http request context and apply site config. * @param siteId ID to represent the site. It is generally the hostname of target site. * @return * @throws IndyHttpException */ public HttpClientContext createContext( final String siteId ) throws IndyHttpException { try { return httpFactory.createContext( siteConfigLookup.lookup( siteId ) ); } catch ( JHttpCException e ) { throw new IndyHttpException( "Failed to create http client context: %s", e, e.getMessage() ); } }
try client = httpFactory.createClient( config.getKojiSiteConfig() );
public HttpImpl( final PasswordManager passwords ) { this.passwords = passwords; this.locationLookup = new LocationLookup(); this.httpFactory = new HttpFactory( new HttpFactoryPasswordDelegate( passwords, locationLookup ) ); }