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.authorization.DocumentAuthorizer;
21 import org.kuali.rice.krad.document.authorization.DocumentPresentationController;
22 import org.kuali.rice.krad.document.authorization.MaintenanceDocumentAuthorizer;
23 import org.kuali.rice.krad.document.authorization.MaintenanceDocumentPresentationController;
24 import org.kuali.rice.krad.service.DataDictionaryService;
25 import org.kuali.rice.krad.service.DataObjectAuthorizationService;
26 import org.kuali.rice.krad.service.DocumentHelperService;
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 DocumentHelperService documentHelperService;
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 getDocumentHelperService().getDocumentPresentationController(docTypeName);
59 boolean canCreate =
60 ((MaintenanceDocumentPresentationController) documentPresentationController).canCreate(dataObjectClass);
61 if (canCreate) {
62 DocumentAuthorizer documentAuthorizer = getDocumentHelperService().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) getDocumentHelperService().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 DocumentHelperService getDocumentHelperService() {
89 if (documentHelperService == null) {
90 documentHelperService = KRADServiceLocatorWeb.getDocumentHelperService();
91 }
92 return documentHelperService;
93 }
94
95 public void setDocumentHelperService(DocumentHelperService documentHelperService) {
96 this.documentHelperService = documentHelperService;
97 }
98 }