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.kim.api.permission.PermissionService;
19 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
20 import org.kuali.rice.krad.util.GlobalVariables;
21 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
22 import org.kuali.rice.krms.impl.repository.ContextBoService;
23 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
24
25 import java.util.HashMap;
26 import java.util.Map;
27
28 public class AgendaAuthorizationServiceImpl implements AgendaAuthorizationService {
29
30 static final String NAMESPACE_CODE = "namespaceCode";
31
32 @Override
33 public boolean isAuthorized(String permissionName, String contextId) {
34 String namespace = "";
35 if (contextId != null) {
36 ContextDefinition context = getContextBoService().getContextByContextId(contextId);
37 namespace = context.getNamespace();
38 }
39
40 Map qualification = new HashMap<String, String>();
41 boolean isAuthorized = getPermissionService().isAuthorized(
42 GlobalVariables.getUserSession().getPrincipalId(),
43 namespace,
44 permissionName,
45 qualification,
46 new HashMap<String, String>());
47 return isAuthorized;
48 }
49
50
51
52
53 private ContextBoService getContextBoService() {
54 return KrmsRepositoryServiceLocator.getContextBoService();
55 }
56
57
58
59
60 private PermissionService getPermissionService() {
61 return KimApiServiceLocator.getPermissionService();
62 }
63 }