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.KrmsConstants;
22 import org.kuali.rice.krms.api.repository.context.ContextDefinition;
23 import org.kuali.rice.krms.impl.repository.ContextBoService;
24 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
25
26 import java.util.HashMap;
27 import java.util.Map;
28
29 public class AgendaAuthorizationServiceImpl implements AgendaAuthorizationService {
30
31 static final String NAMESPACE_CODE = "namespaceCode";
32
33 @Override
34 public boolean isAuthorized(String permissionName, String contextId) {
35 ContextDefinition context = getContextBoService().getContextByContextId(contextId);
36
37 Map qualification = new HashMap<String, String>();
38 if (contextId != null) {
39 qualification.put(NAMESPACE_CODE, context.getNamespace());
40 }
41 boolean isAuthorized = getPermissionService().isAuthorized(
42 GlobalVariables.getUserSession().getPrincipalId(),
43 KrmsConstants.KRMS_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 }