[Dive4elements-commits] [PATCH 3 of 3] merged
Wald Commits
scm-commit at wald.intevation.org
Fri Nov 16 12:01:46 CET 2012
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1353063698 -3600
# Node ID ea40a5ded13476ac2ccea6aa10c4a5faa24eb3a1
# Parent 2fadc6c5cdad163716bf77d3443bf7bd794c4d3f
# Parent 9a24324853715e200ed4bc8e685bb7f18bafc5a8
merged
diff -r 2fadc6c5cdad -r ea40a5ded134 flys-client/src/main/java/de/intevation/flys/client/server/filter/GGInAFilter.java
--- a/flys-client/src/main/java/de/intevation/flys/client/server/filter/GGInAFilter.java Fri Nov 16 12:01:11 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/filter/GGInAFilter.java Fri Nov 16 12:01:38 2012 +0100
@@ -7,6 +7,8 @@
import de.intevation.flys.client.server.features.Features;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.Enumeration;
import javax.servlet.Filter;
@@ -34,11 +36,9 @@
private String redirecturl;
private ServletContext sc;
- public static final String LOGIN_JSP = "/login.jsp";
- public static final String LOGIN_SERVLET = "/flys/login";
- public static final String FLYS_CSS = "/FLYS.css";
- public static final String MAP_PRINT = "/flys/map-print";
- public static final String MAPFISH_PRINT = "/flys/mapfish-print/print.pdf";
+ private static final String LOGIN_JSP = "/login.jsp";
+ private static final String LOGIN_SERVLET = "/flys/login";
+ private static final String FLYS_CSS = "/FLYS.css";
/**
@@ -87,14 +87,18 @@
logger.debug("Request for: " + requesturi);
+ // Allow acces to localhost
+ if (isLocalAddress(req)) {
+ logger.debug("Request to localhost");
+ chain.doFilter(req, resp);
+ return;
+ }
+
// Allow access to login pages
- // TODO Maybe replace with Filter <url-pattern>
String path = this.sc.getContextPath();
if (requesturi.equals(path + LOGIN_JSP)
|| requesturi.equals(path + LOGIN_SERVLET)
- || requesturi.equals(path + FLYS_CSS)
- || requesturi.equals(path + MAP_PRINT)
- || requesturi.equals(path + MAPFISH_PRINT)) {
+ || requesturi.equals(path + FLYS_CSS)) {
logger.debug("Request for login " + requesturi);
chain.doFilter(req, resp);
return;
@@ -178,5 +182,21 @@
return AuthenticationFactory.getInstance(this.authmethod).auth(
user.getName(), user.getPassword(), encoding, features);
}
+
+ /**
+ * Returns true if the request is from our machine
+ * @param req The ServletRequest
+ * @return true if the request is from a loopback interface or from one of
+ * the interface addresses of the machine
+ */
+ private boolean isLocalAddress(ServletRequest req) {
+ try {
+ InetAddress addr = InetAddress.getByName(req.getRemoteAddr());
+ return addr.isAnyLocalAddress() || addr.isLoopbackAddress();
+ } catch (UnknownHostException e) {
+ logger.error(e, e);
+ return false;
+ }
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
More information about the Dive4elements-commits
mailing list