Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase >> mail # user >> Java Client : Secure Hbase

Copy link to this message
Re: Java Client : Secure Hbase
Hey Gaurav,

You need to have keytab and principal. Additionally, the configuration
files of cluster should be present in classpath of your app.

Please find below the sample code to create a configuration object for a
secure cluster:

   * @param keytab location of the keytab file
   * @param principal Kerberos principal
   * @return Configuration that can be used to create HConnection or HTable
for a secure HBase cluster.
  public static Configuration getHBaseConfiguration(String keytab, String
principal) {
    // create the type of object we will return from this function

    Configuration conf = HBaseConfiguration.create();

    // security
    conf.set("hbase.myclient.keytab", keytab);
    conf.set("hbase.myclient.principal", principal);
    try {
      User.login(conf, "hbase.myclient.keytab", "hbase.myclient.principal",
    } catch (IOException e) {
      // TODO Auto-generated catch block
    return conf;
On Thu, May 8, 2014 at 3:06 AM, Gaurav Thakur <[EMAIL PROTECTED]> wrote:

Thanks & Regards,
Anil Gupta