1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.service.impl;
17
18 import org.kuali.rice.kim.api.identity.Person;
19 import org.kuali.rice.krad.datadictionary.AttributeSecurity;
20 import org.kuali.rice.krad.document.DocumentAuthorizer;
21 import org.kuali.rice.krad.document.DocumentPresentationController;
22 import org.kuali.rice.krad.maintenance.MaintenanceDocumentAuthorizer;
23 import org.kuali.rice.krad.maintenance.MaintenanceDocumentPresentationController;
24 import org.kuali.rice.krad.service.DataDictionaryService;
25 import org.kuali.rice.krad.service.DataObjectAuthorizationService;
26 import org.kuali.rice.krad.service.DocumentDictionaryService;
27 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
28
29
30
31
32
33
34
35
36 public class DataObjectAuthorizationServiceImpl implements DataObjectAuthorizationService {
37
38 private DataDictionaryService dataDictionaryService;
39 private DocumentDictionaryService documentDictionaryService;
40
41
42
43
44 @Override
45 public boolean attributeValueNeedsToBeEncryptedOnFormsAndLinks(Class<?> dataObjectClass, String attributeName) {
46 AttributeSecurity attributeSecurity =
47 getDataDictionaryService().getAttributeSecurity(dataObjectClass.getName(), attributeName);
48
49 return attributeSecurity != null && attributeSecurity.hasRestrictionThatRemovesValueFromUI();
50 }
51
52
53
54
55 @Override
56 public boolean canCreate(Class<?> dataObjectClass, Person user, String docTypeName) {
57 DocumentPresentationController documentPresentationController =
58 getDocumentDictionaryService().getDocumentPresentationController(docTypeName);
59 boolean canCreate =
60 ((MaintenanceDocumentPresentationController) documentPresentationController).canCreate(dataObjectClass);
61 if (canCreate) {
62 DocumentAuthorizer documentAuthorizer = getDocumentDictionaryService().getDocumentAuthorizer(docTypeName);
63 canCreate = ((MaintenanceDocumentAuthorizer) documentAuthorizer).canCreate(dataObjectClass, user);
64 }
65 return canCreate;
66 }
67
68
69
70
71 @Override
72 public boolean canMaintain(Object dataObject, Person user, String docTypeName) {
73 return ((MaintenanceDocumentAuthorizer) getDocumentDictionaryService().getDocumentAuthorizer(docTypeName))
74 .canMaintain(dataObject, user);
75 }
76
77 protected DataDictionaryService getDataDictionaryService() {
78 if (dataDictionaryService == null) {
79 this.dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService();
80 }
81 return dataDictionaryService;
82 }
83
84 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
85 this.dataDictionaryService = dataDictionaryService;
86 }
87
88 protected DocumentDictionaryService getDocumentDictionaryService() {
89 if (documentDictionaryService == null) {
90 documentDictionaryService = KRADServiceLocatorWeb.getDocumentDictionaryService();
91 }
92 return documentDictionaryService;
93 }
94
95 public void setDocumentDictionaryService(DocumentDictionaryService documentDictionaryService) {
96 this.documentDictionaryService = documentDictionaryService;
97 }
98 }