如何从 Swing 应用程序获取 Windows 登录凭据?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1413184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get windows logon credentials from a Swing application?
提问by Ken Liu
How would I go about getting the Windows user credentials from a Swing application?
我将如何从 Swing 应用程序获取 Windows 用户凭据?
I am working on an internal (corporate) Swing application. Currently the user has to login to the application using a login screen, which then connects to an app server which authenticates the user against the company LDAP server.
我正在开发一个内部(公司)Swing 应用程序。目前,用户必须使用登录屏幕登录应用程序,然后连接到应用服务器,该服务器根据公司 LDAP 服务器对用户进行身份验证。
Since the user has already logged in to his workstation using the same credentials, is there any way that a Swing application can get these credentials from Windows itself and then automatically log the user in (SSO)? I know this is possible because I have seen some other applications do it, but I don't know how to go about doing this with Swing/Java.
由于用户已经使用相同的凭据登录到他的工作站,有什么方法可以让 Swing 应用程序从 Windows 本身获取这些凭据,然后让用户自动登录 (SSO)?我知道这是可能的,因为我已经看到其他一些应用程序这样做了,但我不知道如何使用 Swing/Java 来做到这一点。
采纳答案by Pascal Thivent
There are similar questions on SO that look like interesting (so this question might be a duplicate):
SO上有类似的问题看起来很有趣(所以这个问题可能是重复的):
- How do I access Windows credentials from Java?
- Java Active Directory Integrated Windows Authentication
IMHO, read carefully Kohsuke's blog posts (hereand here) and the Single-Sign-On in Java Platform using Active Directoryarticle, they contain very valuable informations.
恕我直言,仔细阅读 Kohsuke 的博客文章(这里和这里)和使用 Active Directory 的 Java 平台单点登录文章,它们包含非常有价值的信息。
But you need to dig the whole thing a bit further.
但是你需要更深入地挖掘整个事情。