This is the documentation for CDH 5.1.x. Documentation for other versions is available at Cloudera Documentation.

Appendix K - Authenticating Kerberos Principals in Java Code

This topic provides an example of how to authenticate a Kerberos principal in a Java application using the org.apache.hadoop.security.UserGroupInformation class.

The following code snippet authenticates the cloudera principal using the cloudera.keytab file:
// Authenticating Kerberos principal
System.out.println("Principal Authentication: ");
final String user = "cloudera@CLOUDERA.COM";
final String keyPath = "cloudera.keytab";
UserGroupInformation.loginUserFromKeytab(user, keyPath);
Page generated September 3, 2015.