我正在编写一个Java 1.5+客户端,该客户端需要从IIS托管的Web服务中获取数据.我在Eclipse中创建了一个新的Web服务客户端,并在生成客户端代理时使用了Java代理客户端类型和Apache Axis2 Web服务运行时.Web服务本身在Windows 2003上运行,并且安全性设置为仅使用Windows集成身份验证.我在线上找到了许多文章,展示了如何从Java客户端成功连接到该IIS服务,但是我所看到的一切似乎都要求我将用户名和密码放在Java客户端代码中.
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.
我的Java客户端将在与IIS服务位于同一Active Directory网络上的Windows计算机上运行(即,我每天登录的帐户都可以访问该服务).我希望我的Java客户端在登录用户的上下文中运行,而无需在代码中放入登录凭据.这是我当前的代码,可以正常工作,但是需要我在代码中输入用户名和密码:
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:
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);
但是我真的不想在代码中输入用户名和密码-我希望它使用运行Java客户端的已登录Windows用户的凭据运行.
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.
我应该使用什么代码,以便它无需登录用户名和密码即可与登录用户的凭据连接?这可能吗?
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?