i2 Connect gateway

    Show / Hide Table of Contents

    Custom HTTP headers

    Starting at version 4.3.3, i2 Analyze contains an extension point that enables you to send additional headers to connectors when requests are made through the i2 Connect gateway. You can use this feature to implement solutions that include providing API keys from a secrets manager, or supplying other centralized configuration parameters.

    The extension point requires you to write an implementation of the IConnectorRequestModifier interface. The implementation must be packaged into a JAR file and deployed to i2 Analyze. The following example demonstrates how to use Maven to do this and how to configure i2 Analyze to use your implementation.

    Note: The connector request modifier is invoked only for requests made to endpoints by individual users. It is not invoked for requests made to the connector config, schema, or charting scheme endpoints.

    Overview

    For i2 Analyze to use your implementation, complete the following tasks:

    1. Create and package your implementation of IConnectorRequestModifier
    2. Configure i2 Analyze to use your packaged implementation
    3. Redeploy and restart Liberty to update your deployment

    Prerequisites

    • Java installed

    The request modifier project

    Update the value of the <toolkitLocation> element in the request-modifier/pom.xml file to reference the installation location of i2 Analyze. For example:

    <toolkitLocation>C:\i2\i2analyze</toolkitLocation>
    

    This location is used by Maven to locate the JAR files to pull into the local Maven repository and where to place the packaged JAR file that contains your implementation.

    To set up the Maven environment, open a terminal in the request-modifier directory.

    1. Initialize the Maven dependencies

    mvnw initialize
    

    This pulls in JAR files from the i2 Analyze deployment toolkit into your local Maven repository.

    2. Compile and install the project

    mvnw clean install
    

    At this point, you could start editing the implementation in request-modifier/src/main/java/com/i2group/example/ExampleRequestModifier.java. For the example implementation, do not make any changes.

    Deploy the request modifier implementation

    When the implementation is complete, package the class into a JAR file.

    Open a terminal in the request-modifier directory and run the following command:

    mvnw package
    

    The Maven package command creates a JAR file from the ExampleRequestModifier.java class and puts it in the toolkit/configuration/fragments/opal-services/WEB-INF/lib/ directory of the i2 Analyze toolkit specified in the <toolkitLocation> element.

    Configure i2 Analyze

    For i2 Analyze to use the ExampleRequestModifier, it must be specified in the DiscoServerSettingsCommon.properties file.

    Add the following line to the end of the toolkit/configuration/fragments/opal-services/WEB-INF/classes/DiscoServerSettingsCommon.properties file:

    ConnectorRequestModifier=com.i2group.example.ExampleRequestModifier
    

    Redeploy and restart Liberty

    setup -t stopLiberty
    setup -t deployLiberty
    setup -t startLiberty
    

    Testing

    To test the implementation, execute a query through the External Searches UI in either Analyst's Notebook or the web client. When you do so:

    • All connectors receive an extra header named Example-Value-Header in requests made through the i2 Connect gateway. The value you see depends on the identifier of the connector, as defined in the i2 Connect Gateway.

    • Asynchronous query requests contain an additional header named Example-Async-State-Header. The value of the header is unchanged for the duration of each asynchronous query, but is unique to each query.

    For example:

    Host: localhost:9084,
    Connection: keep-alive,
    Content-Length: 92,
    User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.11)
    Content-Type: application/json
    Example-Async-State-Header: dc05164d-0e1c-4c88-be7c-7ebbcd079ff8
    Example-Value-Header: exampleConValue
    Accept-Encoding: gzip,deflate
    Accept-Language: en-gb
    
    Back to top © N. Harris Computer Corporation.