使用鬆餅我使用下面的代碼獲取實際登錄用戶:的Java SSO與Tomcat的
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中啓動時,它始終爲空。