大佬教程收集整理的这篇文章主要介绍了是否可以在Windows上禁用Java的“单点登录”(使用“凭据管理器”中的凭据)?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在寻找与您要求相同的内容。到目前为止,我还没有在JDK上找到实现此目的的方法。
要求对Java BUG数据库进行增强。查看该报告以了解是否得到了Sun的答复(对报告进行投票,以期尽快解决该问题)。
我最终要做的是覆盖sun.net.www.protocol.http.NTLMAuthentication
类。通过查看sun.net.www.protocol.http.httpURLAuthentication
,我发现您唯一需要修改的就是以下结果:
NTLMAuthentication.supportstransparentAuth()
true
在windows平台和false
其他平台上,该方法具有硬编码的返回值。此代码是从windows 7上安装的JDK中提取的:
static Boolean supportstransparentAuth()
{
return true;
}
该方法说明的是默认情况下是否应使用windows凭据。如果设置为true
,
。参见以下httpURLConnection
课程片段:
//Declared as a member variable of httpURLConnection
private Boolean trytransparentNTLMServer = NTLMAuthentication.supportstransparentAuth();
//InsIDe of getServerAuthentication method.
passwordAuthentication a = null;
if (!trytransparentNTLMServer) {
//If set to false, this will call Authenticator.requestpasswordAuthentication().
a = privilegedrequestpasswordAuthentication(url.getHost(), addr, port, url.getProtocol(), "", scheR_82_11845@e, url, requestorType.SERVER);
}
/* If we are not trying transparent authentication then
* we need to have a passwordAuthentication instance. For
* transparent authentication (windows only) the username
* and password will be picked up from the current logged
* on users credentials.
*/
if (trytransparentNTLMServer || (!trytransparentNTLMServer && a != null)) {
//If set to true or if Authenticator dID not return any credentials, use windows credentials.
//NTLMAuthentication constructor, if receives a == null will fetch current looged user credentials.
ret = new NTLMAuthentication(false, url1, a);
}
为了获得NTLMAuthentication
源代码,我使用了此Java反编译器。打开位于JDK安装文件夹中的rt.jar,并复制所需的类代码。
然后,我只是更改supportstransparentAuth
为返回false。但是,非常希望此方法首先检查系统属性,然后根据该属性返回true或false。
要编译它,我只是将java文件放在sun / net / www / protocol / http文件夹结构下并运行:
javac NTLMAuthentication.java
然后使用以下命令运行我的应用程序:
java -Xbootclasspath:"path/to/your/sun/net/www/protocol/http/classes;normal/JDK/boot/directorIEs"
这将告诉JVMNTLMAuthentication
在rt.jar中加载我们的实现。您必须注意不要错过带有的任何默认类加载路径-Xbootclasspath
,否则会ClassnotFound
出错。
之后,一切正常。
这种方法具有您应注意的重要缺点。
因此,这绝对不适合生产环境。
最后,这是有关引导类路径选项和java类加载器的绝佳资源:PDF
希望这可以帮助。
Java SE 6文档中Oracle的“ http
Authentication”页面说:“如果您以域用户身份在Windows计算机上运行,或者,如果您已经在Linux或Solaris计算机上运行了该kinit
命令并获得了凭据缓存,
”,那么传递给Authenticator.setDefault()
“将被完全忽略”
的实例。
这与我观察到的情况相符:在Windows系统上为主机X设置http或httpS连接始终从“ Windows保险柜”的“
Windows凭据”传递主机X的凭据,如我的Windows 7“凭据管理器”中所示控制面板页面。
@H_674_99@但是 ,在我的用例中,我不想使用Windows可能存储的任何凭据,而我总是想使用我在代码中明确指定的凭据。
有没有办法重写记录的行为,即有没有办法忽略Windows存储的凭据?
@H_674_99@更新: 否则,有人可以指出我在Java SE 6源代码中的某个位置,在那里我可以看到所存储的Windows凭据不能被忽略吗?
以上是大佬教程为你收集整理的是否可以在Windows上禁用Java的“单点登录”(使用“凭据管理器”中的凭据)?全部内容,希望文章能够帮你解决是否可以在Windows上禁用Java的“单点登录”(使用“凭据管理器”中的凭据)?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。