title: How to access secure kerberized hadoop using just java API
body: <p>I am pretty new to Kerberos. I am using a shared Hadoop cluster. My admin has provided me with a username and a password and the location of the KDC server.</p>
  
  <p>Is it possible to use just the JAVA GSS API and the Hadoop USerGroupInformation class to access the Hadoop cluster.</p>
  
  <p>For a non-kerberos hadoop cluster, this would be the code snippet I would use to, say read a file from HDFS :</p>
  
  <pre><code>String uname = &lt;Some username&gt;;
  UserGroupInformation ugi = UserGroupInformation.createRemoteUser(uname);
  ugi.doAs(new PrivilegedExceptionAction&lt;Void&gt;(){
  
     public Void run() throws Exception {
  
        HdfsConfiguration hdfsConf = new HdfsConfiguration();
        ... SETUP Configuration ...
        FileSystem fs = FileSystem.get(hdfsConf);
        ... Use 'fs' to read/write etc ...
     }
  
  });
  </code></pre>
  
  <p>Now for a secure cluster, I am also provided the kerberos password for the user..
  Could someone please provide me with what are the exact changes I need to make to the above code snippet to first access the KDC and do a kinit and then proceed with the HDFS operation</p>
  
  <p>Please remember, in the environment I am planning to deploy the Java app, I might not have 'kinit' installed locally, so invoking the kinit process from within java is not an option.</p>
  
  <p>Thanks in advance..</p>