[jboss-cvs] jboss-seam/src/main/org/jboss/seam/web ...
Gavin King
gavin.king at jboss.com
Fri Jul 6 16:35:51 EDT 2007
User: gavin
Date: 07/07/06 16:35:51
Modified: src/main/org/jboss/seam/web CharacterEncodingFilter.java
Added: src/main/org/jboss/seam/web LoggingFilter.java
Log:
JBSEAM-1610
Revision Changes Path
1.8 +1 -0 jboss-seam/src/main/org/jboss/seam/web/CharacterEncodingFilter.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: CharacterEncodingFilter.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/web/CharacterEncodingFilter.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- CharacterEncodingFilter.java 25 Jun 2007 22:56:50 -0000 1.7
+++ CharacterEncodingFilter.java 6 Jul 2007 20:35:51 -0000 1.8
@@ -63,4 +63,5 @@
{
this.overrideClient = overrideClient;
}
+
}
\ No newline at end of file
1.1 date: 2007/07/06 20:35:51; author: gavin; state: Exp;jboss-seam/src/main/org/jboss/seam/web/LoggingFilter.java
Index: LoggingFilter.java
===================================================================
package org.jboss.seam.web;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.MDC;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.intercept.BypassInterceptors;
import org.jboss.seam.annotations.web.Filter;
import org.jboss.seam.security.Identity;
/**
* This filter adds the authenticated user name to the log4j
* mapped diagnostic context so that it can be included in
* formatted log output if desired, by adding %X{username}
* to the pattern.
*
* @author Eric Trautman
*/
@Startup
@Scope(ScopeType.APPLICATION)
@Name("org.jboss.seam.web.loggingFilter")
@BypassInterceptors
@Filter(within="org.jboss.seam.web.authenticationFilter")
@Install(classDependencies="org.apache.log4j.Logger",
dependencies="org.jboss.seam.security.identity",
precedence=Install.BUILT_IN)
public class LoggingFilter extends AbstractFilter
{
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException
{
HttpSession session = ((HttpServletRequest) servletRequest).getSession(false);
if (session!=null)
{
Object attribute = session.getAttribute("org.jboss.seam.security.identity");
if (attribute instanceof Identity)
{
Identity identity = (Identity) attribute;
String username = identity.getUsername();
if (username != null)
{
MDC.put("username", username);
}
}
}
filterChain.doFilter(servletRequest, servletResponse);
MDC.remove("username");
}
}
More information about the jboss-cvs-commits
mailing list