Hi!
Thanks for your answer. I used the example to get a webpage protected with single sign-on (MS Outlook web access) and it works.
Now I'm trying to access to an Apache server protected with Kerberos / Negotiate.
My problem is that it seems to use my Windows XP ticket even if I put a "Authenticator.setDefault(new MyAuthenticator());" line and that MyAuthenticator returns the right username/password for the Apache server. I tried also to use Authenticator.requestPasswordAuthentication()... but then I don't know what to do with the PasswordAuthentification object returned.
My login.conf looks like :
com.sun.security.jgss.krb5.initiate {
com.sun.security.auth.module.Krb5LoginModule required
useTicketCache=false
doNotPrompt=false
principal="MY_REALM"
debug=true;
};
How can I force Java to get the username/password from authenticator ?
Any other idea about my problem ?
Thanks,
Laurent
Your Apache server is in another Kerberos 5 realm other than the Windows Active Directory, right? You may need to specify the realm name and kdc of that realm with system properties. JRE should be able to retrieve tickets for that realm, and since you already specify useTicketCache=false and doNotPrompt=false, the username and password should be prompted for.
Also, you shouldn't specify "principal" in the JAAS login config file.
You are right. The apache realm is different.
But I forgot to mention that I also put a krb5.conf file for Java :
[libdefaults]
default_realm = MY_REALM
dns_lookup_realm = false
dns_lookup_kdc = false
[domain_realm]
the-apache-server = MY_REALM
[realms]
MY_REALM = {
admin_server = the-apache-server
kdc = the-apache-server
}
Maybe something is wrong here ?
Note that my apache-server is also the Kerberos server (admin + kdc).
I also tried to set properties :
java -Djava.security.krb5.realm=MY_REALM -Djava.security.krb5.kdc=the-apache-server....
Nothing is working. Java is always using my Windows principal.
Is it possible that Java use a cache and that I should force it to reload or something like that ?
Yes, Java always uses the cached ticket (without looking at other config. If you think this is wrong, just file a bug.).
So, there are 2 ways you can do:
1. Specify useTicketCache=false, then you need to always provide username/password in your application.
2. Run kinit first (with -J-Djava.security.krb5.realm=.... ...kdc=...) to retrieve a ticket from the realm of your Apache server. Java will try this file-based ticket before the native one.
My suggestion is that you use kinit to get a ticket and move it to another place, then, if you want to use the Windows Active Directory, this ticket won't be used. If you want to use the other Kerberos realm (where Apache lies), you can add "ticketCache=c:\my\cache\ticket" to your JAAS config file. Both with useTicketCache=true to achieve single sign-on.
Hope this helps.
Ooops!!! Sorry! That's so stupid...
My system properties were not set correctly!!!
So I was always using the krb5.ini configuration file from Windows!
Now it works better even if I can not connect to my KDC server (SocketTimeOutException)...
I will go on my investigation !