使用 SSPI 从 Windows 上运行的 Java 应用程序获取 SSO

发布于 2024-09-16 19:37:22 字数 497 浏览 1 评论 0 原文

我有一个在 Windows 上运行的 Java 应用程序,需要使用 Kerberos/SPNEGO 对 Web 应用程序进行身份验证。我知道如何配置 JAAS 来实现此目的,但我发现 Java(JDK6 和 JDK7beta)Kerberos 实现缺少一些我需要的重要功能。例如,支持引用或使用 DNS 来确定主机的领域(我有一个多领域环境)。

是否有第三方模块可以使用Windows本机Waffle 及其 WindowsLoginModule,但它似乎没有执行 SSO,因为它要求用户将他们的凭据重新输入到应用程序中。

I have a Java application running on Windows that needs to authenticate to a webapp using Kerberos/SPNEGO. I'm aware of how to configure JAAS to achieve this, but I find the Java (JDK6 and JDK7beta) Kerberos implementation to be lacking a couple important features I need. For example, support for referrals or using the DNS to figure out the realm of a host (I have a multi-realm environment).

Is there a third-party module that can implement authentication using the Windows native SSPI? We've already gone through the trouble of configuring our Windows clients to work within our environment, it'd be nice to not have to do it again for Java. I'm aware of Waffle and its WindowsLoginModule, but it doesn't seem to do SSO as it requires users to re-enter their credentials into the application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彼岸花似海 2024-09-23 19:37:22

我们也遇到过类似的问题。我们面临的主要问题是使用 Windows UAC 时 GSS-API 实现失败,我们使用 Waffle 解决了这个问题。

Waffle 基本上是 JNA 对 SSPI 调用的包装器。我们通过覆盖类 sun.net.www.protocol.http.NegotiatorImpl 成功地使用 Waffle 实现了 SSO:

package sun.net.www.protocol.http;

import java.io.IOException;
import waffle.windows.auth.impl.WindowsSecurityContextImpl;

public class NegotiatorImpl extends Negotiator {

private String serviceName;

public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
    this.serviceName = "HTTP/" + hci.host.toLowerCase();
}

    @Override
    public byte[] firstToken() throws IOException {
        return WindowsSecurityContextImpl.getCurrent("Negotiate", serviceName).getToken();
    }

    @Override
    public byte[] nextToken(byte[] in) throws IOException {
        return new byte[0];
    }
}

然后您可以创建一个仅包含此类的 JAR,并将其与 Waffle 一起复制& JNA JAR 到 JVM 的 ./jre/lib/endorsed。使用 JVM 的 Java 认可的标准覆盖机制,这替换 JVM 的默认 Negotiator 实现。

We've had a similar issue. The main problem for us was that the GSS-API implementation fails when using Windows UAC and we solved it using Waffle.

Waffle is basically a wrapper for the JNA calls to SSPI. We've managed to implement SSO using Waffle by overriding the class sun.net.www.protocol.http.NegotiatorImpl:

package sun.net.www.protocol.http;

import java.io.IOException;
import waffle.windows.auth.impl.WindowsSecurityContextImpl;

public class NegotiatorImpl extends Negotiator {

private String serviceName;

public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
    this.serviceName = "HTTP/" + hci.host.toLowerCase();
}

    @Override
    public byte[] firstToken() throws IOException {
        return WindowsSecurityContextImpl.getCurrent("Negotiate", serviceName).getToken();
    }

    @Override
    public byte[] nextToken(byte[] in) throws IOException {
        return new byte[0];
    }
}

Then you can create a JAR with holding only this class and copy it along with the Waffle & JNA JARs to ./jre/lib/endorsed of your JVM. Using the Java Endorsed Standards Override Mechanism of the JVM, this replaces the default Negotiator implementation of the JVM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文