Package org.sonatype.nexus.proxy.storage.remote.httpclient

Examples of org.sonatype.nexus.proxy.storage.remote.httpclient.RemoteStorageContextCustomizer


      final SSLConnectionSocketFactory sslSocketFactory = new SSLConnectionSocketFactory(sc, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
      final Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
          .register("http", PlainConnectionSocketFactory.getSocketFactory())
          .register("https", sslSocketFactory).build();

      httpClientBuilder = httpClientFactory.prepare(new RemoteStorageContextCustomizer(context));
      connectionManager = new BasicHttpClientConnectionManager(registry);
      httpClientBuilder.getHttpClientBuilder().setConnectionManager(connectionManager);
      httpClientBuilder.getHttpClientBuilder().addInterceptorFirst(
          new HttpResponseInterceptor()
          {
View Full Code Here


  }

  @Override
  public HttpClient create() {
    RemoteStorageContext context = globalRemoteStorageContextProvider.get();
    Builder builder = prepare(new RemoteStorageContextCustomizer(context));

    // FIXME: Why is this here and not general?
    boolean reuseConnections = reuseConnectionsNeeded(context);
    if (!reuseConnections) {
      builder.getHttpClientBuilder().setConnectionReuseStrategy(new NoConnectionReuseStrategy());
View Full Code Here

          eventBus,
          jmxInstaller,
          null);

      // just to grab UA
      final Builder builder = testSubject.prepare(new RemoteStorageContextCustomizer(globalRemoteStorageContext));
      final String userAgent = builder.getUserAgent();
      final HttpClient client = builder.build();

      activity.perform(client);
View Full Code Here

      // Note: explicitly created instance (like in case of proxies), it does pool and
      // returns customized client

      // we will reuse the "global" one, but this case is treated differently anyway by factory
      final HttpClient client =
          testSubject.create(new RemoteStorageContextCustomizer(globalRemoteStorageContext));
      // shared client does reuse connections (does pool)
      Assert.assertTrue(
          ((DefaultHttpClient) client).getConnectionReuseStrategy() instanceof DefaultConnectionReuseStrategy);
      Assert.assertTrue(((DefaultHttpClient) client).getConnectionManager() instanceof PoolingClientConnectionManager);
View Full Code Here

        Providers.of(globalRemoteStorageContext),
        eventBus,
        jmxInstaller,
        null);

    RemoteStorageContextCustomizer customizer = new RemoteStorageContextCustomizer(globalRemoteStorageContext);
    final Builder builder = testSubject.prepare(customizer);

    final RemoteAuthenticationSettings remoteAuthenticationSettings =
        new UsernamePasswordRemoteAuthenticationSettings("user", "pass");
    customizer.applyAuthenticationConfig(builder, remoteAuthenticationSettings, null);

    final DefaultRemoteHttpProxySettings httpProxy = new DefaultRemoteHttpProxySettings();
    httpProxy.setHostname("http-proxy");
    httpProxy.setPort(8080);
    httpProxy.setProxyAuthentication(new UsernamePasswordRemoteAuthenticationSettings("http-proxy", "http-pass"));

    final DefaultRemoteHttpProxySettings httpsProxy = new DefaultRemoteHttpProxySettings();
    httpsProxy.setHostname("https-proxy");
    httpsProxy.setPort(9090);
    httpsProxy.setProxyAuthentication(new UsernamePasswordRemoteAuthenticationSettings("https-proxy", "https-pass"));

    final DefaultRemoteProxySettings remoteProxySettings = new DefaultRemoteProxySettings();
    remoteProxySettings.setHttpProxySettings(httpProxy);
    remoteProxySettings.setHttpsProxySettings(httpsProxy);

    customizer.applyProxyConfig(builder, remoteProxySettings);

    final CredentialsProvider credentialsProvider = builder.getCredentialsProvider();

    assertThat(credentialsProvider.getCredentials(AuthScope.ANY), notNullValue(Credentials.class));
    assertThat(credentialsProvider.getCredentials(AuthScope.ANY).getUserPrincipal().getName(), equalTo("user"));
View Full Code Here

    try {
      ProxyRepository proxyRepository = getUnprotectedRepositoryRegistry().getRepositoryWithFacet(id,
          ProxyRepository.class);
      HttpClient client = httpClientProvider.create(
          new RemoteStorageContextCustomizer(proxyRepository.getRemoteStorageContext()));

      MavenRepositoryReader mr = new MavenRepositoryReader(client, queryStringBuilder);
      MavenRepositoryReaderResponse data = new MavenRepositoryReaderResponse();
      // FIXME: Sort this out, NEXUS-4058 was closed about a year go (orig: we really should not do the encoding here, but this is work around until NEXUS-4058 is fixed).
      String localUrl = createRemoteResourceReference(request, id, "").toString(false, false);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.storage.remote.httpclient.RemoteStorageContextCustomizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.