aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java41
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java2
-rw-r--r--pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java1
3 files changed, 40 insertions, 4 deletions
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
index 4713e84f..7b126a40 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/filter/ExceptionCatchFilter.java
@@ -33,7 +33,9 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.slf4j.MDC;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,11 +65,16 @@ public class ExceptionCatchFilter implements Filter {
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
- //try {
+ try {
if(request instanceof HttpServletRequest) {
+
logger.debug("Processing Parameters into Attributes");
HttpServletRequest httpRequest = (HttpServletRequest)request;
+ MDC.put("SESSION_ID", httpRequest.getSession().getId());
+
+ logger.warn("Access from IP {}", getClientIpAddr(httpRequest));
+
PdfAsHelper.logAccess(httpRequest);
@SuppressWarnings("unchecked")
Enumeration<String> parameterNames = httpRequest.getParameterNames();
@@ -75,12 +82,20 @@ public class ExceptionCatchFilter implements Filter {
String name = parameterNames.nextElement();
String value = httpRequest.getParameter(name);
request.setAttribute(name, value);
- logger.debug("Setting attribute: " + name + " - " + value);
}
}
-
+ try {
chain.doFilter(request, response);
+ } finally {
+ if(request instanceof HttpServletResponse) {
+ HttpServletResponse resp = (HttpServletResponse)response;
+ logger.debug("Got response status: {}", resp.getStatus());
+ }
+ }
+ } finally {
+ MDC.remove("SESSION_ID");
+ }
/*} catch(Throwable e) {
System.err.println("Unhandled Exception found!");
e.printStackTrace(System.err);
@@ -88,6 +103,26 @@ public class ExceptionCatchFilter implements Filter {
}*/
}
+ public static String getClientIpAddr(HttpServletRequest request) {
+ String ip = request.getHeader("X-Forwarded-For");
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("WL-Proxy-Client-IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_CLIENT_IP");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+ }
+ if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+ ip = request.getRemoteAddr();
+ }
+ return ip;
+ }
+
/**
* @see Filter#init(FilterConfig)
*/
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
index b2559b25..c4db2e4f 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/helper/PdfAsHelper.java
@@ -857,7 +857,7 @@ public class PdfAsHelper {
public static void logAccess(HttpServletRequest request) {
HttpSession session = request.getSession();
- logger.debug("Access to " + request.getServletPath() + " in Session: "
+ logger.info("Access to " + request.getServletPath() + " in Session: "
+ session.getId());
}
diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
index 13c37171..45861953 100644
--- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
+++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java
@@ -104,6 +104,7 @@ public class DataURLServlet extends HttpServlet {
throw new PdfAsSecurityLayerException(errorResponseType.getInfo(),
errorResponseType.getErrorCode());
} else {
+ logger.error("Unknown SL response {}", xmlResponse);
throw new PdfAsSecurityLayerException("Unknown SL response",
9999);
}