提交 | 用户 | 时间
|
fd2207
|
1 |
package com.jcdm.framework.security.context; |
懒 |
2 |
|
|
3 |
import org.springframework.security.core.Authentication; |
|
4 |
|
|
5 |
/** |
|
6 |
* 身份验证信息 |
|
7 |
* |
|
8 |
* @author jc |
|
9 |
*/ |
|
10 |
public class AuthenticationContextHolder |
|
11 |
{ |
|
12 |
private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>(); |
|
13 |
|
|
14 |
public static Authentication getContext() |
|
15 |
{ |
|
16 |
return contextHolder.get(); |
|
17 |
} |
|
18 |
|
|
19 |
public static void setContext(Authentication context) |
|
20 |
{ |
|
21 |
contextHolder.set(context); |
|
22 |
} |
|
23 |
|
|
24 |
public static void clearContext() |
|
25 |
{ |
|
26 |
contextHolder.remove(); |
|
27 |
} |
|
28 |
} |