提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.bpm.framework.web.core; |
H |
2 |
|
|
3 |
import com.iailab.framework.security.core.util.SecurityFrameworkUtils; |
|
4 |
import com.iailab.module.bpm.framework.flowable.core.util.FlowableUtils; |
|
5 |
import org.springframework.web.filter.OncePerRequestFilter; |
|
6 |
|
|
7 |
import javax.servlet.FilterChain; |
|
8 |
import javax.servlet.ServletException; |
|
9 |
import javax.servlet.http.HttpServletRequest; |
|
10 |
import javax.servlet.http.HttpServletResponse; |
|
11 |
import java.io.IOException; |
|
12 |
|
|
13 |
/** |
|
14 |
* Flowable Web 过滤器,将 userId 设置到 {@link org.flowable.common.engine.impl.identity.Authentication} 中 |
|
15 |
* |
|
16 |
* @author jason |
|
17 |
*/ |
|
18 |
public class FlowableWebFilter extends OncePerRequestFilter { |
|
19 |
|
|
20 |
@Override |
|
21 |
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) |
|
22 |
throws ServletException, IOException { |
|
23 |
try { |
|
24 |
// 设置工作流的用户 |
|
25 |
Long userId = SecurityFrameworkUtils.getLoginUserId(); |
|
26 |
if (userId != null) { |
|
27 |
FlowableUtils.setAuthenticatedUserId(userId); |
|
28 |
} |
|
29 |
// 过滤 |
|
30 |
chain.doFilter(request, response); |
|
31 |
} finally { |
|
32 |
// 清理 |
|
33 |
FlowableUtils.clearAuthenticatedUserId(); |
|
34 |
} |
|
35 |
} |
|
36 |
} |