-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathAcceptorAuthenticationMain.java
More file actions
25 lines (20 loc) · 953 Bytes
/
Copy pathAcceptorAuthenticationMain.java
File metadata and controls
25 lines (20 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package cz.cacek.kerberos.jaas;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginContext;
/**
* Acceptor authentication which uses Krb5LoginModule in non-interactive mode. Keytab and principal options are defined in jaas.conf.
* <p>
* KDC doesn't need to be available/reachable for the acceptor's authentication.
*/
public class AcceptorAuthenticationMain {
public static void main(String[] args) throws Exception {
System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("java.security.auth.login.config", "jaas.conf");
System.setProperty("java.security.krb5.conf", "krb5.conf");
LoginContext lc = new LoginContext("KerberosAcceptorWithKeytab");
lc.login();
Subject subj = lc.getSubject();
System.out.println("Principals: " + subj.getPrincipals());
System.out.println("PrivateCredentials: " + subj.getPrivateCredentials());
}
}