[java-identity-provider COMMIT] in /trunk: idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java i...

noreply at shibboleth.net noreply at shibboleth.net
Wed Dec 10 12:06:48 EST 2014


Author: scantor
Date: Wed Dec 10 12:06:47 2014
New Revision: 7061

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7061&view=rev
Log:
IDP-409 - put initial MDC population and cleanup in place

Modified:
    trunk/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java
    trunk/idp-war/src/main/webapp/WEB-INF/web.xml

Modified: trunk/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java?rev=7061&r1=7060&r2=7061&view=diff
==============================================================================
--- trunk/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java (original)
+++ trunk/idp-core/src/main/java/net/shibboleth/idp/log/SLF4JMDCServletFilter.java Wed Dec 10 12:06:47 2014
@@ -19,14 +19,18 @@
 
 import java.io.IOException;
 
+import javax.annotation.Nonnull;
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
 
 import net.shibboleth.idp.Version;
+import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
 
 import org.slf4j.MDC;
 
@@ -36,27 +40,41 @@
  * is returned.
  */
 public class SLF4JMDCServletFilter implements Filter {
+    
+    /** MDC attribute name for client address. */
+    @Nonnull @NotEmpty public static final String CLIENT_ADDRESS_MDC_ATTRIBUTE = "idp.remote_addr";
+
+    /** MDC attribute name for container session ID. */
+    @Nonnull @NotEmpty public static final String JSESSIONID_MDC_ATTRIBUTE = "idp.jsessionid";
 
     /** {@inheritDoc} */
+    @Override
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
             ServletException {
         try {
             MDC.put(Version.MDC_ATTRIBUTE, Version.getVersion());
-            // TODO populate the MDC will other interesting things
+            MDC.put(CLIENT_ADDRESS_MDC_ATTRIBUTE, request.getRemoteAddr());
+            if (request instanceof HttpServletRequest) {
+                final HttpSession session = ((HttpServletRequest) request).getSession();
+                if (session != null) {
+                    MDC.put(JSESSIONID_MDC_ATTRIBUTE, session.getId());
+                }
+            }
             
             chain.doFilter(request, response);
         } finally {
             MDC.clear();
         }
-
     }
 
     /** {@inheritDoc} */
+    @Override
     public void init(FilterConfig filterConfig) throws ServletException {
         // nothing to do
     }
 
     /** {@inheritDoc} */
+    @Override
     public void destroy() {
         // nothing to do
     }

Modified: trunk/idp-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-war/src/main/webapp/WEB-INF/web.xml?rev=7061&r1=7060&r2=7061&view=diff
==============================================================================
--- trunk/idp-war/src/main/webapp/WEB-INF/web.xml (original)
+++ trunk/idp-war/src/main/webapp/WEB-INF/web.xml Wed Dec 10 12:06:47 2014
@@ -27,6 +27,7 @@
     </listener>
     
     <!-- Filters and filter mappings -->
+    <!-- Try and force I18N, probably won't help much. -->
     <filter>
         <filter-name>CharacterEncodingFilter</filter-name>
         <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
@@ -39,10 +40,12 @@
             <param-value>true</param-value>
         </init-param>
     </filter>
+    <!-- Lets us lump repeated Set-Cookie headers into one, something containers rarely support. -->
     <filter>
         <filter-name>CookieBufferingFilter</filter-name>
         <filter-class>net.shibboleth.utilities.java.support.net.CookieBufferingFilter</filter-class>
     </filter>
+    <!-- Automates the unpack and pack of the cookie-based storage model. -->
     <filter>
         <filter-name>ClientSessionStorageServiceFilter</filter-name>
         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@@ -51,6 +54,7 @@
             <param-value>shibboleth.ClientSessionStorageService</param-value>
         </init-param>
     </filter>
+    <!-- Automates the unpack and pack of the cookie-based storage model. -->
     <filter>
         <filter-name>ClientPersistentStorageServiceFilter</filter-name>
         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@@ -59,9 +63,15 @@
             <param-value>shibboleth.ClientPersistentStorageService</param-value>
         </init-param>
     </filter>
+    <!-- Automates TLS-based propagation of HttpServletRequest/Response into beans. -->
     <filter>
         <filter-name>RequestResponseContextFilter</filter-name>
         <filter-class>net.shibboleth.utilities.java.support.net.RequestResponseContextFilter</filter-class>

[... 24 lines stripped ...]


More information about the commits mailing list