Implementing Custom Authenticators¶
Required Libraries to Develop Custom Authenticators¶
To develop a custom authenticator, add the following jar file to the CLASSPATH of your environment:
<DENODO_HOME>/lib/contrib/denodo-commons-custom.jar
If the custom authenticator relies on third-party libraries, you have to do one of the following steps:
Import the third-party jar files in to Virtual DataPort and when importing the new custom authenticator with Design Studio, select the jar with the custom authenticator and the external jars.
Or copy the contents of the required jars into the jar that contains the custom authenticator. You have to copy the contents of the required jars, not the jars themselves.
Custom Authenticator JAR Creation
Run the Maven command mvn package in the project’s root directory. This will compile your project, run the tests, and create the JAR file in the project’s target folder. The name of the JAR file will be based on the name and version of the Maven project.
Once you have developed a custom authenticator and imported it into Virtual DataPort, read the article How to debug Denodo custom extensions with Eclipse of the Denodo Knowledge Base to learn how to debug it.
Simple JDBC Implementation¶
This example demonstrates how to establish a basic JDBC connection to a Virtual DataPort server from a Java client. The code showcases how to configure specific connection properties beyond the standard user and password, which is essential when using a custom authenticator or passing additional data.
The example sets up a connection using a JDBC URL, and it defines a Properties object to include key-value pairs. This is the recommended way to pass information like an accessToken for OAuth2 authentication and a customParameters JSON string.
// Define the JDBC URL to connect to the Virtual DataPort server
String jdbcUrl = "jdbc:vdb://localhost:9999/admin";
// Create a Properties object to hold connection parameters
Properties connectionProps = new Properties();
// Set authentication properties for OAuth2
connectionProps.put("useOAuth2", "true");
connectionProps.put("accessToken", "dummyToken");
// Include custom parameters as a JSON string
connectionProps.put("customParameters", "{\"my_custom_param\":\"value\"}");
// Establish the connection to the server
Connection connection = DriverManager.getConnection(jdbcUrl, connectionProps);
// Create a Statement object to execute a query
Statement statement = connection.createStatement();
// Execute a query and retrieve the results
Statement resultSet = statement.executeQuery("<query>");
// Remember to close the connection and statement in a 'finally' block
// or with a try-with-resources statement to avoid resource leaks
