1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.doctype.service.impl; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
20 | |
import org.kuali.rice.core.util.AttributeSet; |
21 | |
import org.kuali.rice.kew.doctype.DocumentTypePolicyEnum; |
22 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
23 | |
import org.kuali.rice.kew.doctype.service.DocumentTypePermissionService; |
24 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
25 | |
import org.kuali.rice.kew.util.KEWConstants; |
26 | |
import org.kuali.rice.kim.api.services.IdentityManagementService; |
27 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
28 | |
import org.kuali.rice.kim.service.PermissionService; |
29 | |
import org.kuali.rice.kim.util.KimConstants; |
30 | |
import org.kuali.rice.kns.datadictionary.DocumentEntry; |
31 | |
import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry; |
32 | |
import org.kuali.rice.kns.document.Document; |
33 | |
import org.kuali.rice.kns.document.MaintenanceDocument; |
34 | |
import org.kuali.rice.kns.document.authorization.DocumentAuthorizerBase; |
35 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
36 | |
import org.kuali.rice.kns.util.KNSConstants; |
37 | |
import org.kuali.rice.kns.util.KNSUtils; |
38 | |
import org.kuali.rice.ksb.api.KsbApiServiceLocator; |
39 | |
import org.kuali.rice.ksb.api.cache.RiceCacheAdministrator; |
40 | |
|
41 | |
import java.util.ArrayList; |
42 | |
import java.util.List; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | 0 | public class DocumentTypePermissionServiceImpl implements DocumentTypePermissionService { |
51 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentTypePermissionServiceImpl.class); |
52 | |
|
53 | |
public static final String DOC_TYPE_PERM_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_GROUP + ":"; |
54 | |
public static final String BLANKET_APPROVE_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_PREFIX + "BlanketApprove:"; |
55 | |
public static final String PRINCIPAL_ADHOC_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_PREFIX + "PrincipalAdhoc:"; |
56 | |
public static final String GROUP_ADHOC_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_PREFIX + "GroupAdhoc:"; |
57 | |
public static final String ADMIN_ROUTING_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_PREFIX + "AdminRouting:"; |
58 | |
public static final String CANCEL_CACHE_PREFIX = DOC_TYPE_PERM_CACHE_PREFIX + "Cancel:"; |
59 | |
|
60 | |
private RiceCacheAdministrator cacheAdministrator; |
61 | 0 | private final AttributeSet EMPTY_ROLE_QUALIFIERS = new AttributeSet(0); |
62 | |
|
63 | |
protected RiceCacheAdministrator getCacheAdministrator() { |
64 | 0 | if ( cacheAdministrator == null ) { |
65 | 0 | cacheAdministrator = KsbApiServiceLocator.getCacheAdministrator(); |
66 | |
} |
67 | 0 | return cacheAdministrator; |
68 | |
} |
69 | |
|
70 | |
public boolean canBlanketApprove(String principalId, DocumentType documentType, String documentStatus, String initiatorPrincipalId) { |
71 | 0 | validatePrincipalId(principalId); |
72 | 0 | validateDocumentType(documentType); |
73 | 0 | validateDocumentStatus(documentStatus); |
74 | 0 | validatePrincipalId(initiatorPrincipalId); |
75 | |
|
76 | 0 | String cacheKey = buildBlanketApproveCacheKey(principalId, documentType, documentStatus, initiatorPrincipalId); |
77 | 0 | Boolean result = (Boolean)getCacheAdministrator().getFromCache(cacheKey); |
78 | 0 | if ( result == null ) { |
79 | 0 | if (documentType.isBlanketApproveGroupDefined()) { |
80 | 0 | boolean initiatorAuthorized = true; |
81 | 0 | if (documentType.getInitiatorMustBlanketApprovePolicy().getPolicyValue()) { |
82 | 0 | initiatorAuthorized = executeInitiatorPolicyCheck(principalId, initiatorPrincipalId, documentStatus); |
83 | |
} |
84 | 0 | result = initiatorAuthorized && documentType.isBlanketApprover(principalId); |
85 | 0 | } else { |
86 | 0 | AttributeSet permissionDetails = buildDocumentTypePermissionDetails(documentType); |
87 | 0 | result = getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.BLANKET_APPROVE_PERMISSION, permissionDetails, EMPTY_ROLE_QUALIFIERS); |
88 | |
} |
89 | 0 | getCacheAdministrator().putInCache(cacheKey, result, DOC_TYPE_PERM_CACHE_GROUP); |
90 | |
} |
91 | 0 | return result; |
92 | |
} |
93 | |
|
94 | |
protected String buildBlanketApproveCacheKey( String principalId, DocumentType documentType, String documentStatus, String initiatorPrincipalId ) { |
95 | 0 | return BLANKET_APPROVE_CACHE_PREFIX + documentType.getName() + "/" + documentStatus + "/" + principalId + "/" + initiatorPrincipalId; |
96 | |
} |
97 | |
|
98 | |
public boolean canReceiveAdHocRequest(String principalId, DocumentType documentType, String actionRequestType) { |
99 | 0 | validatePrincipalId(principalId); |
100 | 0 | validateDocumentType(documentType); |
101 | 0 | validateActionRequestType(actionRequestType); |
102 | |
|
103 | 0 | String cacheKey = buildPrincipalAdhocCacheKey(principalId, documentType, actionRequestType ); |
104 | 0 | Boolean result = (Boolean)getCacheAdministrator().getFromCache(cacheKey); |
105 | |
|
106 | 0 | if ( result == null ) { |
107 | 0 | AttributeSet permissionDetails = buildDocumentTypeActionRequestPermissionDetails(documentType, actionRequestType); |
108 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.AD_HOC_REVIEW_PERMISSION, permissionDetails)) { |
109 | 0 | result = getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.AD_HOC_REVIEW_PERMISSION, permissionDetails, EMPTY_ROLE_QUALIFIERS); |
110 | |
} else { |
111 | 0 | result = Boolean.TRUE; |
112 | |
} |
113 | 0 | getCacheAdministrator().putInCache(cacheKey, result, DOC_TYPE_PERM_CACHE_GROUP); |
114 | |
} |
115 | 0 | return result; |
116 | |
} |
117 | |
|
118 | |
protected String buildPrincipalAdhocCacheKey( String principalId, DocumentType documentType, String actionRequestType ) { |
119 | 0 | return PRINCIPAL_ADHOC_CACHE_PREFIX + documentType.getName() + "/" + actionRequestType + "/" + principalId; |
120 | |
} |
121 | |
|
122 | |
public boolean canGroupReceiveAdHocRequest(String groupId, DocumentType documentType, String actionRequestType) { |
123 | 0 | validateGroupId(groupId); |
124 | 0 | validateDocumentType(documentType); |
125 | 0 | validateActionRequestType(actionRequestType); |
126 | |
|
127 | 0 | String cacheKey = buildGroupAdhocCacheKey(groupId, documentType, actionRequestType ); |
128 | 0 | Boolean result = (Boolean)getCacheAdministrator().getFromCache(cacheKey); |
129 | |
|
130 | 0 | if ( result == null ) { |
131 | 0 | result = Boolean.TRUE; |
132 | 0 | AttributeSet permissionDetails = buildDocumentTypeActionRequestPermissionDetails(documentType, actionRequestType); |
133 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.AD_HOC_REVIEW_PERMISSION, permissionDetails)) { |
134 | 0 | List<String> principalIds = getIdentityManagementService().getGroupMemberPrincipalIds(groupId); |
135 | |
|
136 | 0 | for (String principalId : principalIds) { |
137 | 0 | if (!getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.AD_HOC_REVIEW_PERMISSION, permissionDetails, EMPTY_ROLE_QUALIFIERS)) { |
138 | 0 | result = Boolean.FALSE; |
139 | 0 | break; |
140 | |
} |
141 | |
} |
142 | |
} |
143 | 0 | getCacheAdministrator().putInCache(cacheKey, result, DOC_TYPE_PERM_CACHE_GROUP); |
144 | |
} |
145 | 0 | return result; |
146 | |
} |
147 | |
|
148 | |
protected String buildGroupAdhocCacheKey( String groupId, DocumentType documentType, String actionRequestType ) { |
149 | 0 | return GROUP_ADHOC_CACHE_PREFIX + documentType.getName() + "/" + actionRequestType + "/" + groupId; |
150 | |
} |
151 | |
|
152 | |
public boolean canAdministerRouting(String principalId, DocumentType documentType) { |
153 | 0 | validatePrincipalId(principalId); |
154 | 0 | validateDocumentType(documentType); |
155 | |
|
156 | 0 | String cacheKey = buildAdminRoutingCacheKey(principalId, documentType ); |
157 | 0 | Boolean result = (Boolean)getCacheAdministrator().getFromCache(cacheKey); |
158 | |
|
159 | 0 | if ( result == null ) { |
160 | 0 | if (documentType.isSuperUserGroupDefined()) { |
161 | 0 | result = documentType.isSuperUser(principalId); |
162 | |
} else { |
163 | 0 | AttributeSet permissionDetails = buildDocumentTypePermissionDetails(documentType); |
164 | 0 | result = getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.ADMINISTER_ROUTING_PERMISSION, permissionDetails, EMPTY_ROLE_QUALIFIERS); |
165 | |
} |
166 | 0 | getCacheAdministrator().putInCache(cacheKey, result, DOC_TYPE_PERM_CACHE_GROUP); |
167 | |
} |
168 | |
|
169 | 0 | return result; |
170 | |
} |
171 | |
|
172 | |
protected String buildAdminRoutingCacheKey( String principalId, DocumentType documentType ) { |
173 | 0 | return ADMIN_ROUTING_CACHE_PREFIX + documentType.getName() + "/" + principalId; |
174 | |
} |
175 | |
|
176 | |
public boolean canCancel(String principalId, String documentId, DocumentType documentType, List<String> routeNodeNames, String documentStatus, String initiatorPrincipalId) { |
177 | 0 | validatePrincipalId(principalId); |
178 | 0 | validateDocumentType(documentType); |
179 | 0 | validateRouteNodeNames(routeNodeNames); |
180 | 0 | validateDocumentStatus(documentStatus); |
181 | 0 | validatePrincipalId(initiatorPrincipalId); |
182 | |
|
183 | 0 | if (!documentType.isPolicyDefined(DocumentTypePolicyEnum.INITIATOR_MUST_CANCEL)) { |
184 | 0 | List<AttributeSet> permissionDetailList = buildDocumentTypePermissionDetails(documentType, routeNodeNames, documentStatus); |
185 | |
|
186 | 0 | boolean foundAtLeastOnePermission = false; |
187 | |
|
188 | 0 | for (AttributeSet permissionDetails : permissionDetailList) { |
189 | 0 | AttributeSet roleQualifiers = buildDocumentIdRoleDocumentTypeDocumentStatusQualifiers(documentType, documentStatus, documentId, permissionDetails.get(KEWConstants.ROUTE_NODE_NAME_DETAIL)); |
190 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.CANCEL_PERMISSION, permissionDetails)) { |
191 | 0 | foundAtLeastOnePermission = true; |
192 | 0 | if (getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.CANCEL_PERMISSION, permissionDetails, roleQualifiers)) { |
193 | 0 | return true; |
194 | |
} |
195 | |
} |
196 | 0 | } |
197 | |
|
198 | 0 | if (foundAtLeastOnePermission) { |
199 | 0 | return false; |
200 | |
} |
201 | |
} |
202 | |
|
203 | 0 | if (documentType.getInitiatorMustCancelPolicy().getPolicyValue()) { |
204 | 0 | return executeInitiatorPolicyCheck(principalId, initiatorPrincipalId, documentStatus); |
205 | |
} else { |
206 | 0 | return true; |
207 | |
} |
208 | |
} |
209 | |
|
210 | |
public boolean canInitiate(String principalId, DocumentType documentType) { |
211 | 0 | validatePrincipalId(principalId); |
212 | 0 | validateDocumentType(documentType); |
213 | |
|
214 | 0 | AttributeSet permissionDetails = buildDocumentTypePermissionDetails(documentType); |
215 | 0 | if (useKimPermission(KNSConstants.KUALI_RICE_SYSTEM_NAMESPACE, KEWConstants.INITIATE_PERMISSION, permissionDetails)) { |
216 | 0 | return getIdentityManagementService().isAuthorizedByTemplateName(principalId, KNSConstants.KUALI_RICE_SYSTEM_NAMESPACE, KEWConstants.INITIATE_PERMISSION, permissionDetails, EMPTY_ROLE_QUALIFIERS); |
217 | |
} |
218 | 0 | return true; |
219 | |
} |
220 | |
|
221 | |
public boolean canRoute(String principalId, DocumentRouteHeaderValue documentRouteHeaderValue) { |
222 | 0 | return canRoute(principalId, documentRouteHeaderValue.getDocumentId(), documentRouteHeaderValue.getDocumentType(), |
223 | |
documentRouteHeaderValue.getDocRouteStatus(), documentRouteHeaderValue.getInitiatorWorkflowId()); |
224 | |
} |
225 | |
|
226 | |
public boolean canRoute(String principalId, String documentId, DocumentType documentType, String documentStatus, String initiatorPrincipalId) { |
227 | 0 | validatePrincipalId(principalId); |
228 | 0 | validateDocumentType(documentType); |
229 | 0 | validateDocumentStatus(documentStatus); |
230 | 0 | validatePrincipalId(initiatorPrincipalId); |
231 | |
|
232 | 0 | if (!documentType.isPolicyDefined(DocumentTypePolicyEnum.INITIATOR_MUST_ROUTE)) { |
233 | 0 | AttributeSet permissionDetails = buildDocumentTypeDocumentStatusPermissionDetails(documentType, documentStatus); |
234 | 0 | AttributeSet roleQualifiers = buildDocumentIdRoleDocumentTypeDocumentStatusQualifiers(documentType, documentStatus, documentId, permissionDetails.get(KEWConstants.ROUTE_NODE_NAME_DETAIL)); |
235 | |
|
236 | 0 | if (LOG.isDebugEnabled()) { |
237 | 0 | LOG.debug("Permission details values: " + permissionDetails.formattedDump(10)); |
238 | 0 | LOG.debug("Role qualifiers values: " + roleQualifiers.formattedDump(10)); |
239 | |
} |
240 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.ROUTE_PERMISSION, permissionDetails)) { |
241 | 0 | return getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.ROUTE_PERMISSION, permissionDetails, roleQualifiers); |
242 | |
} |
243 | |
} |
244 | |
|
245 | 0 | if (documentType.getInitiatorMustRoutePolicy().getPolicyValue()) { |
246 | 0 | return executeInitiatorPolicyCheck(principalId, initiatorPrincipalId, documentStatus); |
247 | |
} |
248 | 0 | return true; |
249 | |
} |
250 | |
|
251 | |
public boolean canAddRouteLogMessage(String principalId, DocumentRouteHeaderValue documentRouteHeaderValue) { |
252 | 0 | return canAddRouteLogMessage(principalId, documentRouteHeaderValue.getDocumentId(), |
253 | |
documentRouteHeaderValue.getDocumentType(), documentRouteHeaderValue.getDocRouteStatus(), |
254 | |
documentRouteHeaderValue.getInitiatorWorkflowId()); |
255 | |
} |
256 | |
|
257 | |
public boolean canAddRouteLogMessage(String principalId, String documentId, DocumentType documentType, |
258 | |
String documentStatus, String initiatorPrincipalId) { |
259 | 0 | validatePrincipalId(principalId); |
260 | 0 | validateDocumentType(documentType); |
261 | 0 | validateDocumentStatus(documentStatus); |
262 | 0 | validatePrincipalId(initiatorPrincipalId); |
263 | |
|
264 | 0 | AttributeSet permissionDetails = buildDocumentTypeDocumentStatusPermissionDetails(documentType, documentStatus); |
265 | 0 | AttributeSet roleQualifiers = buildDocumentIdRoleDocumentTypeDocumentStatusQualifiers(documentType, |
266 | |
documentStatus, documentId, permissionDetails.get(KEWConstants.ROUTE_NODE_NAME_DETAIL)); |
267 | |
|
268 | 0 | if (LOG.isDebugEnabled()) { |
269 | 0 | LOG.debug("Permission details values: " + permissionDetails.formattedDump(10)); |
270 | 0 | LOG.debug("Role qualifiers values: " + roleQualifiers.formattedDump(10)); |
271 | |
} |
272 | |
|
273 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.ADD_MESSAGE_TO_ROUTE_LOG, permissionDetails)) { |
274 | 0 | return getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, |
275 | |
KEWConstants.ADD_MESSAGE_TO_ROUTE_LOG, permissionDetails, roleQualifiers); |
276 | |
} |
277 | |
|
278 | 0 | return false; |
279 | |
} |
280 | |
|
281 | |
public boolean canSave(String principalId, String documentId, DocumentType documentType, List<String> routeNodeNames, String documentStatus, String initiatorPrincipalId) { |
282 | 0 | validatePrincipalId(principalId); |
283 | 0 | validateDocumentType(documentType); |
284 | 0 | validateRouteNodeNames(routeNodeNames); |
285 | 0 | validateDocumentStatus(documentStatus); |
286 | 0 | validatePrincipalId(initiatorPrincipalId); |
287 | |
|
288 | 0 | if (!documentType.isPolicyDefined(DocumentTypePolicyEnum.INITIATOR_MUST_SAVE)) { |
289 | 0 | List<AttributeSet> permissionDetailList = buildDocumentTypePermissionDetails(documentType, routeNodeNames, documentStatus); |
290 | |
|
291 | 0 | boolean foundAtLeastOnePermission = false; |
292 | |
|
293 | 0 | for (AttributeSet permissionDetails : permissionDetailList) { |
294 | 0 | AttributeSet roleQualifiers = buildDocumentIdRoleDocumentTypeDocumentStatusQualifiers(documentType, documentStatus, documentId, permissionDetails.get(KEWConstants.ROUTE_NODE_NAME_DETAIL)); |
295 | 0 | if (useKimPermission(KEWConstants.KEW_NAMESPACE, KEWConstants.SAVE_PERMISSION, permissionDetails)) { |
296 | 0 | foundAtLeastOnePermission = true; |
297 | 0 | if (getIdentityManagementService().isAuthorizedByTemplateName(principalId, KEWConstants.KEW_NAMESPACE, KEWConstants.SAVE_PERMISSION, permissionDetails, roleQualifiers)) { |
298 | 0 | return true; |
299 | |
} |
300 | |
} |
301 | 0 | } |
302 | |
|
303 | 0 | if (foundAtLeastOnePermission) { |
304 | 0 | return false; |
305 | |
} |
306 | |
} |
307 | |
|
308 | 0 | if (documentType.getInitiatorMustSavePolicy().getPolicyValue()) { |
309 | 0 | return executeInitiatorPolicyCheck(principalId, initiatorPrincipalId, documentStatus); |
310 | |
} |
311 | 0 | return true; |
312 | |
} |
313 | |
|
314 | |
protected AttributeSet buildDocumentTypePermissionDetails(DocumentType documentType) { |
315 | 0 | AttributeSet details = new AttributeSet(); |
316 | 0 | details.put(KEWConstants.DOCUMENT_TYPE_NAME_DETAIL, documentType.getName()); |
317 | 0 | return details; |
318 | |
} |
319 | |
|
320 | |
protected AttributeSet buildDocumentTypeActionRequestPermissionDetails(DocumentType documentType, String actionRequestCode) { |
321 | 0 | AttributeSet details = buildDocumentTypePermissionDetails(documentType); |
322 | 0 | if (!StringUtils.isBlank(actionRequestCode)) { |
323 | 0 | details.put(KEWConstants.ACTION_REQUEST_CD_DETAIL, actionRequestCode); |
324 | |
} |
325 | 0 | return details; |
326 | |
} |
327 | |
|
328 | |
protected AttributeSet buildDocumentTypeDocumentStatusPermissionDetails(DocumentType documentType, String documentStatus) { |
329 | 0 | AttributeSet details = buildDocumentTypePermissionDetails(documentType); |
330 | 0 | if (!StringUtils.isBlank(documentStatus)) { |
331 | 0 | details.put(KEWConstants.DOCUMENT_STATUS_DETAIL, documentStatus); |
332 | |
} |
333 | 0 | return details; |
334 | |
} |
335 | |
|
336 | |
protected AttributeSet buildDocumentIdRoleDocumentTypeDocumentStatusQualifiers(DocumentType documentType, String documentStatus, String documentId, String routeNodeName) { |
337 | 0 | AttributeSet qualifiers = new AttributeSet(); |
338 | 0 | qualifiers.put(KimConstants.AttributeConstants.DOCUMENT_NUMBER, documentId); |
339 | 0 | if (!StringUtils.isBlank(documentStatus)) { |
340 | 0 | qualifiers.put(KEWConstants.DOCUMENT_STATUS_DETAIL, documentStatus); |
341 | 0 | if (KEWConstants.ROUTE_HEADER_INITIATED_CD.equals(documentStatus) || KEWConstants.ROUTE_HEADER_SAVED_CD.equals(documentStatus)) { |
342 | 0 | qualifiers.put(KimConstants.AttributeConstants.ROUTE_NODE_NAME, DocumentAuthorizerBase.PRE_ROUTING_ROUTE_NAME); |
343 | |
} |
344 | |
else { |
345 | 0 | qualifiers.put(KimConstants.AttributeConstants.ROUTE_NODE_NAME, routeNodeName); |
346 | |
} |
347 | |
} |
348 | 0 | qualifiers.put(KEWConstants.DOCUMENT_TYPE_NAME_DETAIL, documentType.getName()); |
349 | |
|
350 | 0 | DocumentEntry documentEntry = KNSServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(documentType.getName()); |
351 | 0 | if (documentEntry != null) { |
352 | 0 | Class<? extends Document> documentClass = documentEntry.getDocumentClass(); |
353 | |
String namespaceCode; |
354 | 0 | if (MaintenanceDocument.class.isAssignableFrom(documentClass)) { |
355 | 0 | MaintenanceDocumentEntry maintenanceDocumentEntry = (MaintenanceDocumentEntry) documentEntry; |
356 | 0 | namespaceCode = KNSUtils.getNamespaceCode(maintenanceDocumentEntry.getBusinessObjectClass()); |
357 | 0 | } |
358 | |
else { |
359 | 0 | namespaceCode = KNSUtils.getNamespaceCode(documentClass); |
360 | |
} |
361 | 0 | qualifiers.put(KimConstants.AttributeConstants.NAMESPACE_CODE, namespaceCode); |
362 | |
} |
363 | |
|
364 | 0 | return qualifiers; |
365 | |
} |
366 | |
|
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
|
375 | |
|
376 | |
|
377 | |
|
378 | |
protected List<AttributeSet> buildDocumentTypePermissionDetails(DocumentType documentType, |
379 | |
List<String> routeNodeNames, String documentStatus) { |
380 | 0 | List<AttributeSet> detailList = new ArrayList<AttributeSet>(); |
381 | |
|
382 | 0 | for (String routeNodeName : routeNodeNames) { |
383 | 0 | AttributeSet details = buildDocumentTypePermissionDetails(documentType); |
384 | 0 | if (KEWConstants.ROUTE_HEADER_INITIATED_CD.equals(documentStatus) || |
385 | |
KEWConstants.ROUTE_HEADER_SAVED_CD.equals(documentStatus)) { |
386 | 0 | details.put(KEWConstants.ROUTE_NODE_NAME_DETAIL, DocumentAuthorizerBase.PRE_ROUTING_ROUTE_NAME); |
387 | 0 | } else if (!StringUtils.isBlank(routeNodeName)) { |
388 | 0 | details.put(KEWConstants.ROUTE_NODE_NAME_DETAIL, routeNodeName); |
389 | |
} |
390 | 0 | if (!StringUtils.isBlank(documentStatus)) { |
391 | 0 | details.put(KEWConstants.DOCUMENT_STATUS_DETAIL, documentStatus); |
392 | |
} |
393 | 0 | if (null != documentType) { |
394 | 0 | details.put(KEWConstants.DOCUMENT_TYPE_NAME_DETAIL, documentType.getName()); |
395 | |
} |
396 | 0 | detailList.add(details); |
397 | 0 | } |
398 | 0 | return detailList; |
399 | |
} |
400 | |
|
401 | |
|
402 | |
protected boolean useKimPermission(String namespace, String permissionTemplateName, AttributeSet permissionDetails) { |
403 | 0 | Boolean b = CoreFrameworkServiceLocator.getParameterService().getParameterValueAsBoolean(KEWConstants.KEW_NAMESPACE, KNSConstants.DetailTypes.ALL_DETAIL_TYPE, KEWConstants.KIM_PRIORITY_ON_DOC_TYP_PERMS_IND); |
404 | 0 | if (b == null || b) { |
405 | 0 | return getIdentityManagementService().isPermissionDefinedForTemplateName(namespace, permissionTemplateName, permissionDetails); |
406 | |
} |
407 | 0 | return false; |
408 | |
} |
409 | |
|
410 | |
private boolean executeInitiatorPolicyCheck(String principalId, String initiatorPrincipalId, String documentStatus) { |
411 | 0 | return principalId.equals(initiatorPrincipalId) || !(KEWConstants.ROUTE_HEADER_SAVED_CD.equals(documentStatus) || KEWConstants.ROUTE_HEADER_INITIATED_CD.equals(documentStatus)); |
412 | |
} |
413 | |
|
414 | |
private void validatePrincipalId(String principalId) { |
415 | 0 | if (StringUtils.isBlank(principalId)) { |
416 | 0 | throw new IllegalArgumentException("Invalid principal ID, value was empty"); |
417 | |
} |
418 | 0 | } |
419 | |
|
420 | |
private void validateGroupId(String groupId) { |
421 | 0 | if (StringUtils.isBlank(groupId)) { |
422 | 0 | throw new IllegalArgumentException("Invalid group ID, value was empty"); |
423 | |
} |
424 | 0 | } |
425 | |
|
426 | |
private void validateDocumentType(DocumentType documentType) { |
427 | 0 | if (documentType == null) { |
428 | 0 | throw new IllegalArgumentException("DocumentType cannot be null"); |
429 | |
} |
430 | 0 | } |
431 | |
|
432 | |
private void validateActionRequestType(String actionRequestType) { |
433 | 0 | if (StringUtils.isBlank(actionRequestType)) { |
434 | 0 | throw new IllegalArgumentException("Invalid action request type, value was empty"); |
435 | |
} |
436 | 0 | if (!KEWConstants.ACTION_REQUEST_CODES.containsKey(actionRequestType)) { |
437 | 0 | throw new IllegalArgumentException("Invalid action request type was given, value was: " + actionRequestType); |
438 | |
} |
439 | 0 | } |
440 | |
|
441 | |
private void validateRouteNodeNames(List<String> routeNodeNames) { |
442 | 0 | if (routeNodeNames.isEmpty()) { |
443 | 0 | return; |
444 | |
|
445 | |
} |
446 | 0 | for (String routeNodeName : routeNodeNames) { |
447 | 0 | if (StringUtils.isBlank(routeNodeName)) { |
448 | 0 | throw new IllegalArgumentException("List of route node names contained an invalid route node name, value was empty"); |
449 | |
} |
450 | |
} |
451 | 0 | } |
452 | |
|
453 | |
private void validateDocumentStatus(String documentStatus) { |
454 | 0 | if (StringUtils.isBlank(documentStatus)) { |
455 | 0 | throw new IllegalArgumentException("Invalid document status, value was empty"); |
456 | |
} |
457 | 0 | if (!KEWConstants.DOCUMENT_STATUSES.containsKey(documentStatus)) { |
458 | 0 | throw new IllegalArgumentException("Invalid document status was given, value was: " + documentStatus); |
459 | |
} |
460 | 0 | } |
461 | |
|
462 | |
protected IdentityManagementService getIdentityManagementService() { |
463 | 0 | return KimApiServiceLocator.getIdentityManagementService(); |
464 | |
} |
465 | |
|
466 | |
protected PermissionService getPermissionService() { |
467 | 0 | return KimApiServiceLocator.getPermissionService(); |
468 | |
} |
469 | |
|
470 | |
} |