wujian
2024-03-22 0ce25f34a0d627a5cc0d073d24b8c3e569feac15
提交 | 用户 | 时间
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 }