KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > webapp > filter > AuthenticationFilter


1 package org.jbpm.webapp.filter;
2
3 import java.io.IOException JavaDoc;
4
5 import javax.servlet.Filter JavaDoc;
6 import javax.servlet.FilterChain JavaDoc;
7 import javax.servlet.FilterConfig JavaDoc;
8 import javax.servlet.ServletException JavaDoc;
9 import javax.servlet.ServletRequest JavaDoc;
10 import javax.servlet.ServletResponse JavaDoc;
11 import javax.servlet.http.HttpServletRequest JavaDoc;
12
13 import org.jbpm.security.Authentication;
14 import org.jbpm.webapp.bean.UserBean;
15
16 public class AuthenticationFilter implements Filter JavaDoc {
17
18   public void doFilter(ServletRequest JavaDoc servletRequest, ServletResponse JavaDoc servletResponse, FilterChain JavaDoc filterChain) throws IOException JavaDoc, ServletException JavaDoc {
19     HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) servletRequest;
20     UserBean userBean = (UserBean) request.getSession().getAttribute("userBean");
21     String JavaDoc actorId = (userBean!=null ? userBean.getUserName() : null);
22     
23     Authentication.pushAuthenticatedActorId(actorId);
24     try {
25       filterChain.doFilter(servletRequest, servletResponse);
26     } finally {
27       Authentication.popAuthenticatedActorId();
28     }
29   }
30
31   public void init(FilterConfig JavaDoc filterConfig) throws ServletException JavaDoc {
32   }
33
34   public void destroy() {
35   }
36   
37   // private static final Log log = LogFactory.getLog(LogFilter.class);
38
}
39
Popular Tags