1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sec.service.impl;
17
18 import org.kuali.ole.sec.document.authorization.SecTransactionalDocumentAuthorizer;
19 import org.kuali.ole.sec.service.AccessSecurityService;
20 import org.kuali.ole.sys.context.SpringContext;
21 import org.kuali.ole.sys.service.impl.DocumentHelperServiceImpl;
22 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer;
23 import org.kuali.rice.kns.document.authorization.TransactionalDocumentAuthorizer;
24
25
26
27
28
29 public class SecDocumentHelperServiceImpl extends DocumentHelperServiceImpl {
30 private AccessSecurityService accessSecurityService;
31
32
33
34
35
36
37
38
39 @Override
40 public DocumentAuthorizer getDocumentAuthorizer(String documentType) {
41
42 DocumentAuthorizer configuredDocumentAuthorizer = super.getDocumentAuthorizer(documentType);
43 if (getAccessSecurityService().isAccessSecurityControlledDocumentType(documentType)) {
44 if ( configuredDocumentAuthorizer instanceof TransactionalDocumentAuthorizer ) {
45 try {
46 SecTransactionalDocumentAuthorizer secDocumentAuthorizer = SecTransactionalDocumentAuthorizer.class.newInstance();
47 secDocumentAuthorizer.setDocumentAuthorizer((TransactionalDocumentAuthorizer) configuredDocumentAuthorizer);
48
49 return secDocumentAuthorizer;
50 } catch (Exception e) {
51 throw new RuntimeException("Unable to create new instance of SecTransactionalDocumentAuthorizer for document type: " + documentType, e);
52 }
53 } else {
54 throw new RuntimeException( "Original DocumentAuthorizer for " + documentType + " is not an instance of " + TransactionalDocumentAuthorizer.class.getName() + ". It can not be wrapped. This is a configuration error." );
55 }
56 }
57
58 return configuredDocumentAuthorizer;
59 }
60
61 public AccessSecurityService getAccessSecurityService() {
62 if ( accessSecurityService == null ) {
63 accessSecurityService = SpringContext.getBean(AccessSecurityService.class);
64 }
65 return accessSecurityService;
66 }
67
68 }