Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/0.2.2' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hhund committed Apr 7, 2021
2 parents c3828b4 + ffaa41a commit d1d5a65
Show file tree
Hide file tree
Showing 40 changed files with 193 additions and 72 deletions.
2 changes: 1 addition & 1 deletion codex-process-data-transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>de.netzwerk-universitaetsmedizin.codex</groupId>
<artifactId>codex-processes-ap1</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>
</parent>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class DataTransferProcessPluginDefinition implements ProcessPluginDefinition
{
public static final String VERSION = "0.2.1";
public static final String VERSION = "0.2.2";

@Override
public String getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.apache.http.impl.client.ProxyAuthenticationStrategy;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.ssl.SSLContexts;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
Expand All @@ -39,6 +41,8 @@

public class ApacheRestfulClientFactoryWithTlsConfig extends RestfulClientFactory
{
private static final Logger logger = LoggerFactory.getLogger(ApacheRestfulClientFactoryWithTlsConfig.class);

private HttpClient myHttpClient;
private HttpHost myProxy;

Expand All @@ -59,6 +63,8 @@ public ApacheRestfulClientFactoryWithTlsConfig(FhirContext fhirContext, KeyStore
@Override
protected synchronized ApacheHttpClient getHttpClient(String theServerBase)
{
logger.info("Returning new ApacheHttpClient for ServerNase {}", theServerBase);

return new ApacheHttpClient(getNativeHttpClient(), new StringBuilder(theServerBase), null, null, null, null);
}

Expand Down Expand Up @@ -91,7 +97,7 @@ public HttpClient getNativeHttpClient()
.setProxy(myProxy).build();

HttpClientBuilder builder = HttpClients.custom().setConnectionManager(connectionManager)
.setDefaultRequestConfig(defaultRequestConfig).disableCookieManagement();
.setSSLContext(sslContext).setDefaultRequestConfig(defaultRequestConfig).disableCookieManagement();

if (myProxy != null && StringUtils.isNotBlank(getProxyUsername())
&& StringUtils.isNotBlank(getProxyPassword()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;

Expand Down Expand Up @@ -70,16 +69,7 @@ public void storeBundle(Bundle bundle)
public PseudonymList getPseudonymsWithNewData(DateWithPrecision exportFrom, Date exportTo)
{
logger.warn("Returning demo pseudonyms for {}", localIdentifierValue);

List<String> pseudonyms;
if ("charite-tmptst.de".equals(localIdentifierValue))
pseudonyms = Arrays.asList("dic_berlin/dic_CT6E6", "dic_berlin/dic_9LDA5");
else if ("klinikum.uni-heidelberg.de".equals(localIdentifierValue))
pseudonyms = Arrays.asList("dic_heidelberg/dic_3YKQW", "dic_heidelberg/dic_RPRM3");
else
pseudonyms = Arrays.asList("foo/bar", "baz/qux");

return new PseudonymList(pseudonyms);
return new PseudonymList(Arrays.asList("dic_foo/bar", "dic_foo/baz"));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ public interface FttpClient
* @return
*/
Optional<String> getCrrPseudonym(String dicSourceAndPseudonym);

void testConnection();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@
import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import ca.uhn.fhir.context.FhirContext;
import de.rwh.utils.crypto.CertificateHelper;
import de.rwh.utils.crypto.io.CertificateReader;
import de.rwh.utils.crypto.io.PemIo;

public class FttpClientFactory
public class FttpClientFactory implements InitializingBean
{
private static final Logger logger = LoggerFactory.getLogger(FttpClientFactory.FttpClientStub.class);

private static final class FttpClientStub implements FttpClient
{
private static final Logger logger = LoggerFactory.getLogger(FttpClientStub.class);
Expand Down Expand Up @@ -59,9 +61,14 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
return Optional.empty();
}
}

@Override
public void testConnection()
{
logger.warn("Stub implementation, no connection test performed");
}
}

private final FhirContext fhirContext;
private final Path trustStorePath;
private final Path certificatePath;
private final Path privateKeyPath;
Expand All @@ -70,14 +77,9 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
private final String fttpStudy;
private final String fttpTarget;

public FttpClientFactory(FhirContext fhirContext, Path trustStorePath, Path certificatePath, Path privateKeyPath,
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget)
public FttpClientFactory(Path trustStorePath, Path certificatePath, Path privateKeyPath, String fttpServerBase,
String fttpApiKey, String fttpStudy, String fttpTarget)
{
if (fhirContext != null)
this.fhirContext = fhirContext;
else
this.fhirContext = FhirContext.forR4();

this.trustStorePath = trustStorePath;
this.certificatePath = certificatePath;
this.privateKeyPath = privateKeyPath;
Expand All @@ -88,6 +90,23 @@ public FttpClientFactory(FhirContext fhirContext, Path trustStorePath, Path cert
this.fttpTarget = fttpTarget;
}

@Override
public void afterPropertiesSet() throws Exception
{
try
{
logger.info(
"Testing connection to fTTP with {trustStorePath: {}, certificatePath: {}, privateKeyPath: {}, fttpServerBase: {}, fttpApiKey: {}, fttpStudy: {}, fttpTarget: {}}",
trustStorePath, certificatePath, privateKeyPath, fttpServerBase, fttpApiKey, fttpStudy, fttpTarget);

getFttpClient().testConnection();
}
catch (Exception e)
{
logger.error("Error while testing connection to fTTP", e);
}
}

public FttpClient getFttpClient()
{
if (configured())
Expand All @@ -105,12 +124,15 @@ private boolean configured()

protected FttpClient createFttpClient()
{
logger.debug("Reading trust-store from {}", trustStorePath.toString());
KeyStore trustStore = readTrustStore(trustStorePath);
char[] keyStorePassword = UUID.randomUUID().toString().toCharArray();

logger.debug("Creating key-store from {} and {}", certificatePath.toString(), privateKeyPath.toString());
KeyStore keyStore = readKeyStore(certificatePath, privateKeyPath, keyStorePassword);

return new FttpClientImpl(fhirContext, trustStore, keyStore, keyStorePassword, fttpServerBase, fttpApiKey,
fttpStudy, fttpTarget);
return new FttpClientImpl(trustStore, keyStore, keyStorePassword, fttpServerBase, fttpApiKey, fttpStudy,
fttpTarget);
}

private KeyStore readTrustStore(Path trustPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.hl7.fhir.r4.model.CapabilityStatement;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Parameters.ParametersParameterComponent;
import org.hl7.fhir.r4.model.StringType;
Expand All @@ -21,6 +22,7 @@
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.IRestfulClientFactory;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;

public class FttpClientImpl implements FttpClient, InitializingBean
{
Expand All @@ -34,27 +36,30 @@ public class FttpClientImpl implements FttpClient, InitializingBean
private final String fttpTarget;
private final String fttpApiKey;

public FttpClientImpl(FhirContext fhirContext, KeyStore trustStore, KeyStore keyStore, char[] keyStorePassword,
String fttpServerBase, String fttpApiKey, String fttpStudy, String fttpTarget)
public FttpClientImpl(KeyStore trustStore, KeyStore keyStore, char[] keyStorePassword, String fttpServerBase,
String fttpApiKey, String fttpStudy, String fttpTarget)
{
clientFactory = createClientFactory(fhirContext, trustStore, keyStore, keyStorePassword);
clientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
clientFactory = createClientFactory(trustStore, keyStore, keyStorePassword);

this.fttpServerBase = fttpServerBase;
this.fttpApiKey = fttpApiKey;
this.fttpStudy = fttpStudy;
this.fttpTarget = fttpTarget;
}

protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(FhirContext fhirContext, KeyStore trustStore,
KeyStore keyStore, char[] keyStorePassword)
protected ApacheRestfulClientFactoryWithTlsConfig createClientFactory(KeyStore trustStore, KeyStore keyStore,
char[] keyStorePassword)
{
Objects.requireNonNull(fhirContext, "fhirContext");
Objects.requireNonNull(trustStore, "trustStore");
Objects.requireNonNull(keyStore, "keyStore");
Objects.requireNonNull(keyStorePassword, "keyStorePassword");

return new ApacheRestfulClientFactoryWithTlsConfig(fhirContext, trustStore, keyStore, keyStorePassword);
FhirContext fhirContext = FhirContext.forR4();
ApacheRestfulClientFactoryWithTlsConfig hapiClientFactory = new ApacheRestfulClientFactoryWithTlsConfig(
fhirContext, trustStore, keyStore, keyStorePassword);
hapiClientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER);
fhirContext.setRestfulClientFactory(hapiClientFactory);
return hapiClientFactory;
}

@Override
Expand All @@ -76,6 +81,7 @@ public Optional<String> getCrrPseudonym(String dicSourceAndPseudonym)
try
{
IGenericClient client = clientFactory.newGenericClient(fttpServerBase);
client.registerInterceptor(new LoggingInterceptor());

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

return Optional.empty();
}

@Override
public void testConnection()
{
IGenericClient client = clientFactory.newGenericClient(fttpServerBase);
CapabilityStatement statement = client.capabilities().ofType(CapabilityStatement.class).execute();

logger.info("Connection test OK {} - {}", statement.getSoftware().getName(),
statement.getSoftware().getVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ public FttpClientFactory fttpClientFactory()
Path certificatePath = checkExists(fttpCertificate);
Path privateKeyPath = checkExists(fttpPrivateKey);

return new FttpClientFactory(fhirContext, trustStorePath, certificatePath, privateKeyPath, fttpServerBase,
fttpApiKey, fttpStudy, fttpTarget);
return new FttpClientFactory(trustStorePath, certificatePath, privateKeyPath, fttpServerBase, fttpApiKey,
fttpStudy, fttpTarget);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<bpmn:process id="dataReceive" isExecutable="true" camunda:versionTag="0.2.1">
<bpmn:process id="dataReceive" isExecutable="true" camunda:versionTag="0.2.2">
<bpmn:startEvent id="DataReceiveMessageStartEvent" name="start data receive process">
<bpmn:outgoing>Flow_1gyqorb</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_1qwi1k6" messageRef="Message_157qpi8" />
Expand Down
4 changes: 2 additions & 2 deletions codex-process-data-transfer/src/main/resources/bpe/send.bpmn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<bpmn:process id="dataSend" isExecutable="true" camunda:versionTag="0.2.1">
<bpmn:process id="dataSend" isExecutable="true" camunda:versionTag="0.2.2">
<bpmn:startEvent id="DataSendMessageStartEvent" name="start data send process">
<bpmn:outgoing>Flow_1km61ly</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_07sumgd" messageRef="Message_0mcjkpi" />
Expand All @@ -22,7 +22,7 @@
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="processDefinitionKey">dataTranslate</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
<camunda:inputParameter name="messageName">startDataTranslate</camunda:inputParameter>
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-translate</camunda:inputParameter>
</camunda:inputOutput>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<bpmn:process id="dataTranslate" isExecutable="true" camunda:versionTag="0.2.1">
<bpmn:process id="dataTranslate" isExecutable="true" camunda:versionTag="0.2.2">
<bpmn:startEvent id="DataTranslateMessageStartEvent" name="start data translate process">
<bpmn:outgoing>Flow_185r1m5</bpmn:outgoing>
<bpmn:messageEventDefinition id="MessageEventDefinition_0nqjzhp" messageRef="Message_1nly3ld" />
Expand All @@ -25,7 +25,7 @@
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="processDefinitionKey">dataReceive</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
<camunda:inputParameter name="messageName">startDataReceive</camunda:inputParameter>
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-receive</camunda:inputParameter>
</camunda:inputOutput>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<bpmn:process id="dataTrigger" isExecutable="true" camunda:versionTag="0.2.1">
<bpmn:process id="dataTrigger" isExecutable="true" camunda:versionTag="0.2.2">
<bpmn:serviceTask id="FindNewData" name="find new data" camunda:class="de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.service.FindNewData">
<bpmn:incoming>Flow_0jy9ipp</bpmn:incoming>
<bpmn:outgoing>Flow_015mo33</bpmn:outgoing>
Expand All @@ -9,7 +9,7 @@
<bpmn:extensionElements>
<camunda:inputOutput>
<camunda:inputParameter name="processDefinitionKey">dataSend</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.1</camunda:inputParameter>
<camunda:inputParameter name="versionTag">0.2.2</camunda:inputParameter>
<camunda:inputParameter name="messageName">startDataSend</camunda:inputParameter>
<camunda:inputParameter name="profile">http://netzwerk-universitaetsmedizin.de/fhir/StructureDefinition/task-start-data-send</camunda:inputParameter>
</camunda:inputOutput>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- status managed by bpe -->
<status value="unknown" />
<experimental value="false" />
<date value="2021-03-30" />
<date value="2021-04-07" />
<publisher value="NUM-CODEX" />
<contact>
<name value="NUM-CODEX" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- status managed by bpe -->
<status value="unknown" />
<experimental value="false" />
<date value="2021-03-30" />
<date value="2021-04-07" />
<publisher value="NUM-CODEX" />
<contact>
<name value="NUM-CODEX" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<!-- status managed by bpe -->
<status value="unknown" />
<experimental value="false" />
<date value="2021-03-30" />
<date value="2021-04-07" />
<publisher value="NUM-CODEX" />
<contact>
<name value="NUM-CODEX" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<!-- status managed by bpe -->
<status value="unknown" />
<experimental value="false" />
<date value="2021-03-30" />
<date value="2021-04-07" />
<publisher value="NUM-CODEX" />
<contact>
<name value="NUM-CODEX" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- status managed by bpe -->
<status value="unknown" />
<experimental value="false" />
<date value="2021-03-30" />
<date value="2021-04-07" />
<publisher value="NUM-CODEX" />
<description
value="CodeSystem with standard values for the NUM-CODEX data-transfer processes" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<name value="NUM-CODEX_CRR_Pseudonym_Identifier"/>
<status value="active" />
<kind value="identifier"/>
<date value="2021-03-30"/>
<date value="2021-04-07"/>
<publisher value="NUM-Codex"/>
<responsible value="THS Greifswald"/>
<description value="CODEX specific pseudonym"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<name value="NUM-CODEX_DIC_Pseudonym_Identifier"/>
<status value="active" />
<kind value="identifier"/>
<date value="2021-03-30"/>
<date value="2021-04-07"/>
<publisher value="NUM-Codex"/>
<responsible value="THS Greifswald"/>
<description value="DIZ specific pseudonym"/>
Expand Down
Loading

0 comments on commit d1d5a65

Please sign in to comment.