Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/129 stand alone validator 1.1.0.0 not working #132

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions codex-process-data-transfer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.0.11</version>
<version>6.1.6</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -181,7 +181,7 @@
commons-codec,commons-io,crypto-utils,jakarta.activation,jakarta.annotation-api,jakarta.ws.rs-api,jakarta.xml.bind-api,commons-compress,commons-lang3,commons-text,
httpclient,httpcore,log4j-api,log4j-core,log4j-slf4j2-impl,bcpkix-jdk18on,bcprov-jdk18on,bcutil-jdk18on,ucum,hk2-api,hk2-locator,hk2-utils,osgi-resource-locator,
aopalliance-repackaged,jakarta.inject-api,jersey-apache-connector,jersey-client,jersey-common,jersey-entity-filtering,jersey-hk2,jersey-media-jaxb,jersey-media-json-jackson,
dsf-bpe-process-api-v1,dsf-fhir-auth,dsf-fhir-rest-adapter,dsf-fhir-validation,dsf-openehr-model,jcl-over-slf4j,
dsf-bpe-process-api-v1,dsf-fhir-auth,dsf-fhir-rest-adapter,dsf-fhir-validation,dsf-openehr-model,jcl-over-slf4j,jackson-module-jakarta-xmlbind-annotations,
slf4j-api,spring-aop,spring-beans,spring-context,spring-core,spring-expression,spring-jcl,thymeleaf,unbescape,xpp3,xpp3_xpath
</includeArtifactIds>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.DataLogger;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.logging.ErrorLogger;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.config.ProxyConfig;
import dev.dsf.bpe.v1.documentation.ProcessDocumentation;

@Configuration
Expand Down Expand Up @@ -367,4 +368,11 @@ public ErrorLogger errorLogger()
{
return new ErrorLogger(api.getMailService(), sendValidationFailedMail, sendProcessFailedMail);
}

