1
2
3
4
5 package gboat2.web.service.impl;
6
7 import gboat2.base.core.service.ModuleService;
8 import gboat2.base.core.validate.IOperaPrivilegeCheckService;
9 import gboat2.base.bridge.model.Resource;
10 import gboat2.base.bridge.model.UserSession;
11 import gboat2.base.bridge.GboatAppContext;
12
13 import java.util.List;
14 import java.util.Map;
15
16 import org.osgi.framework.Bundle;
17
18
19
20
21
22
23
24 public class SessionPrivilegeCheckServiceImpl implements IOperaPrivilegeCheckService {
25
26 @Override
27 public boolean privilegeCheckServiceByMethodName(Map<?, ?> params, Bundle bd) {
28 UserSession session = GboatAppContext.getUserSession();
29 if(session==null){
30
31 return false;
32 }else if ("super".equals(session.getLoginId())){
33
34 return true;
35 }
36
37 String actionName = (String) params.get("ACTION_NAME");
38 String methodName = (String) params.get("METHOD_NAME");
39
40
41 List<String> operationCodes = ModuleService.getOperationCodesOf(actionName, methodName);
42 if (null == operationCodes || operationCodes.isEmpty())
43 return true;
44
45 for (String operationCode : operationCodes) {
46 if (session.havePriority(new Resource(actionName, operationCode)))
47 return true;
48 }
49 return false;
50 }
51
52 @Override
53 public boolean privilegeCheckServiceByMethodCode(Map<?, ?> params, Bundle bd) {
54 UserSession session = GboatAppContext.getUserSession();
55
56 if ("super".equals(session.getLoginId()))
57 return true;
58
59 String actionName = (String) params.get("ACTION_NAME");
60 String methodCode = (String) params.get("METHOD_CODE");
61
62 return session.havePriority(new Resource(actionName, methodCode));
63 }
64
65 }