Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.NTCredentials


      try
      {
        if( authscheme instanceof NTLMScheme )
        {
          logger.info( host + ":" + port + " requires Windows authentication" );
          return new NTCredentials( username, password, host, domain );
        }
        else if( authscheme instanceof RFC2617Scheme )
        {
          logger.info( host + ":" + port + " requires authentication with the realm '" + authscheme.getRealm()
              + "'" );
View Full Code Here


   
      if (!param.getProxyChainUserName().equals("")) {
         
//          NTCredentials credentials = new NTCredentials(
//                  param.getProxyChainUserName(), param.getProxyChainPassword(), param.getProxyChainName(), param.getProxyChainName());
          NTCredentials credentials = new NTCredentials(
                  param.getProxyChainUserName(), param.getProxyChainPassword(), "",  param.getProxyChainRealm().equals("") ? "" : param.getProxyChainRealm());
//      Below is the original code, but user reported that above code works.
//          UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(
//                  param.getProxyChainUserName(), param.getProxyChainPassword());
          AuthScope authScope = new AuthScope(param.getProxyChainName(), param.getProxyChainPort(), param.getProxyChainRealm().equals("") ? AuthScope.ANY_REALM : param.getProxyChainRealm());
View Full Code Here

    private void addAuth(HttpClient client) {
        List list = param.getListAuth();
        for (int i=0; i<list.size(); i++) {
            HostAuthentication auth = (HostAuthentication) list.get(i);
            AuthScope authScope = null;
            NTCredentials credentials= null;
            try {
                authScope = new AuthScope(auth.getHostName(), auth.getPort(), (auth.getRealm() == null || auth.getRealm().equals("")) ? AuthScope.ANY_REALM : auth.getRealm());
                credentials = new NTCredentials(auth.getUserName(), auth.getPassword(), InetAddress.getLocalHost().getCanonicalHostName(), auth.getHostName());
                client.getState().setCredentials(authScope, credentials);
            } catch (UnknownHostException e1) {
                e1.printStackTrace();
            }
            //client.getState().setCredentials(
View Full Code Here

    HostConfiguration hostConf = client.getHostConfiguration();
    if (PROXY) {
      hostConf.setProxy(PROXY_HOST, PROXY_PORT);
    }
    if (NTLM_USERNAME.length() > 0) {
      Credentials ntCreds = new NTCredentials(NTLM_USERNAME, NTLM_PASSWORD, NTLM_HOST, NTLM_DOMAIN);
      client.getState().setCredentials(new AuthScope(NTLM_HOST, AuthScope.ANY_PORT), ntCreds);

      LOG.info("Added NTLM credentials for " + NTLM_USERNAME);
    }
    LOG.info("Configured Client");
View Full Code Here

                int domainIndex = this.getProxyUser().indexOf("\\");
                if (domainIndex > 0) {
                    String domain = this.getProxyUser().substring(0, domainIndex);
                    if (this.getProxyUser().length() > domainIndex + 1) {
                        String user = this.getProxyUser().substring(domainIndex + 1);
                        proxyCred = new NTCredentials(user,
                                                      this.getProxyPassword(),
                                                      this.getProxyHost(),
                                                      domain);
                    }
                }
            }
        }

        // Overide the property setting in runtime.
        HttpTransportProperties.ProxyProperties proxyProperties =
                (HttpTransportProperties.ProxyProperties) messageContext
                        .getProperty(HTTPConstants.PROXY);

        if (proxyProperties != null) {
            String host = proxyProperties.getProxyHostName();
            if (host == null || host.length() == 0) {
                throw new AxisFault(ProxyConfiguration.class.getName() +
                                    " Proxy host is not available. Host is a MUST parameter");

            } else {
                this.setProxyHost(host);
            }


            this.setProxyPort(proxyProperties.getProxyPort());

            //Setting credentials

            String userName = proxyProperties.getUserName();
            String password = proxyProperties.getPassWord();
            String domain = proxyProperties.getDomain();

            if (userName == null && password == null) {
                proxyCred = new UsernamePasswordCredentials("", "");
            } else {
                proxyCred = new UsernamePasswordCredentials(userName, password);
            }

            if (userName != null && password != null && domain != null) {
                proxyCred = new NTCredentials(userName, password, host, domain);
            }

        }

        //Using Java Networking Properties
View Full Code Here

            // These items don't change, so only need to be done once
            if (useProxy) {
                if (PROXY_USER.length() > 0){
                    httpClient.getState().setProxyCredentials(
                        new AuthScope(PROXY_HOST,PROXY_PORT,null,AuthScope.ANY_SCHEME),
                        new NTCredentials(PROXY_USER,PROXY_PASS,localHost,PROXY_DOMAIN)
                    );
                }
            }

    }
View Full Code Here

          client.getState().setCredentials(
                            new AuthScope(u.getHost(),u.getPort(),
                                realm.length()==0 ? null : realm //"" is not the same as no realm
                                ,AuthScope.ANY_SCHEME),
                            // NT Includes other types of Credentials
                            new NTCredentials(
                  username,
                                    auth.getPass(),
                                    localHost,
                  domain
              ));
View Full Code Here

                        .setAuthenticationPreemptive(authenticator.getPreemptiveAuthentication());

                if (host != null) {
                    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);
View Full Code Here

        if (useDynamicProxy){
            String user = getProxyUser();
            if (user.length() > 0){
                httpClient.getState().setProxyCredentials(
                        new AuthScope(proxyHost,proxyPort,null,AuthScope.ANY_SCHEME),
                        new NTCredentials(user,getProxyPass(),localHost,PROXY_DOMAIN)
                    );
            } else {
                httpClient.getState().clearProxyCredentials();
            }
        } else {
            if (useStaticProxy) {
                if (PROXY_USER.length() > 0){
                    httpClient.getState().setProxyCredentials(
                        new AuthScope(PROXY_HOST,PROXY_PORT,null,AuthScope.ANY_SCHEME),
                        new NTCredentials(PROXY_USER,PROXY_PASS,localHost,PROXY_DOMAIN)
                    );
                }
            } else {
                httpClient.getState().clearProxyCredentials();
            }
View Full Code Here

                    state.setCredentials(
                            new AuthScope(u.getHost(),u.getPort(),
                                    realm.length()==0 ? null : realm //"" is not the same as no realm
                                    ,AuthScope.ANY_SCHEME),
                            // NT Includes other types of Credentials
                            new NTCredentials(
                                    username,
                                    auth.getPass(),
                                    localHost,
                                    domain
                            ));
View Full Code Here

TOP

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

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.