// for validation config
@Bean
public ProxyConfig proxyConfig()
{
return api.getProxyConfig();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import de.rwh.utils.crypto.CertificateHelper;
import de.rwh.utils.crypto.io.CertificateReader;
import de.rwh.utils.crypto.io.PemIo;
import dev.dsf.bpe.v1.ProcessPluginApi;
import dev.dsf.bpe.v1.config.ProxyConfig;
import dev.dsf.bpe.v1.documentation.ProcessDocumentation;
import dev.dsf.fhir.validation.SnapshotGenerator;
import dev.dsf.fhir.validation.ValueSetExpander;
Expand All @@ -66,9 +66,6 @@ public class ValidationConfig
{
private static final Logger logger = LoggerFactory.getLogger(ValidationConfig.class);

@Autowired
private ProcessPluginApi api;

public static enum TerminologyServerConnectionTestStatus
{
OK, NOT_OK, DISABLED
Expand Down Expand Up @@ -209,6 +206,9 @@ public static enum TerminologyServerConnectionTestStatus
@Autowired
private ObjectMapper objectMapper;

// not using process plugin api to enable reuse of this config class in stand-alone validator
@Autowired
private ProxyConfig proxyConfig;

@Bean
public ValidationPackageManager validationPackageManager()
Expand Down Expand Up @@ -376,11 +376,11 @@ private ValidationPackageClientJersey validationPackageClientJersey()

String proxyUrl = null, proxyUsername = null;
char[] proxyPassword = null;
if (api.getProxyConfig().isEnabled() && !api.getProxyConfig().isNoProxyUrl(packageServerBaseUrl))
if (proxyConfig.isEnabled() && !proxyConfig.isNoProxyUrl(packageServerBaseUrl))
{
proxyUrl = api.getProxyConfig().getUrl();
proxyUsername = api.getProxyConfig().getUsername();
proxyPassword = api.getProxyConfig().getPassword() == null ? null : api.getProxyConfig().getPassword();
proxyUrl = proxyConfig.getUrl();
proxyUsername = proxyConfig.getUsername();
proxyPassword = proxyConfig.getPassword() == null ? null : proxyConfig.getPassword();
}

KeyStore packageClientTrustStore = trustStore("FHIR package client", packageClientTrustCertificates);
Expand Down Expand Up @@ -439,11 +439,11 @@ private ValueSetExpansionClient valueSetExpansionClientJersey()

String proxyUrl = null, proxyUsername = null;
char[] proxyPassword = null;
if (api.getProxyConfig().isEnabled() && !api.getProxyConfig().isNoProxyUrl(valueSetExpansionServerBaseUrl))
if (proxyConfig.isEnabled() && !proxyConfig.isNoProxyUrl(valueSetExpansionServerBaseUrl))
{
proxyUrl = api.getProxyConfig().getUrl();
proxyUsername = api.getProxyConfig().getUsername();
proxyPassword = api.getProxyConfig().getPassword() == null ? null : api.getProxyConfig().getPassword();
proxyUrl = proxyConfig.getUrl();
proxyUsername = proxyConfig.getUsername();
proxyPassword = proxyConfig.getPassword() == null ? null : proxyConfig.getPassword();
}

KeyStore valueSetExpansionClientTrustStore = trustStore("ValueSet expansion client",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.validation;

import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.hl7.fhir.instance.model.api.IBaseResource;
Expand Down Expand Up @@ -36,6 +39,8 @@
import ca.uhn.fhir.validation.ValidationResult;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ValidationConfig;
import de.netzwerk_universitaetsmedizin.codex.processes.data_transfer.spring.config.ValidationConfig.TerminologyServerConnectionTestStatus;
import dev.dsf.bpe.v1.config.ProxyConfig;
import dev.dsf.bpe.v1.documentation.ProcessDocumentation;

public class ValidationMain implements InitializingBean
{
Expand Down Expand Up @@ -73,6 +78,22 @@ public static class TestConfig
@Value("${de.netzwerk.universitaetsmedizin.rdp.validation.output.pretty:true}")
private boolean outputPretty;

@ProcessDocumentation(description = "Forward (http/https) proxy url, use *DEV_DSF_BPE_PROXY_NOPROXY* to list domains that do not require a forward proxy", example = "http://proxy.foo:8080")
@Value("${de.netzwerk.universitaetsmedizin.rdp.validation.proxy.url:#{null}}")
private String proxyUrl;

@ProcessDocumentation(description = "Forward proxy username", recommendation = "Configure username if proxy requires authentication")
@Value("${de.netzwerk.universitaetsmedizin.rdp.validation.proxy.username:#{null}}")
private String proxyUsername;

@ProcessDocumentation(description = "Forward Proxy password", recommendation = "Configure password if proxy requires authentication, use docker secret file to configure using *${env_variable}_FILE*")
@Value("${de.netzwerk.universitaetsmedizin.rdp.validation.proxy.password:#{null}}")
private char[] proxyPassword;

@ProcessDocumentation(description = "Forward proxy no-proxy list, entries will match exactly or agianst (one level) sub-domains, if no port is specified - all ports are matched; comma or space separated list, YAML block scalars supported", example = "foo.bar, test.com:8080")
@Value("#{'${de.netzwerk.universitaetsmedizin.rdp.validation.proxy.noProxy:}'.trim().split('(,[ ]?)|(\\n)')}")
private List<String> proxyNoProxy;

@Autowired
private ValidationPackageManager packageManager;

Expand All @@ -86,15 +107,15 @@ public static class TestConfig
private ConfigurableEnvironment environment;

@Bean
public ObjectMapper getObjectMapper()
public ObjectMapper objectMapper()
{
return JsonMapper.builder().serializationInclusion(Include.NON_NULL)
.serializationInclusion(Include.NON_EMPTY).disable(MapperFeature.AUTO_DETECT_CREATORS)
.disable(MapperFeature.AUTO_DETECT_FIELDS).disable(MapperFeature.AUTO_DETECT_SETTERS).build();
}

@Bean
public FhirContext getFhirContext()
public FhirContext fhirContext()
{
FhirContext context = FhirContext.forR4();
HapiLocalizer localizer = new HapiLocalizer()
Expand All @@ -109,11 +130,91 @@ public Locale getLocale()
return context;
}

@Bean
public ProxyConfig proxyConfig()
{
return new ProxyConfig()
{
@Override
public boolean isNoProxyUrl(String targetUrl)
{
if (proxyNoProxy.contains("*"))
return true;

if (targetUrl == null || targetUrl.isBlank())
return false;

try
{
URI u = new URI(targetUrl);

String host = u.getHost();
if (host == null)
{
logger.debug("Given targetUrl '{}' is malformed, no host value", targetUrl);
return false;
}

String subHost = Stream.of(u.getHost().split("\\.")).skip(1).collect(Collectors.joining("."));
int port = u.getPort() == -1 ? getDefaultPort(u.getScheme()) : u.getPort();

return proxyNoProxy.stream().anyMatch(s -> s.equals(host) || s.equals(host + ":" + port)
|| s.equals(subHost) || s.equals(subHost + ":" + port));
}
catch (URISyntaxException e)
{
logger.debug("Given targetUrl '{}' is malformed: {}", targetUrl, e.getMessage());
return false;
}
}

private int getDefaultPort(String scheme)
{
return switch (scheme)
{
case "http", "ws" -> 80;
case "https", "wss" -> 443;
default -> throw new IllegalArgumentException("Schema " + scheme + " not supported");
};
}

@Override
public boolean isEnabled()
{
return getUrl() != null;
}

@Override
public String getUsername()
{
return proxyUsername;
}

@Override
public String getUrl()
{
return proxyUrl;
}

@Override
public char[] getPassword()
{
return proxyPassword;
}

@Override
public List<String> getNoProxyUrls()
{
return proxyNoProxy;
}
};
}

@Bean
public ValidationMain validatorMain()
{
return new ValidationMain(environment, getFhirContext(), packageManager, validationPackageIdentifiers,
output, outputPretty, valueSetExpansionClient);
return new ValidationMain(environment, fhirContext(), packageManager, validationPackageIdentifiers, output,
outputPretty, valueSetExpansionClient);
}
}

Expand Down
12 changes: 6 additions & 6 deletions codex-processes-ap1-docker-test-setup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ services:


dic-fhir:
image: ghcr.io/datasharingframework/fhir:1.5.0
image: ghcr.io/datasharingframework/fhir:1.5.1
restart: "no"
ports:
- 127.0.0.1:5000:5000
Expand Down Expand Up @@ -136,7 +136,7 @@ services:
- db
- proxy
dic-bpe:
image: ghcr.io/datasharingframework/bpe:1.5.0
image: ghcr.io/datasharingframework/bpe:1.5.1
restart: "no"
ports:
- 127.0.0.1:5003:5003
Expand Down Expand Up @@ -232,7 +232,7 @@ services:


dts-fhir:
image: ghcr.io/datasharingframework/fhir:1.5.0
image: ghcr.io/datasharingframework/fhir:1.5.1
restart: "no"
ports:
- 127.0.0.1:5001:5001
Expand Down Expand Up @@ -293,7 +293,7 @@ services:
- db
- proxy
dts-bpe:
image: ghcr.io/datasharingframework/bpe:1.5.0
image: ghcr.io/datasharingframework/bpe:1.5.1
restart: "no"
ports:
- 127.0.0.1:5004:5004
Expand Down Expand Up @@ -356,7 +356,7 @@ services:


crr-fhir:
image: ghcr.io/datasharingframework/fhir:1.5.0
image: ghcr.io/datasharingframework/fhir:1.5.1
restart: "no"
ports:
- 127.0.0.1:5002:5002
Expand Down Expand Up @@ -417,7 +417,7 @@ services:
- db
- proxy
crr-bpe:
image: ghcr.io/datasharingframework/bpe:1.5.0
image: ghcr.io/datasharingframework/bpe:1.5.1
restart: "no"
ports:
- 127.0.0.1:5005:5005
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<main.basedir>${project.basedir}</main.basedir>
<hapi.version>5.1.0</hapi.version>
<dsf.version>1.5.0</dsf.version>
<dsf.version>1.5.1</dsf.version>
</properties>

<description>Business processes for the NUM RDP project (AP1) as plugins for the Data Sharing Framework.</description>
Expand Down
Loading