Using Ranger client libraries

Ranger now supports clients written in java and python which enable applications to access Ranger REST APIs programmatically. Using client library code simplifies access using java or python, compared with making direct HTTP requests to Ranger REST APIs.

Summary

Ranger client libraries:

  • Provide idiomatic, hand-written code in Java and Python, making Ranger REST APIs simple and intuitive to use.
  • Handle all low-level details of communication with the server including complexities involved in JSON parsing.
  • Support installing the python client using the familiar package management tool pip.
Table 1. Ranger Client Installation Repo and Library Reference Links
Language Installation Library Reference
java github source repository java library reference
python github source repository python library reference

Authentication

The Apache Ranger release 2.2 client supports two authentication types:
  • Basic authentication (username/password)
  • Kerberos authentication

Java client prompts for the authentication mode to be used at runtime. For Kerberos-based authentications, a principal and keytab file path is required.

SSL

Java and Python clients support SSL/TLS-enabled ranger. To connect to HTTPS ranger using java client, provide the path to the SSL configuration file, as shown in this example:
$ ./run-sample-client.sh -n <ranger_admin_url>
SSL Configuration File: /path/to/config.xml
Sample SSL configuration file which requires values to be populated:
<configuration>
  <property>
    <name>xasecure.policymgr.clientssl.truststore</name>
    <value></value>
  </property>
  <property>
    <name>xasecure.policymgr.clientssl.truststore.credential.file</name>
    <value></value>
  </property>
  <property>
    <name>xasecure.policymgr.clientssl.truststore.type</name>
    <value></value>
  </property>
</configuration>

Environment variables

The Java client requires requires that you initialize the following environment variables:
$ export JAVA_HOME=/usr/java/<jdk_version>/bin
$ export PATH=$PATH:$JAVA_HOME
$ export HADOOP_CREDSTORE_PASSWORD=<hadoop_credstore_password>