1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.authorization;
17
18 import org.kuali.rice.core.api.util.RiceKeyConstants;
19 import org.kuali.rice.kim.api.permission.PermissionService;
20 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
21 import org.kuali.rice.krad.util.GlobalVariables;
22 import org.kuali.rice.krad.util.KRADConstants;
23 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
24 import org.kuali.rice.krms.impl.repository.ContextBoService;
25 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30 public class AgendaAuthorizationServiceImpl implements AgendaAuthorizationService {
31
32 static final String NAMESPACE_CODE = "namespaceCode";
33
34 @Override
35 public boolean isAuthorized(String permissionName, String contextId) {
36 String namespace = "";
37 if (contextId != null) {
38 ContextDefinition context = getContextBoService().getContextByContextId(contextId);
39 if (context != null) {
40 namespace = context.getNamespace();
41 }
42 }
43
44 Map<String, String> qualification = new HashMap<String, String>();
45 boolean isAuthorized = getPermissionService().isAuthorized(
46 GlobalVariables.getUserSession().getPrincipalId(),
47 namespace,
48 permissionName,
49 qualification);
50 return isAuthorized;
51 }
52
53
54
55
56 private ContextBoService getContextBoService() {
57 return KrmsRepositoryServiceLocator.getContextBoService();
58 }
59
60
61
62
63 private PermissionService getPermissionService() {
64 return KimApiServiceLocator.getPermissionService();
65 }
66 }