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 | 0 | 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 | 0 | AttributeSecurity attributeSecurity = |
47 | |
getDataDictionaryService().getAttributeSecurity(dataObjectClass.getName(), attributeName); |
48 | |
|
49 | 0 | return attributeSecurity != null && attributeSecurity.hasRestrictionThatRemovesValueFromUI(); |
50 | |
} |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
@Override |
56 | |
public boolean canCreate(Class<?> dataObjectClass, Person user, String docTypeName) { |
57 | 0 | DocumentPresentationController documentPresentationController = |
58 | |
getDocumentHelperService().getDocumentPresentationController(docTypeName); |
59 | 0 | boolean canCreate = |
60 | |
((MaintenanceDocumentPresentationController) documentPresentationController).canCreate(dataObjectClass); |
61 | 0 | if (canCreate) { |
62 | 0 | DocumentAuthorizer documentAuthorizer = getDocumentHelperService().getDocumentAuthorizer(docTypeName); |
63 | 0 | canCreate = ((MaintenanceDocumentAuthorizer) documentAuthorizer).canCreate(dataObjectClass, user); |
64 | |
} |
65 | 0 | return canCreate; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
@Override |
72 | |
public boolean canMaintain(Object dataObject, Person user, String docTypeName) { |
73 | 0 | return ((MaintenanceDocumentAuthorizer) getDocumentHelperService().getDocumentAuthorizer(docTypeName)) |
74 | |
.canMaintain(dataObject, user); |
75 | |
} |
76 | |
|
77 | |
protected DataDictionaryService getDataDictionaryService() { |
78 | 0 | if (dataDictionaryService == null) { |
79 | 0 | this.dataDictionaryService = KRADServiceLocatorWeb.getDataDictionaryService(); |
80 | |
} |
81 | 0 | return dataDictionaryService; |
82 | |
} |
83 | |
|
84 | |
public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { |
85 | 0 | this.dataDictionaryService = dataDictionaryService; |
86 | 0 | } |
87 | |
|
88 | |
protected DocumentHelperService getDocumentHelperService() { |
89 | 0 | if (documentHelperService == null) { |
90 | 0 | documentHelperService = KRADServiceLocatorWeb.getDocumentHelperService(); |
91 | |
} |
92 | 0 | return documentHelperService; |
93 | |
} |
94 | |
|
95 | |
public void setDocumentHelperService(DocumentHelperService documentHelperService) { |
96 | 0 | this.documentHelperService = documentHelperService; |
97 | 0 | } |
98 | |
} |