공부
[Java] HBase secure
승가비
2020. 7. 13. 23:52
728x90
private Configuration getConf() {
Configuration conf = new Configuration(true);
conf = HBaseConfiguration.create(conf);
conf.set("hbase.zookeeper.quorum", zkQuorm);
conf.set("hbase.zookeeper.property.clientPort", zkPort);
if (StringUtils.isNotBlank(zkBasePath)) {
conf.set("zookeeper.znode.parent", zkBasePath);
}
conf.setInt("hbase.rpc.timeout", Integer.parseInt(rpcTimeout));
conf.set("hbase.client.scanner.timeout.period", "1500");
conf.set("hbase.cells.scanned.per.heartbeat.check", "10000");
conf.set("zookeeper.session.timeout", "10000");
conf.setInt("hbase.client.pause", 1000);
conf.setInt("hbase.client.retries.number", Integer.parseInt(retriesNumber));
return secure(conf);
}
private Configuration secure(Configuration conf) {
if(!CommonUtils.Y.equals(isSecure)) {
return conf;
}
File krb5 = FileUtils.streamToFile(getClass().getClassLoader().getResourceAsStream("krb5.conf"));
File jaas = FileUtils.streamToFile(getClass().getClassLoader().getResourceAsStream("jaas.conf"));
System.setProperty("zookeeper.sasl.client", "false");
System.setProperty("java.security.krb5.conf", krb5.getPath());
System.setProperty("java.security.auth.login.config", jaas.getPath());
conf.set("hadoop.security.authentication", "Kerberos");
conf.set("hbase.security.authentication", "Kerberos");
conf.set("hbase.master.kerberos.principal", "hbase/_HOST@HBASE.ITSC.COM");
conf.set("hbase.regionserver.kerberos.principal", "hbase/_HOST@HBASE.ITSC.COM");
FileUtils.checkFile(krb5.getPath());
FileUtils.checkFile(jaas.getPath());
UserGroupInformation.setConfiguration(conf);
try {
File file = FileUtils.streamToFile(getClass().getClassLoader().getResourceAsStream(keytab));
UserGroupInformation.loginUserFromKeytab(principal, file.getPath());
ConnectionFactory.createConnection(conf);
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
}
return conf;
}
https://stackoverflow.com/questions/23561736/java-client-for-secure-hbase
Java Client For Secure Hbase
Hi I am trying to write a java client for secure hbase. I want to do kinit also from code itself for that i`m using the usergroup information class. Can anyone point out where am I going wrong her...
stackoverflow.com
728x90