1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.bo.authorization;
17
18 import org.kuali.rice.kns.authorization.BusinessObjectAuthorizer;
19 import org.kuali.rice.krad.bo.BusinessObject;
20 import org.kuali.rice.krad.bo.DataObjectAuthorizerBase;
21 import org.kuali.rice.krad.service.DataDictionaryService;
22 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
23 import org.kuali.rice.krad.service.KualiModuleService;
24 import org.kuali.rice.krad.service.PersistenceStructureService;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30
31
32
33 @Deprecated
34 public class BusinessObjectAuthorizerBase extends DataObjectAuthorizerBase implements BusinessObjectAuthorizer {
35 private static final long serialVersionUID = -6315759348728853851L;
36
37 private static KualiModuleService kualiModuleService;
38 private static DataDictionaryService dataDictionaryService;
39 private static PersistenceStructureService persistenceStructureService;
40
41 protected final boolean permissionExistsByTemplate(
42 BusinessObject businessObject, String namespaceCode,
43 String permissionTemplateName) {
44 return getPermissionService()
45 .isPermissionDefinedByTemplate(namespaceCode, permissionTemplateName, new HashMap<String, String>(
46 getPermissionDetailValues(businessObject)));
47 }
48
49 protected final boolean permissionExistsByTemplate(
50 BusinessObject businessObject, String namespaceCode,
51 String permissionTemplateName, Map<String, String> permissionDetails) {
52 Map<String, String> combinedPermissionDetails = new HashMap<String, String>(
53 getPermissionDetailValues(businessObject));
54 combinedPermissionDetails.putAll(permissionDetails);
55 return getPermissionService()
56 .isPermissionDefinedByTemplate(namespaceCode, permissionTemplateName, combinedPermissionDetails);
57 }
58
59 public final boolean isAuthorized(BusinessObject businessObject,
60 String namespaceCode, String permissionName, String principalId) {
61 return getPermissionService().isAuthorized(principalId,
62 namespaceCode, permissionName,
63 new HashMap<String, String>(getRoleQualification(businessObject, principalId)));
64 }
65
66 public final boolean isAuthorizedByTemplate(BusinessObject dataObject,
67 String namespaceCode, String permissionTemplateName,
68 String principalId) {
69 return getPermissionService().isAuthorizedByTemplate(principalId, namespaceCode, permissionTemplateName,
70 new HashMap<String, String>(getPermissionDetailValues(dataObject)), new HashMap<String, String>(
71 getRoleQualification(dataObject, principalId)));
72 }
73
74 public final boolean isAuthorized(BusinessObject businessObject,
75 String namespaceCode, String permissionName, String principalId,
76 Map<String, String> collectionOrFieldLevelPermissionDetails,
77 Map<String, String> collectionOrFieldLevelRoleQualification) {
78 Map<String, String> roleQualifiers = null;
79 Map<String, String> permissionDetails = null;
80 if (collectionOrFieldLevelRoleQualification != null) {
81 roleQualifiers = new HashMap<String, String>(
82 getRoleQualification(businessObject, principalId));
83 roleQualifiers.putAll(collectionOrFieldLevelRoleQualification);
84 } else {
85 roleQualifiers = new HashMap<String, String>(
86 getRoleQualification(businessObject, principalId));
87 }
88
89
90
91
92
93
94
95
96
97 return getPermissionService().isAuthorized(principalId,
98 namespaceCode, permissionName,
99 roleQualifiers);
100 }
101
102
103
104
105
106
107
108
109
110
111
112 protected final Map<String, String> getRoleQualification(
113 BusinessObject primaryBusinessObjectOrDocument) {
114 return getRoleQualification(primaryBusinessObjectOrDocument, GlobalVariables
115 .getUserSession().getPerson().getPrincipalId());
116 }
117
118
119
120
121 @Override
122 public Map<String, String> getCollectionItemPermissionDetails(
123 BusinessObject collectionItemBusinessObject) {
124 return new HashMap<String, String>();
125 }
126
127
128
129
130 @Override
131 public Map<String, String> getCollectionItemRoleQualifications(
132 BusinessObject collectionItemBusinessObject) {
133 return new HashMap<String, String>();
134 }
135
136 protected static KualiModuleService getKualiModuleService() {
137 if (kualiModuleService == null) {
138 kualiModuleService = KRADServiceLocatorWeb.getKualiModuleService();
139 }
140 return kualiModuleService;
141 }
142
143 protected static DataDictionaryService getDataDictionaryService() {
144 if (dataDictionaryService == null) {
145 dataDictionaryService = KRADServiceLocatorWeb
146 .getDataDictionaryService();
147 }
148 return dataDictionaryService;
149 }
150 }