Package org.apache.commons.httpclient.auth

Examples of org.apache.commons.httpclient.auth.AuthScope


                        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();
                if (schemes != null && schemes.size() > 0) {
View Full Code Here


          mDestination.getName(), "Realm");
      String password = config.getValueOptional(Constants.CHAPTER_SYSTEM,
          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(),
View Full Code Here

  public void setUsernameAndPassword(String username, String password) {
    if (username != null && password != null) {
      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) {
View Full Code Here

            hc = hClient.getHostConfiguration();
            hc = setProxySetttings(hClient, hc);

            hClient.getState()
                .setCredentials(
                    new AuthScope(AuthScope.ANY_HOST,
                        AuthScope.ANY_PORT,
                        AuthScope.ANY_REALM),
                    getCredentials(feed));

            gMethod = new GetMethod(url.toString());
View Full Code Here

          } else {
            if (status == HttpStatus.SC_UNAUTHORIZED) {
              hc = hClient.getHostConfiguration();
              hc = setProxySetttings(hClient, hc);
              hClient.getState().setCredentials(
                  new AuthScope(AuthScope.ANY_HOST,
                      AuthScope.ANY_PORT,
                      AuthScope.ANY_REALM),
                  getCredentials(pFeed));
              gMethod = new GetMethod(url.toString());
              gMethod.setDoAuthentication(true);
View Full Code Here

            // Retry with password.
            hc = hClient.getHostConfiguration();
            try {

              hClient.getState().setCredentials(
                  new AuthScope(AuthScope.ANY_HOST,
                      AuthScope.ANY_PORT,
                      AuthScope.ANY_REALM),
                  getCredentials(feed)

              );
View Full Code Here

            // Retry with password.
            hc = hClient.getHostConfiguration();
            hc = setProxySetttings(hClient, hc);
            hClient.getState()
                .setCredentials(
                    new AuthScope(AuthScope.ANY_HOST,
                        AuthScope.ANY_PORT,
                        AuthScope.ANY_REALM),
                    getCredentials(pDownload
                        .getAttachment().getNews()
                        .getFeedReference().resolve()));
View Full Code Here

      /* Authenticate if required */
      if (creds.getUsername() != null || creds.getPassword() != null) {
        String user = StringUtils.isSet(creds.getUsername()) ? creds.getUsername() : ""; //$NON-NLS-1$
        String pw = StringUtils.isSet(creds.getPassword()) ? creds.getPassword() : ""; //$NON-NLS-1$

        AuthScope proxyAuthScope = new AuthScope(creds.getHost(), creds.getPort());

        /* Use NTLM Credentials if Domain is set */
        if (creds.getDomain() != null)
          client.getState().setProxyCredentials(proxyAuthScope, new NTCredentials(user, pw, creds.getHost(), creds.getDomain()));

View Full Code Here

      /* Authenticate if required */
      if (creds.getUsername() != null || creds.getPassword() != null) {
        String user = StringUtils.isSet(creds.getUsername()) ? creds.getUsername() : "";
        String pw = StringUtils.isSet(creds.getPassword()) ? creds.getPassword() : "";

        AuthScope proxyAuthScope = new AuthScope(creds.getHost(), creds.getPort());

        /* Use NTLM Credentials if Domain is set */
        if (creds.getDomain() != null)
          client.getState().setProxyCredentials(proxyAuthScope, new NTCredentials(user, pw, creds.getHost(), creds.getDomain()));

View Full Code Here

    params.setSoTimeout(10000);
    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

TOP

Related Classes of org.apache.commons.httpclient.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.