4

私のアプリケーションは Spring Framework で実行され、HikariCP と共に Kerberos 認証を使用して Hive サーバーに接続する必要があります。

Spring Security Kerberos の例を調べましたが、光 CP と関連付けることができませんでした。以下は、DriverManager との接続を取得するためのコードです。DataSource と 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;
}
4

0 に答える 0