Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.UsernamePasswordCredentials


    HttpClient c = new HttpClient(connectionManager);

    // use basic authentication if available
    if (user != null && user.length() > 0) {
      AuthScope authScope = new AuthScope(null, -1, null);
      Credentials credentials = new UsernamePasswordCredentials(user, password);
      c.getState().setCredentials(authScope, credentials);
    }
    return c;
  }
View Full Code Here


      // gives an unauthorized response in certain situations, thus reducing the overhead of making the
      // connection.
      client.getState().setAuthenticationPreemptive(true);

      // Set up the WMS credentials:
      Credentials credentials = new UsernamePasswordCredentials(authentication.getUser(),
          authentication.getPassword());
      client.getState().setCredentials(authentication.getRealm(), parseDomain(url), credentials);
    }

    // Create the GET method with the correct URL:
View Full Code Here

      {
         log.debug("Connecting to: "+url);
         String userInfo = url.getUserInfo();
         if( userInfo != null )
         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials(realm, url.getHost(), auth);
         }
         log.debug("RequestURI: "+request.getURI());
         int responseCode = httpConn.executeMethod(request);
         String response = request.getStatusText();
View Full Code Here

         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();

         if( userInfo != null )
         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials("JBossTest Servlets", url.getHost(), auth);
         }
         log.info("RequestURI: "+request.getURI());
         int responseCode = httpConn.executeMethod(request);
         String response = request.getStatusText();
View Full Code Here

         log.info("Connecting to: "+ url);
         String userInfo = url.getUserInfo();

         if( userInfo != null )
         {
            UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
            httpConn.getState().setCredentials(realm, url.getHost(), auth);
         }
         log.info("RequestURI: "+request.getURI());
         int responseCode = httpConn.executeMethod(request);
         String response = request.getStatusText();
View Full Code Here

  }
 
  @Test
  public void testSecureLinksAdmin() throws Exception
  {
    httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "asd"));
    Book book = client.getBookXML("foo");
    checkBookLinks1(url, book, "add", "update", "list", "self", "remove");
  }
View Full Code Here

  }

  @Test
  public void testSecureLinksPowerUser() throws Exception
  {
    httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("power-user", "asd"));
    Book book = client.getBookXML("foo");
    checkBookLinks1(url, book, "add", "update", "list", "self");
  }
View Full Code Here

  }

  @Test
  public void testSecureLinksUser() throws Exception
  {
    httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("user", "asd"));
    Book book = client.getBookXML("foo");
    checkBookLinks1(url, book, "list", "self");
  }
View Full Code Here

      HttpClient client = new HttpClient();
     
      client.getState().setCredentials(
          //new AuthScope(null, 8080, "Test"),
          new AuthScope(AuthScope.ANY),
          new UsernamePasswordCredentials("bill", "password")
      );
      {
         GetMethod method = new GetMethod("http://localhost:8080/basic-integration-test/security");
         method.setDoAuthentication(true);
         int status = client.executeMethod(method);
View Full Code Here

      HttpClient client = new HttpClient();
      client.getParams().setAuthenticationPreemptive(true);

      client.getState().setCredentials(
              //new AuthScope(null, 8080, "Test"),
              new AuthScope(AuthScope.ANY), new UsernamePasswordCredentials("bill", "password"));
      {
         GetMethod method = createGetMethod("/secured");
         method.setDoAuthentication(true);
         int status = client.executeMethod(method);
         Assert.assertEquals(HttpResponseCodes.SC_OK, status);
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.UsernamePasswordCredentials

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.