My application runs with Spring Framework and have to connected to Hive server with Kerberos Authentication along with HikariCP.
I looked into examples of Spring Security Kerberos but i could not relate it with Hikari CP. The following is the code for getting the connections with DriverManager. How do I use DataSource and HikariCP ?
private String getHadoopJDBCUrl() throws IOException {
System.setProperty("javax.security.auth.useSubjectCredsOnly", "false");
System.setProperty("java.security.krb5.conf", enviroment.getProperty(KERBEROS_CONFIG_FILE));
org.apache.hadoop.conf.Configuration configuration = new org.apache.hadoop.conf.Configuration();
configuration.set("hadoop.security.authentication", "kerberos");
configuration.set("hadoop.security.auth_to_local", connectionDetails.getSecurityAuth());
UserGroupInformation.setConfiguration(configuration);
if (!(connectionDetails.getKerberosUserName().equalsIgnoreCase(Utility.EMPTY_STRING)
|| connectionDetails.getKerberosPassword().equalsIgnoreCase(Utility.EMPTY_STRING))) {
UserGroupInformation.loginUserFromKeytab(connectionDetails.getKerberosUserName(),
connectionDetails.getKerberosPassword());
}
return String.join("", connectionDetails.getJdbcURL(), "/", aggregateDetails.getDatabaseName(), ";",
connectionDetails.getPrincipal());
}
public ConnectionDetails getConnectionDetails()
throws ParseException, ClassNotFoundException, SQLException, IOException {
String JDBCUrl = Utility.EMPTY_STRING;
Class.forName(connectionDetails.getDriver());
if (connectionDetails.getType().equalsIgnoreCase(ConnectionDetails.HADOOP_PERSISTENCE)) {
JDBCUrl = getHadoopJDBCUrl();
}
connectionDetails.setConnection(DriverManager.getConnection(JDBCUrl));
return connectionDetails;
}