title: Java client call to Windows Integated Authentication web service
body: <p>I am writing a Java 1.5+ client that needs to fetch data from an IIS-hosted web service.  I created a new web service client in Eclipse and used the Java Proxy client type and Apache Axis2 web service runtime when generating the client proxy.  The web service itself runs on Windows 2003 and security is set to use only Windows Integrated Authentication.  I have found many articles online that show how to connect successfully from a Java client to this IIS service, but everything I have seen seems to require that I put the username and password in my Java client code somewhere.</p>
  
  <p>My Java client will run on a Windows machine that is on the same Active Directory network that the IIS service is on (i.e. the account I log in with each day can access the service).  I want my Java client to run in the context of the logged-in user without me needing to put in my login credentials in the code.  Here is my current code, which works, yet requires me to put a user name and password in the code:</p>
  
  <pre><code>final NTCredentials nt = new NTCredentials("my_username", "my_password", "", "my_domain");
          final CredentialsProvider myCredentialsProvider = new CredentialsProvider() {
              public Credentials getCredentials(final AuthScheme scheme, final String host, int port, boolean proxy) throws CredentialsNotAvailableException {
                  return nt; 
              }
          };
  
          DefaultHttpParams.getDefaultParams().setParameter("http.authentication.credential-provider", myCredentialsProvider);
  </code></pre>
  
  <p>But I really don't want to have to put the username and password in the code--I want it to run using the credentials of the logged-in Windows user that is running the Java client.</p>
  
  <p>What code should I use so it will connect with the logged-in user's credentials without needing to specify the user name and password?  Is this possible?</p>