1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.uif.authorization; |
17 | |
|
18 | |
|
19 | |
import org.kuali.rice.kim.api.KimConstants; |
20 | |
import org.kuali.rice.kim.api.identity.Person; |
21 | |
import org.kuali.rice.krad.document.MaintenanceDocument; |
22 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
23 | |
import org.kuali.rice.krad.util.KRADConstants; |
24 | |
import org.kuali.rice.krad.util.KRADUtils; |
25 | |
|
26 | |
import java.util.HashMap; |
27 | |
import java.util.HashSet; |
28 | |
import java.util.Map; |
29 | |
import java.util.Set; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | public class MaintenanceDocumentAuthorizerBase extends DocumentAuthorizerBase { |
35 | |
|
36 | |
public final boolean canCreate(Class<?> boClass, Person user) { |
37 | 0 | Map<String, String> permissionDetails = new HashMap<String, String>(); |
38 | 0 | permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, |
39 | |
KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentTypeName(boClass)); |
40 | 0 | permissionDetails.put(KRADConstants.MAINTENANCE_ACTN, |
41 | |
KRADConstants.MAINTENANCE_NEW_ACTION); |
42 | 0 | return !permissionExistsByTemplate(KRADConstants.KRAD_NAMESPACE, |
43 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, |
44 | |
permissionDetails) |
45 | |
|| getPermissionService() |
46 | |
.isAuthorizedByTemplateName( |
47 | |
user.getPrincipalId(), |
48 | |
KRADConstants.KRAD_NAMESPACE, |
49 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, |
50 | |
permissionDetails, new HashMap<String, String>()); |
51 | |
} |
52 | |
|
53 | |
public final boolean canMaintain(Object dataObject, Person user) { |
54 | 0 | Map<String, String> permissionDetails = new HashMap<String, String>(2); |
55 | 0 | permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME, |
56 | |
KRADServiceLocatorWeb.getDocumentDictionaryService() |
57 | |
.getMaintenanceDocumentTypeName(dataObject.getClass())); |
58 | 0 | permissionDetails.put(KRADConstants.MAINTENANCE_ACTN, KRADConstants.MAINTENANCE_EDIT_ACTION); |
59 | 0 | return !permissionExistsByTemplate(KRADConstants.KRAD_NAMESPACE, |
60 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, permissionDetails) || |
61 | |
isAuthorizedByTemplate(dataObject, KRADConstants.KRAD_NAMESPACE, |
62 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, user.getPrincipalId(), |
63 | |
permissionDetails, null); |
64 | |
} |
65 | |
|
66 | |
public final boolean canCreateOrMaintain(MaintenanceDocument maintenanceDocument, Person user) { |
67 | 0 | return !permissionExistsByTemplate(maintenanceDocument, KRADConstants.KRAD_NAMESPACE, |
68 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS) || |
69 | |
isAuthorizedByTemplate(maintenanceDocument, KRADConstants.KRAD_NAMESPACE, |
70 | |
KimConstants.PermissionTemplateNames.CREATE_MAINTAIN_RECORDS, user.getPrincipalId()); |
71 | |
} |
72 | |
|
73 | |
public Set<String> getSecurePotentiallyHiddenSectionIds() { |
74 | 0 | return new HashSet<String>(); |
75 | |
} |
76 | |
|
77 | |
public Set<String> getSecurePotentiallyReadOnlySectionIds() { |
78 | 0 | return new HashSet<String>(); |
79 | |
} |
80 | |
|
81 | |
@SuppressWarnings("unchecked") |
82 | |
@Override |
83 | |
protected void addRoleQualification(Object dataObject, Map<String, String> attributes) { |
84 | 0 | super.addRoleQualification(dataObject, attributes); |
85 | 0 | if (dataObject instanceof MaintenanceDocument) { |
86 | 0 | MaintenanceDocument maintDoc = (MaintenanceDocument) dataObject; |
87 | 0 | if (maintDoc.getNewMaintainableObject() != null) { |
88 | 0 | attributes.putAll(KRADUtils |
89 | |
.getNamespaceAndComponentSimpleName(maintDoc.getNewMaintainableObject().getDataObjectClass())); |
90 | |
} |
91 | |
} |
92 | 0 | } |
93 | |
|
94 | |
@SuppressWarnings("unchecked") |
95 | |
@Override |
96 | |
protected void addPermissionDetails(Object dataObject, Map<String, String> attributes) { |
97 | 0 | super.addPermissionDetails(dataObject, attributes); |
98 | 0 | if (dataObject instanceof MaintenanceDocument) { |
99 | 0 | MaintenanceDocument maintDoc = (MaintenanceDocument) dataObject; |
100 | 0 | if (maintDoc.getNewMaintainableObject() != null) { |
101 | 0 | attributes.putAll(KRADUtils |
102 | |
.getNamespaceAndComponentSimpleName(maintDoc.getNewMaintainableObject().getDataObjectClass())); |
103 | 0 | attributes.put(KRADConstants.MAINTENANCE_ACTN, |
104 | |
maintDoc.getNewMaintainableObject().getMaintenanceAction()); |
105 | |
} |
106 | |
} |
107 | 0 | } |
108 | |
} |