how to add a filter if there is no web.xml in AEM (cloud version)
We understand AEM is not a J2EE container, but it does have filters.
We are trying to integrate datadome, which is a bot protection system to prevent hacking.
This is what needs to be added to the equivalent of web.xml:
<web-app>
...
<filter>
<filter-name>datadome-filter</filter-name>
<filter-class>co.datadome.api.servlet.DataDomeFilter</filter-class>
<init-param>
<param-name>datadome.apikey</param-name>
<param-value>YOUR_SECRET_LICENSE_KEY</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>datadome-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
...
</web-app>
any idea how one might do this with AEM Cloud?
Maybe, we can write a filter as a proxy to the required filter?
Im thinking something like this, but its a complete guess:
@SlingServletFilter(scope = {SlingServletFilterScope.REQUEST},
pattern = "/.*",
methods = {"GET","POST"})
@Slf4j
@ServiceRanking(100)
public class DDFilter implements Filter{
co.datadome.api.servlet.DataDomeFilter ddfilter;
public void destroy() {
ddfilter.destroy()
}
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain)
throws IOException, ServletException {
ddfilter.dofilter (requ, resp, chain);
}
public void init(FilterConfig config) throws ServletException {
ddfilter = new co.datadome.api.servlet.DataDomeFilter();
ddfilter.init(??);
}
}