aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-web/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-03-03 11:44:03 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-03-03 11:44:03 +0100
commit6f3e54bcb8c9728c037d921af310c8457507836d (patch)
tree6db83d192c2f374219c877462a2277e4faf9d06e /pdf-as-web/src/main/java/at/gv/egiz/pdfas
parentc5f6f204ce7b784640a33bb4de0416282750749c (diff)
downloadpdf-as-4-6f3e54bcb8c9728c037d921af310c8457507836d.tar.gz
pdf-as-4-6f3e54bcb8c9728c037d921af310c8457507836d.tar.bz2
pdf-as-4-6f3e54bcb8c9728c037d921af310c8457507836d.zip
logging changes
Diffstat (limited to 'pdf-as-web/src/main/java/at/gv/egiz/pdfas')
-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);
}