小编PaP*_*aNi的帖子

在Tomcat中使用华夫饼的Java SSO

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

    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());
Run Code Online (Sandbox Code Playgroud)

当我在Eclipse中启动它并返回我的用户名时,它运行良好。

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

拜托,有人知道吗?

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

java tomcat single-sign-on waffle

5
推荐指数
1
解决办法
1300
查看次数

标签 统计

java ×1

single-sign-on ×1

tomcat ×1

waffle ×1