2

JAVA を使用して Active Directory から認証用の TGT を取得しようとしています。

これは私のコードです:

try
{
    URL localURL = super.getClass().getResource("jaas_ntlm_configuration.txt");
    System.setProperty("java.security.auth.login.config", localURL.toString());

    LoginContext localLoginContext = new LoginContext("GetLoginNameKerberos", new SampleCallbackHandler());

    localLoginContext.login();

    Subject localSubject = localLoginContext.getSubject();

    .....
}
catch (LoginException localLoginException) {
    localLoginException.printStackTrace();
}

このコードは 1 つのサーバーでは機能しますが、別のサーバーでは "localLoginContext.login();" で失敗します。この出力で:

>>>KinitOptions cache name is C:\Users\x\krb5cc_x
LSA: Found Ticket
LSA: Made NewWeakGlobalRef
LSA: Found PrincipalName
LSA: Made NewWeakGlobalRef
LSA: Found DerValue
LSA: Made NewWeakGlobalRef
LSA: Found EncryptionKey
LSA: Made NewWeakGlobalRef
LSA: Found TicketFlags
LSA: Made NewWeakGlobalRef
LSA: Found KerberosTime
LSA: Made NewWeakGlobalRef
LSA: Found String
LSA: Made NewWeakGlobalRef
LSA: Found DerValue constructor
LSA: Found Ticket constructor
LSA: Found PrincipalName constructor
LSA: Found EncryptionKey constructor
LSA: Found TicketFlags constructor
LSA: Found KerberosTime constructor
LSA: Finished OnLoad processing
>> Acquire default native Credentials
LSA: Found KrbCreds constructor
LSA: Got handle to Kerberos package
LSA: Response size is 1556
LSA: Principal domain is SUB.DOMAIN.COM
LSA: Name type is 1
LSA: Name count is 1
LSA: Principal domain is SUB.DOMAIN.COM
LSA: Name type is 2
LSA: Name count is 2
LSA: Session key all zero. Stop.
>>> Found no TGT's in LSA
javax.security.auth.login.LoginException: Unable to obtain Princpal Name for authentication
    at com.sun.security.auth.module.Krb5LoginModule.promptForName(Unknown Source)
    at com.sun.security.auth.module.Krb5LoginModule.attemptAuthentication(Unknown Source)
    at com.sun.security.auth.module.Krb5LoginModule.login(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at javax.security.auth.login.LoginContext.invoke(Unknown Source)
    at javax.security.auth.login.LoginContext.access$000(Unknown Source)
    at javax.security.auth.login.LoginContext$4.run(Unknown Source)
    at javax.security.auth.login.LoginContext$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.login.LoginContext.invokePriv(Unknown Source)
    at javax.security.auth.login.LoginContext.login(Unknown Source)
    at my.test.MyTest.main(MyTest.java:123)

何が問題なのかを理解するのを手伝ってもらえますか?

ありがとう。

4

1 に答える 1

6

ユーザー名を入力する必要がないと思っていた場合 (シングル サインオンを期待している場合)、問題は既知の問題です。セキュリティの抜け穴と見なされるため、LSA API は TGT のセッション キーを引き渡しません。エラーメッセージは、これがまさに起こったことであることを明確に示しています。

この制限を無効にするために true に設定できるWindows レジストリ キーがAllowTGTSessionKeyありますが、この設定はサーバーごとではなくワークステーションごとであるため、これが特定の場所で機能する理由であるかどうかは明確ではありません。もう一方の。私の記憶が正しければ、これは XP Service Pack 2 で導入されたため、使用されている Windows のバージョンが別の理由である可能性があります。

Java でシングル サインオンを実現する適切な方法は、TGT の処理を​​ GSS-API に似た高レベル API である Windows SSPI に委任することです。これを行う優れたライブラリがあり、個人的にお勧めします: WAFFLE.

于 2012-11-29T18:28:37.147 に答える