Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.UsernamePasswordCredentials


      IProxyData[] proxies = _proxyService.select(_uri);
      if (proxies != null && proxies.length > 0) {
        IProxyData proxy = proxies[0];
        getHostConfiguration().setProxy(proxy.getHost(), proxy.getPort());
        if (proxy.isRequiresAuthentication()) {
          Credentials credentials = new UsernamePasswordCredentials(proxy.getUserId(), proxy.getPassword());
          getState().setProxyCredentials(AuthScope.ANY, credentials);       
        } else {
          getState().setProxyCredentials(AuthScope.ANY, null);
        }
      } else {
View Full Code Here


                    if (domain != null) {
                        /*Credentials for NTLM Authentication*/
                        creds = new NTCredentials(username, password, host, domain);
                    } else {
                        /*Credentials for Digest and Basic Authentication*/
                        creds = new UsernamePasswordCredentials(username, password);
                    }
                    agent.getState().setCredentials(new AuthScope(host, port, realm), creds);
                } else {
                    if (domain != null) {
                        /*Credentials for NTLM Authentication when host is ANY_HOST*/
                        creds = new NTCredentials(username, password, AuthScope.ANY_HOST, domain);
                        agent.getState().setCredentials(
                                new AuthScope(AuthScope.ANY_HOST, port, realm), creds);
                    } else {
                        /*Credentials only for Digest and Basic Authentication*/
                        creds = new UsernamePasswordCredentials(username, password);
                        agent.getState().setCredentials(new AuthScope(AuthScope.ANY), creds);
                    }
                }
                /* Customizing the priority Order */
                List schemes = authenticator.getAuthSchemes();
View Full Code Here

            client.setHostConfiguration(config);

            if (username != null)
            {
                final UsernamePasswordCredentials creds =
                    new UsernamePasswordCredentials(username, password);
                client.getState().setCredentials(null, hostname, creds);
            }

            client.executeMethod(new HeadMethod());
        }
View Full Code Here

          mDestination.getName(), "Password");
      HttpState state = client.getState();
      state.setCredentials(
          new AuthScope(client.getHostConfiguration().getHost(),
              client.getHostConfiguration().getPort(), realm),
          new UsernamePasswordCredentials(user, password));
      HttpClientParams params = new HttpClientParams();
      params.setAuthenticationPreemptive(config.getValueAsBooleanOptional(
          Constants.CHAPTER_SYSTEM, mDestination.getName(),
          "AuthenticationPreemptive"));
      client.setParams(params);
View Full Code Here

      logger.debug("Setting username '{}' and password for server at {}.", username, serverURL);
      try {
        URL server = new URL(serverURL);
        authScope = new AuthScope(server.getHost(), AuthScope.ANY_PORT);
        httpClient.getState().setCredentials(authScope,
            new UsernamePasswordCredentials(username, password));
        httpClient.getParams().setAuthenticationPreemptive(true);
      }
      catch (MalformedURLException e) {
        logger.warn("Unable to set username and password for malformed URL {}", serverURL);
      }
View Full Code Here

    String password = NetPropertiesHandler.password;
    if (NetPropertiesHandler.proxyOn
        && (userName != null && userName.length() > 0)
        && (password != null && password.length() > 0)) {
      hClient.getState().setProxyCredentials(AuthScope.ANY,
          new UsernamePasswordCredentials(userName, password));
    }
    return hConf;
  }
View Full Code Here

    String proxyPassword = proxySettings.getHttpProxyPassword();

    client.getHostConfiguration().setProxy(proxyHost, proxyPort);
    if (proxyUsername != null && !"".equals(proxyUsername))
    {
      Credentials credentials = new UsernamePasswordCredentials(proxyUsername, proxyPassword);
      client.getState().setProxyCredentials(AuthScope.ANY, credentials);
    }
  }
View Full Code Here

        if (creds.getDomain() != null)
          client.getState().setProxyCredentials(proxyAuthScope, new NTCredentials(user, pw, creds.getHost(), creds.getDomain()));

        /* Use normal Credentials if Domain is not set */
        else
          client.getState().setProxyCredentials(proxyAuthScope, new UsernamePasswordCredentials(user, pw));
      }
    }
  }
View Full Code Here

        if (creds.getDomain() != null)
          client.getState().setProxyCredentials(proxyAuthScope, new NTCredentials(user, pw, creds.getHost(), creds.getDomain()));

        /* Use normal Credentials if Domain is not set */
        else
          client.getState().setProxyCredentials(proxyAuthScope, new UsernamePasswordCredentials(user, pw));
      }
    }
  }
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

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.