Package org.apache.http

Examples of org.apache.http.HttpHost


    public static Test suite() {
        return new TestSuite(TestConnPoolByRoute.class);
    }

    public void testStatelessConnections() throws Exception {
        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);

        ClientConnectionOperator operator = new DefaultClientConnectionOperator(
                supportedSchemes);
       
View Full Code Here


            connPool.shutdown();
        }
    }

    public void testStatefullConnections() throws Exception {
        final HttpHost target = getServerHttp();
        final HttpRoute route = new HttpRoute(target, null, false);

        ClientConnectionOperator operator = new DefaultClientConnectionOperator(
                supportedSchemes);
       
View Full Code Here

            client.getCredentialsProvider().setCredentials( new AuthScope( host, port ), creds );

            AuthCache authCache = new BasicAuthCache();
            BasicScheme basicAuth = new BasicScheme();
            HttpHost targetHost = new HttpHost( repository.getHost(), repository.getPort(), repository.getProtocol() );
            authCache.put( targetHost, basicAuth );

            localContext = new BasicHttpContext();
            localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
        }

        ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
        if ( proxyInfo != null )
        {
            String proxyUsername = proxyInfo.getUserName();
            String proxyPassword = proxyInfo.getPassword();
            String proxyHost = proxyInfo.getHost();
            int proxyPort = proxyInfo.getPort();
            String proxyNtlmHost = proxyInfo.getNtlmHost();
            String proxyNtlmDomain = proxyInfo.getNtlmDomain();
            if ( proxyHost != null )
            {
                HttpHost proxy = new HttpHost( proxyHost, proxyPort );

                if ( proxyUsername != null && proxyPassword != null )
                {
                    Credentials creds;
                    if ( proxyNtlmHost != null || proxyNtlmDomain != null )
View Full Code Here

            AuthState authState =
                (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
            CredentialsProvider credsProvider =
                (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
            HttpHost targetHost =
                (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

            // If not auth scheme has been initialized yet
            if (authState.getAuthScheme() == null) {
                AuthScope authScope =
                    new AuthScope(targetHost.getHostName(), targetHost.getPort());

                // Obtain credentials matching the target host
                Credentials creds = credsProvider.getCredentials(authScope);

                // If found, generate BasicScheme preemptively
View Full Code Here

    }

    public void initializeClient(String username, String password) {
        //this.layerName = null;
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpHost targetHost = new HttpHost(this.serverName, 80, "http");
       
        if (!(username.isEmpty() && password.isEmpty())){
          this.credentials = new UsernamePasswordCredentials(username, password);

          httpclient.getCredentialsProvider().setCredentials(
View Full Code Here

      }
    }
  }
 
  public void abstractRequest(HttpServletRequest request, HttpServletResponse response, String remoteAddress, String action){
    HttpHost targetHost = new HttpHost(remoteAddress);
    HttpClient httpclient = this.ogpHttpClient.getHttpClient();
   
    if (useAuthentication){
      int port = targetHost.getPort();
      String hostName = targetHost.getHostName();
   
      this.credentials = new UsernamePasswordCredentials(this.username, this.password);
//this may not work.  may need a new client.
      ((AbstractHttpClient) httpclient).getCredentialsProvider().setCredentials(
              new AuthScope(hostName, port),
View Full Code Here

                final CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom()
                        .setDefaultCredentialsProvider(credentialsProvider)
                        .build();

                HttpGet get = new HttpGet(endpoint.getUri());
                HttpHost target = URIUtils.extractHost(get.getURI());
                BasicAsyncRequestProducer basicAsyncRequestProducer = new BasicAsyncRequestProducer(target, get);
                httpClient.start();
                try {
                    log.debug("sending request");
                    Future<HttpResponse> futureResponse = httpClient.execute(
View Full Code Here

    public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {

        AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
        CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

        // If not auth scheme has been initialized yet
        if (authState.getAuthScheme() == null) {
            AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());

            // Obtain credentials matching the target host
            Credentials creds = credsProvider.getCredentials(authScope);

            // If found, generate BasicScheme preemptively
View Full Code Here

        }

        if (authenticable instanceof Executor) {
            Executor executor = (Executor) authenticable;

            Executor authenticated = executor.auth(new HttpHost(endpoint.getUri().getHost(), endpoint.getUri().getPort()),
                    username, password).authPreemptive(
                        new HttpHost(endpoint.getUri().getHost(), endpoint.getUri().getPort()));
            log.debug("authenticated executor HTTP client with user and password");
            return authenticated;

        } else if (authenticable instanceof CredentialsProvider) {
            CredentialsProvider credentialsProvider = (CredentialsProvider) authenticable;
            credentialsProvider.setCredentials(new AuthScope(new HttpHost(endpoint.getUri().getHost(), endpoint.getUri().getPort())),
                    new UsernamePasswordCredentials(username, password));

            log.debug("authenticated CredentialsProvider HTTP client with user and password");
            return credentialsProvider;
        }
View Full Code Here

    public HttpHost getTarget() {
        return this.requestProducer.getTarget();
    }

    public HttpRequest generateRequest() throws IOException, HttpException {
        HttpHost target = this.requestProducer.getTarget();
        HttpRequest request = this.requestProducer.generateRequest();
        request.setParams(new DefaultedHttpParams(request.getParams(), this.params));

        this.localContext.setAttribute(ExecutionContext.HTTP_REQUEST, request);
        this.localContext.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
View Full Code Here

TOP

Related Classes of org.apache.http.HttpHost

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.