Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 867688d

Browse files
authored
Merge pull request #9 from num-codex/ssl_fix_hapi_container_0.2.2
SSLContext fixes, HAPI docker image
2 parents 2295c99 + 4aa699b commit 867688d

34 files changed

Lines changed: 112 additions & 57 deletions

codex-process-data-transfer/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>de.netzwerk-universitaetsmedizin.codex</groupId>
1010
<artifactId>codex-processes-ap1</artifactId>
11-
<version>0.2.1</version>
11+
<version>0.2.2-SNAPSHOT</version>
1212
</parent>
1313

1414
<properties>

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/ApacheRestfulClientFactoryWithTlsConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
3030
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
3131
import org.apache.http.ssl.SSLContexts;
32+
import org.slf4j.Logger;
33+
import org.slf4j.LoggerFactory;
3234

3335
import ca.uhn.fhir.context.FhirContext;
3436
import ca.uhn.fhir.rest.api.RequestTypeEnum;
@@ -39,6 +41,8 @@
3941

4042
public class ApacheRestfulClientFactoryWithTlsConfig extends RestfulClientFactory
4143
{
44+
private static final Logger logger = LoggerFactory.getLogger(ApacheRestfulClientFactoryWithTlsConfig.class);
45+
4246
private HttpClient myHttpClient;
4347
private HttpHost myProxy;
4448

@@ -59,6 +63,8 @@ public ApacheRestfulClientFactoryWithTlsConfig(FhirContext fhirContext, KeyStore
5963
@Override
6064
protected synchronized ApacheHttpClient getHttpClient(String theServerBase)
6165
{
66+
logger.info("Returning new ApacheHttpClient for ServerNase {}", theServerBase);
67+
6268
return new ApacheHttpClient(getNativeHttpClient(), new StringBuilder(theServerBase), null, null, null, null);
6369
}
6470

@@ -91,7 +97,7 @@ public HttpClient getNativeHttpClient()
9197
.setProxy(myProxy).build();
9298

9399
HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connectionManager)
94-
.setDefaultRequestConfig(defaultRequestConfig).disableCookieManagement();
100+
.setSSLContext(sslContext).setDefaultRequestConfig(defaultRequestConfig).disableCookieManagement();
95101

96102
if (myProxy != null && StringUtils.isNotBlank(getProxyUsername())
97103
&& StringUtils.isNotBlank(getProxyPassword()))

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/FttpClient.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ public interface FttpClient
1010
* @return
1111
*/
1212
Optional<String> getCrrPseudonym(String dicSourceAndPseudonym);
13+
14+
void testConnection();
1315
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/FttpClientFactory.java

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@
2222
import org.apache.commons.codec.binary.Hex;
2323
import org.slf4j.Logger;
2424
import org.slf4j.LoggerFactory;
25+
import org.springframework.beans.factory.InitializingBean;
2526

26-
import ca.uhn.fhir.context.FhirContext;
2727
import de.rwh.utils.crypto.CertificateHelper;
2828
import de.rwh.utils.crypto.io.CertificateReader;
2929
import de.rwh.utils.crypto.io.PemIo;
3030

31-
public class FttpClientFactory
31+
public class FttpClientFactory implements InitializingBean
3232
{
33+
private static final Logger logger = LoggerFactory.getLogger(FttpClientFactory.FttpClientStub.class);
34+
3335
private static final class FttpClientStub implements FttpClient
3436
{
3537
private static final Logger logger = LoggerFactory.getLogger(FttpClientStub.class);
@@ -59,9 +61,14 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
5961
return Optional.empty();
6062
}
6163
}
64+
65+
@Override
66+
public void testConnection()
67+
{
68+
logger.warn("Stub implementation, no connection test performed");
69+
}
6270
}
6371

64-
private final FhirContext fhirContext;
6572
private final Path trustStorePath;
6673
private final Path certificatePath;
6774
private final Path privateKeyPath;
@@ -70,14 +77,9 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
7077
private final String fttpStudy;
7178
private final String fttpTarget;
7279

