【问题标题】:Java SSO with using waffle in Tomcat在 Tomcat 中使用 waffle 的 Java SSO
【发布时间】:2014-09-29 09:01:21
【问题描述】:

我正在使用以下代码来获取实际登录用户:

    IWindowsSecurityContext clientContext = WindowsSecurityContextImpl.getCurrent("Negotiate", "localhost");
    WindowsAuthProviderImpl provider = new WindowsAuthProviderImpl();
    IWindowsSecurityContext serverContext = null;

    do {
        if (serverContext != null) {
            byte[] tokenForTheClientOnTheServer = serverContext.getToken();
            SecBufferDesc continueToken = new SecBufferDesc(Sspi.SECBUFFER_TOKEN, tokenForTheClientOnTheServer);
            clientContext.initialize(clientContext.getHandle(), continueToken, "localhost");
        }
        byte[] tokenForTheServerOnTheClient = clientContext.getToken();
        serverContext = provider.acceptSecurityToken("server-connection", tokenForTheServerOnTheClient, "Negotiate");

        System.out.println("SSO-Identity: " + serverContext.getIdentity().getFqn());

    } while (clientContext.getContinue());

    System.out.println("Identity: " + serverContext.getIdentity().getFqn());

当我在 Eclipse 中启动它并返回我的用户名时它工作正常。

当我部署我的 Web 应用程序并在 Tomcat 中启动它时,它会返回 nt-authority\system。但我需要实际登录用户的名称。 (在 Tomcat 中使用 Waffle SSO 可以正常工作,但我无法获取用户名)

请问,有人有什么想法吗?

编辑:eclipse 中的用户主体也是正确的。当我在 Tomcat 中启动时,它始终为空。

【问题讨论】:

    标签: java tomcat single-sign-on waffle


    【解决方案1】:

    它会为您获取在服务器上运行 Tomcat 服务的用户 ID。如果您需要来自客户端的用户 ID,您应该使用 request.getUserPrincipal().getName());

    【讨论】:

      【解决方案2】:

      如果您尝试在 tomcat 中使用 waffle 身份验证,则应该使用过滤器而不是独立代码。 您的代码现在适用于某些独立应用程序,例如 Swing/win 表单等。 但是在 HTTP 上,应该使用过滤器来完成。看看Using Spring security + tomcat

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-04
        • 2022-01-04
        相关资源
        最近更新 更多