1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws;
17
18 import org.apache.cxf.frontend.ServerFactoryBean;
19 import org.apache.cxf.interceptor.InterceptorProvider;
20 import org.openehealth.ipf.commons.audit.AuditContext;
21 import org.openehealth.ipf.commons.ihe.core.atna.AuditStrategy;
22 import org.openehealth.ipf.commons.ihe.ws.cxf.WsRejectionHandlingStrategy;
23 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditInRequestInterceptor;
24 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.AuditResponseInterceptor;
25 import org.openehealth.ipf.commons.ihe.ws.cxf.audit.WsAuditDataset;
26 import org.openehealth.ipf.commons.ihe.ws.cxf.payload.InPayloadExtractorInterceptor;
27
28 import static org.openehealth.ipf.commons.ihe.ws.cxf.payload.StringPayloadHolder.PayloadType.SOAP_BODY;
29
30
31
32
33 public class JaxWsRequestServiceFactory<AuditDatasetType extends WsAuditDataset> extends JaxWsServiceFactory<AuditDatasetType> {
34
35 public JaxWsRequestServiceFactory(
36 WsTransactionConfiguration<AuditDatasetType> wsTransactionConfiguration,
37 String serviceAddress,
38 AuditStrategy<AuditDatasetType> auditStrategy,
39 AuditContext auditContext,
40 InterceptorProvider customInterceptors,
41 WsRejectionHandlingStrategy rejectionHandlingStrategy)
42 {
43 super(wsTransactionConfiguration, serviceAddress, auditStrategy, auditContext, customInterceptors, rejectionHandlingStrategy);
44 }
45
46 protected void configureInterceptors(ServerFactoryBean svrFactory) {
47 super.configureInterceptors(svrFactory);
48
49
50 if (auditStrategy != null) {
51 if (wsTransactionConfiguration.isAuditRequestPayload()) {
52 svrFactory.getInInterceptors().add(new InPayloadExtractorInterceptor(SOAP_BODY));
53 }
54
55 svrFactory.getInInterceptors().add(new AuditInRequestInterceptor<>(
56 auditStrategy, auditContext, wsTransactionConfiguration));
57
58 AuditResponseInterceptor<AuditDatasetType> auditInterceptor =
59 new AuditResponseInterceptor<>(auditStrategy, auditContext, true, null, false);
60 svrFactory.getOutInterceptors().add(auditInterceptor);
61 svrFactory.getOutFaultInterceptors().add(auditInterceptor);
62 }
63 }
64
65 }