Package org.apache.http.auth

Examples of org.apache.http.auth.AuthScope


    if (username != null && username.length() > 0)
    {
      UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
     
      CredentialsProvider credsProvider = new BasicCredentialsProvider();
      credsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), credentials);
     
      localContext.setAttribute(ClientContext.CREDS_PROVIDER, credsProvider);
    }
   
    HttpGet     httpGet = new HttpGet(url);
View Full Code Here


    private URL url;

    protected void makeCall(String user, String pass, int expectedStatusCode) throws Exception {
        DefaultHttpClient httpclient = new DefaultHttpClient();
        try {
            httpclient.getCredentialsProvider().setCredentials(new AuthScope(url.getHost(), url.getPort()),
                    new UsernamePasswordCredentials(user, pass));

            HttpGet httpget = new HttpGet(url.toExternalForm() + "secured/");

            System.out.println("executing request" + httpget.getRequestLine());
View Full Code Here

            httpClient = HttpClientUtils.wrapHttpsClient(new DefaultHttpClient());
        } else {
            httpClient = new DefaultHttpClient();
        }

        ((DefaultHttpClient) httpClient).getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY),
                new UsernamePasswordCredentials(user, pass));

        HttpGet get = new HttpGet(url);
        HttpResponse hr;
        try {
View Full Code Here

        remotePassword = pwdLoader.loadPassword(remoteUsername);
      if (remotePassword != null) {
        try {
          URL urlParsed = new URL(url);
          String host = urlParsed.getHost();
          httpclientImpl.getCredentialsProvider().setCredentials(new AuthScope(host, AuthScope.ANY_PORT),
              new UsernamePasswordCredentials(remoteUsername, remotePassword));
          isAuthConfigured = true;
        } catch (MalformedURLException e) {
          // this should never happen due validation before
        }
View Full Code Here

        HttpResponse response = httpclient.execute(getServerHttp(), httpget);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
        entity.consumeContent();
        AuthScope authscope = credsProvider.getAuthScope();
        Assert.assertNotNull(authscope);
        Assert.assertEquals("test realm", authscope.getRealm());
    }
View Full Code Here

        HttpResponse response = httpclient.execute(getServerHttp(), httpget);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_UNAUTHORIZED, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
        entity.consumeContent();
        AuthScope authscope = credsProvider.getAuthScope();
        Assert.assertNotNull(authscope);
        Assert.assertEquals("test realm", authscope.getRealm());
    }
View Full Code Here

        HttpResponse response = httpclient.execute(getServerHttp(), httpget);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
        entity.consumeContent();
        AuthScope authscope = credsProvider.getAuthScope();
        Assert.assertNotNull(authscope);
        Assert.assertEquals("test realm", authscope.getRealm());
    }
View Full Code Here

        HttpResponse response = httpclient.execute(getServerHttp(), httppost);
        HttpEntity entity = response.getEntity();
        Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
        Assert.assertNotNull(entity);
        entity.consumeContent();
        AuthScope authscope = credsProvider.getAuthScope();
        Assert.assertNotNull(authscope);
        Assert.assertEquals("test realm", authscope.getRealm());
    }
View Full Code Here

        // Export
        // 1. XML (default)

        final HttpClient client = ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory()).getHttpClient();
        final AuthScope scope = ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory()).getAuthScope();
        final HttpHost targetHost = new HttpHost(scope.getHost(), scope.getPort(), scope.getScheme());


        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();
View Full Code Here

        assertTrue(!reportTO.getExecutions().isEmpty());

        // Export
        final HttpClient client = ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory()).getHttpClient();
        final AuthScope scope = ((PreemptiveAuthHttpRequestFactory) restTemplate.getRequestFactory()).getAuthScope();
        final HttpHost targetHost = new HttpHost(scope.getHost(), scope.getPort(), scope.getScheme());

        // Add AuthCache to the execution context
        BasicHttpContext localcontext = new BasicHttpContext();

        // Generate BASIC scheme object and add it to the local auth cache
View Full Code Here

TOP

Related Classes of org.apache.http.auth.AuthScope

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.