Java/Spring Boot - JHipster

Add dependency for DataDome Java Module

When using Maven, update your pom.xml file with the following content:

<project>
...
    <dependencies>
    ...
        <dependency>
          <groupId>co.datadome.module</groupId>
         <artifactId>datadome-java-module</artifactId>
          <version>1.18.0</version>
        </dependency>
    ...
    </dependencies>
...
</project>

Register the DataDomeFilter

Add a FilterRegistrationBean in your java web configuration file. It has to be registered with the highest priority order.
For JHipster, you may use WebConfigurer.java.

public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer<WebServerFactory> {
    
        /* section to copy */
    @Bean
    public FilterRegistrationBean<DataDomeFilter> dataDomeFilter() {
        FilterRegistrationBean<DataDomeFilter> filterRegistrationBean = new FilterRegistrationBean<>();

        filterRegistrationBean.setFilter(new DataDomeFilter());

        filterRegistrationBean.setName("datadome-filter");

        filterRegistrationBean.addUrlPatterns("/*");

        Map<String, String> iniParameters = Stream.of(new String[][]{
            {"datadome.apikey", "YOUR_SECRET_LICENSE_KEY"},
            {"datadome.hostname", "YOUR_CLOSEST_API_DATADOME_SERVER"},
        }).collect(Collectors.toMap(data -> data[0], data -> data[1]));
        filterRegistrationBean.setInitParameters(iniParameters);

        filterRegistrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return filterRegistrationBean;
    }
        /* end of section*/
}

List of possible init parameters to add in the iniParameters map:

SettingsDescriptionDefault
datadome.apikeyLicense key to access API
datadome.hostnameAPI server's hostname
Available endpoints
api.datadome.co
datadome.sslUse SSL between the filter and the API servertrue
datadome.regexInclusion Regex""
datadome.exclusion_regexExclusion Regex\.(js|css|jpg|jpeg|png|ico|gif|tiff|svg|woff|woff2|ttf|eot|mp4|otf)$
datadome.connection_timeoutConnection timeout (in ms)150
datadome.read_timeoutRead timeout (in ms)50
datadome.max_connectionsMaximum open connections to the API server100
datadome.proxy_serverHost that will be used as proxy server
See here
datadome.proxy_portTCP port at the proxy server
See here
datadome.proxy_sslIs the connection to the proxy established through TLS
See here
false
datadome.skip_ipsIPv4 or IPv6 subnetwork list on which DataDome validation is not executed, e.g.: "2a03:2880:1000::/36,124.66.0.0/17"

FAQ

Can the DataDome API be called via outbound proxy?

The DataDome module can be used with outbound proxy. Two options are available for the proxy configuration:

  • Use system settings such as -Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=1.2.3.4 -Dhttps.proxyPort=8443 when running your java application

  • Use optional DataDome init parameters datadome.proxy_server, datadome.proxy_port, datadome.proxy_ssl in web.xml

Note: Using the DataDome module with outbound proxy can slow down total time spent calling the DataDome API and increase timeouts. Please adjust timeout settings accordingly.