1 package org.jbpm.webapp.filter; 2 3 import java.io.IOException ; 4 5 import javax.servlet.Filter ; 6 import javax.servlet.FilterChain ; 7 import javax.servlet.FilterConfig ; 8 import javax.servlet.ServletException ; 9 import javax.servlet.ServletRequest ; 10 import javax.servlet.ServletResponse ; 11 import javax.servlet.http.HttpServletRequest ; 12 13 import org.jbpm.security.Authentication; 14 import org.jbpm.webapp.bean.UserBean; 15 16 public class AuthenticationFilter implements Filter { 17 18 public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException , ServletException { 19 HttpServletRequest request = (HttpServletRequest ) servletRequest; 20 UserBean userBean = (UserBean) request.getSession().getAttribute("userBean"); 21 String 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 filterConfig) throws ServletException { 32 } 33 34 public void destroy() { 35 } 36 37 } 39 | Popular Tags |