Solved! Go to Solution.
Views
Replies
Total Likes
Hi @anelem1760873!
Usually, you would include your filter into the filter chain and override the doFilter() method as @bilal_ahmad outlined in his code example.
Depending on your understanding of how to "block/abort" the request, you could do one of the following:
If your use case is really about blocking and/or dropping incoming requests (e. g. as a protective measure against DoS/DDoS, unwanted crawlers or other clients, etc.) my suggestion would be to stop them at an earlier stage. You could leverage some kind of web application firewall (WAF). Sometimes certain modules for Apache HTTPD do the job (mod_security [3], mod_qos [4] or for simple cases even mod_rewrite [5]).
[3] https://github.com/SpiderLabs/ModSecurity/wiki
[4] http://mod-qos.sourceforge.net/
[5] https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Hey @anelem1760873 you can write something this sort in the doFilter() method:
if (resource.getPath().startsWith("/content/pathToBlock/")) {
if (<right condition>)) {
<YOUR BUSINESS LOGIC>
} else {
slingResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
}
return;
}
Thanks,
Bilal.
Hi @anelem1760873!
Usually, you would include your filter into the filter chain and override the doFilter() method as @bilal_ahmad outlined in his code example.
Depending on your understanding of how to "block/abort" the request, you could do one of the following:
If your use case is really about blocking and/or dropping incoming requests (e. g. as a protective measure against DoS/DDoS, unwanted crawlers or other clients, etc.) my suggestion would be to stop them at an earlier stage. You could leverage some kind of web application firewall (WAF). Sometimes certain modules for Apache HTTPD do the job (mod_security [3], mod_qos [4] or for simple cases even mod_rewrite [5]).
[3] https://github.com/SpiderLabs/ModSecurity/wiki
[4] http://mod-qos.sourceforge.net/
[5] https://httpd.apache.org/docs/current/mod/mod_rewrite.html
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies