Skip to content

Instantly share code, notes, and snippets.

@nmreadelf
Created October 25, 2018 07:15
Show Gist options
  • Save nmreadelf/c012c942f4b6f2f25bd82dbc2676159c to your computer and use it in GitHub Desktop.
Save nmreadelf/c012c942f4b6f2f25bd82dbc2676159c to your computer and use it in GitHub Desktop.
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Paths;
import java.security.PrivilegedExceptionAction;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.security.UserGroupInformation;
public class Authtest {
static UserGroupInformation ugi;
public static void main(String[] args) throws IOException {
Configuration conf = new Configuration();
String hadoop_conf_dir = System.getenv("HADOOP_CONF_DIR");
conf.addResource(new Path(Paths.get(hadoop_conf_dir, "core-site.xml").toString()));
conf.addResource(new Path(Paths.get(hadoop_conf_dir, "hdfs-site.xml").toString()));
System.setProperty("java.security.krb5.conf", Paths.get(hadoop_conf_dir, "krb5.conf").toString());
UserGroupInformation.setConfiguration(conf);
if (UserGroupInformation.isSecurityEnabled()) {
System.out.println("Kerberos is enabled");
} else {
System.out.println("Kerberos is not enabled");
}
}
}
[r
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment