Search code examples
javasecuritykerberosntlmgssapi

Configure kerberos without krb5.conf


I'm using kerberos authentication to login to ActiveDirectory. I'm doing it with GSSAPI.

Currently, I'm using krb5.conf file, that describes the realms, encryption algs and more, and the authentication works fine.

I would like avoid using this file. Can I programmatically configure kerberos, without using this file?

Thanks.


Solution

  • You could try just configuring two system properties:

    java.security.krb5.kdc
    java.security.krb5.realm
    

    Note that you can't programmatically configure anything beyond this if you are using JDK's native support for Kerberos.

    If you are coding for Windows, I would warmly recommend using WAFFLE to achieve seamless Single Sign-On. It doesn't have a GSS-API adapter, though. I wrote my own, but only because the rest of the system already relied on it. You could just as easily skip GSS-API and program directly against WAFFLE.