If your service does not support one of the standard authentication methods provided by the driver, you can define a custom authentication requests using the input REST file.
Before you start: Define your custom authentication requests in the input REST file. For details, see "Custom authentication requests."
To configure the driver to use custom authentication requests:
Set the Config property to provide the name and location of the input REST file. For example, C:/path/to/myrest.rest.
Set the AuthenticationMethod property to Custom. Note that Custom is the default when a custom authentication request is defined in the input REST file.
Set the CustomAuthParams property to specify the list of parameters to be used by the authentication requests defined in the input REST file. Note that these values must be specified in the order that corresponds to the index location cited by the variable in the REST file. For example, the following customAuthParams variable points to the second (2) index:
"company": "{customAuthParams[2]}"
To successfully authenticate, the second value specified should be the value for the company field:
CustomAuthParams=123XYZ456abc789;My Company Inc;www.example.com
If applicable, set the ServerName property to set the host name portion of the HTTP endpoint to which you send requests.
If required by your service, set the User property to specify your logon ID.
If required by your service, set the Password property to specify your password.
Optionally, specify values for any additional properties you want to configure.
The following examples demonstrate sessions using a REST file with custom authentication enabled:
For a connection URL:
Connection conn = DriverManager.getConnection
("jdbc:datadirect:autorest:Config=C:/path/to/myrest.rest;CustomAuthParams=123XYZ456abc789;
My Company Inc;path/to/endpoint;ServerName=https://example.com;User=jsmith;
Password=secret");
For a data source:
AutoRESTDataSource mds = new AutoRESTDataSource();
mds.setDescription("My Autonomous REST Data Source");
mds.setConfig("C:/path/to/myrest.rest");
mds.setCustomAuthParams("123XYZ456abc789;My Company Inc;path/to/endpoint");
mds.setServerName("https://example.com");
mds.setUser("jsmith");
mds.setPassword("secret");