提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.framework.security.context; |
懒 |
2 |
|
|
3 |
import org.springframework.web.context.request.RequestAttributes; |
|
4 |
import org.springframework.web.context.request.RequestContextHolder; |
|
5 |
import com.jcdm.common.core.text.Convert; |
|
6 |
|
|
7 |
/** |
|
8 |
* 权限信息 |
|
9 |
* |
|
10 |
* @author jc |
|
11 |
*/ |
|
12 |
public class PermissionContextHolder |
|
13 |
{ |
|
14 |
private static final String PERMISSION_CONTEXT_ATTRIBUTES = "PERMISSION_CONTEXT"; |
|
15 |
|
|
16 |
public static void setContext(String permission) |
|
17 |
{ |
|
18 |
RequestContextHolder.currentRequestAttributes().setAttribute(PERMISSION_CONTEXT_ATTRIBUTES, permission, |
|
19 |
RequestAttributes.SCOPE_REQUEST); |
|
20 |
} |
|
21 |
|
|
22 |
public static String getContext() |
|
23 |
{ |
|
24 |
return Convert.toStr(RequestContextHolder.currentRequestAttributes().getAttribute(PERMISSION_CONTEXT_ATTRIBUTES, |
|
25 |
RequestAttributes.SCOPE_REQUEST)); |
|
26 |
} |
|
27 |
} |