73-
public FttpClientFactory(FhirContext fhirContext, Path trustStorePath, Path certificatePath, Path privateKeyPath,
74-
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget)
80+
public FttpClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath, String fttpServerBase,
81+
String fttpApiKey, String fttpStudy, String fttpTarget)
7582
{
76-
if (fhirContext != null)
77-
this.fhirContext = fhirContext;
78-
else
79-
this.fhirContext = FhirContext.forR4();
80-
8183
this.trustStorePath = trustStorePath;
8284
this.certificatePath = certificatePath;
8385
this.privateKeyPath = privateKeyPath;
@@ -88,6 +90,23 @@ public FttpClientFactory(FhirContext fhirContext, Path trustStorePath, Path cert
8890
this.fttpTarget = fttpTarget;
8991
}
9092

93+
@Override
94+
public void afterPropertiesSet() throws Exception
95+
{
96+
try
97+
{
98+
logger.info(
99+
"Testing connection to fTTP with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, fttpServerBase: {}, fttpApiKey: {}, fttpStudy: {}, fttpTarget: {}}",
100+
trustStorePath, certificatePath, privateKeyPath, fttpServerBase, fttpApiKey, fttpStudy, fttpTarget);
101+
102+
getFttpClient().testConnection();
103+
}
104+
catch (Exception e)
105+
{
106+
logger.error("Error while testing connection to fTTP", e);
107+
}
108+
}
109+
91110
public FttpClient getFttpClient()
92111
{
93112
if (configured())
@@ -105,12 +124,15 @@ private boolean configured()
105124

106125
protected FttpClient createFttpClient()
107126
{
127+
logger.debug("Reading trust-store from {}", trustStorePath.toString());
108128
KeyStore trustStore = readTrustStore(trustStorePath);
109129
char[] keyStorePassword = UUID.randomUUID().toString().toCharArray();
130+
131+
logger.debug("Creating key-store from {} and {}", certificatePath.toString(), privateKeyPath.toString());
110132
KeyStore keyStore = readKeyStore(certificatePath, privateKeyPath, keyStorePassword);
111133

112-
return new FttpClientImpl(fhirContext, trustStore, keyStore, keyStorePassword, fttpServerBase, fttpApiKey,
113-
fttpStudy, fttpTarget);
134+
return new FttpClientImpl(trustStore, keyStore, keyStorePassword, fttpServerBase, fttpApiKey, fttpStudy,
135+
fttpTarget);
114136
}
115137

116138
private KeyStore readTrustStore(Path trustPath)

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/FttpClientImpl.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.regex.Matcher;
99
import java.util.regex.Pattern;
1010

11+
import org.hl7.fhir.r4.model.CapabilityStatement;
1112
import org.hl7.fhir.r4.model.Parameters;
1213
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
1314
import org.hl7.fhir.r4.model.StringType;
@@ -21,6 +22,7 @@
2122
import ca.uhn.fhir.rest.client.api.IGenericClient;
2223
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
2324
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
25+
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
2426

2527
public class FttpClientImpl implements FttpClient, InitializingBean
2628
{
@@ -34,27 +36,30 @@ public class FttpClientImpl implements FttpClient, InitializingBean
3436
private final String fttpTarget;
3537
private final String fttpApiKey;
3638

37-
public FttpClientImpl(FhirContext fhirContext, KeyStore trustStore, KeyStore keyStore, char[] keyStorePassword,
38-
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget)
39+
public FttpClientImpl(KeyStore trustStore, KeyStore keyStore, char[] keyStorePassword, String fttpServerBase,
40+
String fttpApiKey, String fttpStudy, String fttpTarget)
3941
{
40-
clientFactory = createClientFactory(fhirContext, trustStore, keyStore, keyStorePassword);
41-
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
42+
clientFactory = createClientFactory(trustStore, keyStore, keyStorePassword);
4243

4344
this.fttpServerBase = fttpServerBase;
4445
this.fttpApiKey = fttpApiKey;
4546
this.fttpStudy = fttpStudy;
4647
this.fttpTarget = fttpTarget;
4748
}
4849

49-
protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(FhirContext fhirContext, KeyStore trustStore,
50-
KeyStore keyStore, char[] keyStorePassword)
50+
protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(KeyStore trustStore, KeyStore keyStore,
51+
char[] keyStorePassword)
5152
{
52-
Objects.requireNonNull(fhirContext, "fhirContext");
5353
Objects.requireNonNull(trustStore, "trustStore");
5454
Objects.requireNonNull(keyStore, "keyStore");
5555
Objects.requireNonNull(keyStorePassword, "keyStorePassword");
5656

57-
return new ApacheRestfulClientFactoryWithTlsConfig(fhirContext, trustStore, keyStore, keyStorePassword);
57+
FhirContext fhirContext = FhirContext.forR4();
58+
ApacheRestfulClientFactoryWithTlsConfig hapiClientFactory = new ApacheRestfulClientFactoryWithTlsConfig(
59+
fhirContext, trustStore, keyStore, keyStorePassword);
60+
hapiClientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
61+
fhirContext.setRestfulClientFactory(hapiClientFactory);
62+
return hapiClientFactory;
5863
}
5964

6065
@Override
@@ -76,6 +81,7 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
7681
try
7782
{
7883
IGenericClient client = clientFactory.newGenericClient(fttpServerBase);
84+
client.registerInterceptor(new LoggingInterceptor());
7985

8086
Parameters parameters = client.operation().onServer().named("request-psn-workflow")
8187
.withParameters(createParameters(dicSourceAndPseudonym)).accept(Constants.CT_FHIR_XML_NEW)
@@ -125,4 +131,14 @@ protected Optional<String> getPseudonym(Parameters params)
125131

126132
return Optional.empty();
127133
}
134+
135+
@Override
136+
public void testConnection()
137+
{
138+
IGenericClient client = clientFactory.newGenericClient(fttpServerBase);
139+
CapabilityStatement statement = client.capabilities().ofType(CapabilityStatement.class).execute();
140+
141+
logger.info("Connection test OK {} - {}", statement.getSoftware().getName(),
142+
statement.getSoftware().getVersion());
143+
}
128144
}

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/spring/config/TransferDataConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ public FttpClientFactory fttpClientFactory()
134134
Path certificatePath = checkExists(fttpCertificate);
135135
Path privateKeyPath = checkExists(fttpPrivateKey);
136136

137-
return new FttpClientFactory(fhirContext, trustStorePath, certificatePath, privateKeyPath, fttpServerBase,
138-
fttpApiKey, fttpStudy, fttpTarget);
137+
return new FttpClientFactory(trustStorePath, certificatePath, privateKeyPath, fttpServerBase, fttpApiKey,
138+
fttpStudy, fttpTarget);
139139
}
140140

141141
@Bean

codex-process-data-transfer/src/main/resources/bpe/receive.bpmn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_18azqkl" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
3-
<bpmn:process id="dataReceive" isExecutable="true" camunda:versionTag="0.2.1">
3+
<bpmn:process id="dataReceive" isExecutable="true" camunda:versionTag="0.2.2">
44
<bpmn:startEvent id="DataReceiveMessageStartEvent" name="start data receive process">
55
<bpmn:outgoing>Flow_1gyqorb</bpmn:outgoing>
66
<bpmn:messageEventDefinition id="MessageEventDefinition_1qwi1k6" messageRef="Message_157qpi8" />

codex-process-data-transfer/src/main/resources/bpe/send.bpmn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_008keuw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
3-
<bpmn:process id="dataSend" isExecutable="true" camunda:versionTag="0.2.1">
3+
<bpmn:process id="dataSend" isExecutable="true" camunda:versionTag="0.2.2">
44
<bpmn:startEvent id="DataSendMessageStartEvent" name="start data send process">
55
<bpmn:outgoing>Flow_1km61ly</bpmn:outgoing>
66
<bpmn:messageEventDefinition id="MessageEventDefinition_07sumgd" messageRef="Message_0mcjkpi" />
@@ -22,7 +22,7 @@
2222
<bpmn:extensionElements>
2323
<camunda:inputOutput>
2424
<camunda:inputParameter name="processDefinitionKey">dataTranslate</camunda:inputParameter>
25-
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
25+
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
2626
<camunda:inputParameter name="messageName">startDataTranslate</camunda:inputParameter>
2727
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-translate</camunda:inputParameter>
2828
</camunda:inputOutput>

codex-process-data-transfer/src/main/resources/bpe/translate.bpmn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1davgtw" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
3-
<bpmn:process id="dataTranslate" isExecutable="true" camunda:versionTag="0.2.1">
3+
<bpmn:process id="dataTranslate" isExecutable="true" camunda:versionTag="0.2.2">
44
<bpmn:startEvent id="DataTranslateMessageStartEvent" name="start data translate process">
55
<bpmn:outgoing>Flow_185r1m5</bpmn:outgoing>
66
<bpmn:messageEventDefinition id="MessageEventDefinition_0nqjzhp" messageRef="Message_1nly3ld" />
@@ -25,7 +25,7 @@
2525
<bpmn:extensionElements>
2626
<camunda:inputOutput>
2727
<camunda:inputParameter name="processDefinitionKey">dataReceive</camunda:inputParameter>
28-
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
28+
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
2929
<camunda:inputParameter name="messageName">startDataReceive</camunda:inputParameter>
3030
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-receive</camunda:inputParameter>
3131
</camunda:inputOutput>

codex-process-data-transfer/src/main/resources/bpe/trigger.bpmn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1bd6yss" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
3-
<bpmn:process id="dataTrigger" isExecutable="true" camunda:versionTag="0.2.1">
3+
<bpmn:process id="dataTrigger" isExecutable="true" camunda:versionTag="0.2.2">
44
<bpmn:serviceTask id="FindNewData" name="find new data" camunda:class="de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.FindNewData">
55
<bpmn:incoming>Flow_0jy9ipp</bpmn:incoming>
66
<bpmn:outgoing>Flow_015mo33</bpmn:outgoing>
@@ -9,7 +9,7 @@
99
<bpmn:extensionElements>
1010
<camunda:inputOutput>
1111
<camunda:inputParameter name="processDefinitionKey">dataSend</camunda:inputParameter>
12-
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
12+
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
1313
<camunda:inputParameter name="messageName">startDataSend</camunda:inputParameter>
1414
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-send</camunda:inputParameter>
1515
</camunda:inputOutput>

0 commit comments

Comments
 (0)