Joaquín Reñé
2025-10-07 146a0fb8b0e90f9196e569152f649baf60d6cc8f
securis/src/main/java/net/curisit/securis/DevFilter.java
....@@ -1,3 +1,6 @@
1
+/*
2
+ * Copyright @ 2013 CurisTEC, S.A.S. All Rights Reserved.
3
+ */
14 package net.curisit.securis;
25
36 import java.io.IOException;
....@@ -16,6 +19,19 @@
1619 import org.apache.logging.log4j.LogManager;
1720 import org.apache.logging.log4j.Logger;
1821
22
+/**
23
+* DevFilter
24
+* <p>
25
+* Development-time CORS helper. Adds permissive CORS headers to allow front-end
26
+* resources (e.g. JS served from a different origin) to call the API.
27
+* Short-circuits <code>OPTIONS</code> preflight requests.
28
+*
29
+* <p><b>Security note:</b> This configuration is intentionally permissive and should be
30
+* restricted for production.
31
+*
32
+* @author JRA
33
+ * Last reviewed by JRA on Oct 5, 2025.
34
+*/
1935 @ApplicationScoped
2036 @WebFilter(urlPatterns = "/*")
2137 public class DevFilter implements Filter {
....@@ -23,10 +39,19 @@
2339 @SuppressWarnings("unused")
2440 private static final Logger log = LogManager.getLogger(DevFilter.class);
2541
42
+ /**
43
+ * init<p>
44
+ * Filter init hook (unused).
45
+ */
2646 @Override
2747 public void init(FilterConfig fc) throws ServletException {
2848 }
2949
50
+ /**
51
+ * doFilter
52
+ * <p>
53
+ * Add CORS headers and pass through non-OPTIONS methods to the next filter.
54
+ */
3055 @Override
3156 public void doFilter(ServletRequest sreq, ServletResponse sres, FilterChain fc) throws IOException, ServletException {
3257 HttpServletRequest req = (HttpServletRequest) sreq;
....@@ -44,6 +69,10 @@
4469 }
4570 }
4671
72
+ /**
73
+ * destroy<p>
74
+ * Filter destroy hook (unused).
75
+ */
4776 @Override
4877 public void destroy() {
4978 }