Skip to content

Commit

Permalink
EPA-282
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-kontcur committed Oct 14, 2024
1 parent 7bf717f commit d1312a8
Show file tree
Hide file tree
Showing 21 changed files with 136 additions and 141 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice.
#Mon Oct 14 14:37:29 AMT 2024
#Mon Oct 14 16:33:30 AMT 2024
lib-cetp-1.0-SNAPSHOT.jar>=
lib-cetp-1.0-SNAPSHOT-sources.jar>=
lib-cetp-1.0-SNAPSHOT.pom>=
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
<version>4.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
<groupId>de.servicehealth</groupId>
<artifactId>lib-cetp</artifactId>
<versioning>
<lastUpdated>20241014103723</lastUpdated>
<lastUpdated>20241014123324</lastUpdated>
<snapshot>
<localCopy>true</localCopy>
</snapshot>
<snapshotVersions>
<snapshotVersion>
<extension>pom</extension>
<value>1.0-SNAPSHOT</value>
<updated>20241014103723</updated>
<updated>20241014123324</updated>
</snapshotVersion>
<snapshotVersion>
<extension>jar</extension>
<value>1.0-SNAPSHOT</value>
<updated>20241014103723</updated>
<updated>20241014123324</updated>
</snapshotVersion>
<snapshotVersion>
<classifier>sources</classifier>
<extension>jar</extension>
<value>1.0-SNAPSHOT</value>
<updated>20241014103723</updated>
<updated>20241014123324</updated>
</snapshotVersion>
</snapshotVersions>
</versioning>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<versions>
<version>1.0-SNAPSHOT</version>
</versions>
<lastUpdated>20241014103723</lastUpdated>
<lastUpdated>20241014123324</lastUpdated>
</versioning>
</metadata>
23 changes: 15 additions & 8 deletions src/main/java/health/ere/ps/config/RuntimeConfig.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
package health.ere.ps.config;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import de.health.service.cetp.config.IRuntimeConfig;
import de.health.service.cetp.config.IUserConfigurations;
import de.health.service.cetp.konnektorconfig.KCUserConfigurations;
import health.ere.ps.model.config.UserConfigurations;
import jakarta.enterprise.inject.Alternative;
import jakarta.enterprise.inject.spi.CDI;
import jakarta.json.JsonObject;
import jakarta.servlet.http.HttpServletRequest;

import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

@Alternative
public class RuntimeConfig extends UserConfig implements IRuntimeConfig {

Expand Down Expand Up @@ -102,7 +107,9 @@ public void updateConfigurationsWithHttpServletRequest(HttpServletRequest httpSe
this.sendPreview = !httpServletRequest.getHeader("X-sendPreview").equalsIgnoreCase("false");
}

this.updateProperties(this.getConfigurations().updateWithRequest(httpServletRequest));
IUserConfigurations userConfigurations = getConfigurations();
userConfigurations.updateWithRequest(httpServletRequest);
this.updateProperties(userConfigurations);
}

public void updateConfigurationsWithJsonObject(JsonObject object) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/health/ere/ps/config/SimpleUserConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void setIdpClientId(String idpClientId) {
}

private void setValues(UserRuntimeConfig userConfig) {
IUserConfigurations configurations = userConfig.getUserConfigurations();
IUserConfigurations configurations = userConfig.getConfigurations();
this.erixaHotfolder = configurations.getErixaHotfolder();
this.erixaDrugstoreEmail = configurations.getErixaDrugstoreEmail();
this.erixaUserEmail = configurations.getErixaUserEmail();
Expand Down
12 changes: 5 additions & 7 deletions src/main/java/health/ere/ps/config/UserConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package health.ere.ps.config;

import com.fasterxml.jackson.annotation.JsonIgnore;
import de.health.service.cetp.config.IRuntimeConfig;
import de.health.service.cetp.config.IUserConfigurations;
import de.health.service.cetp.config.UserRuntimeConfig;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class UserConfig implements UserRuntimeConfig {

String defaultMuster16TemplateProfile = "DENS";

private UserConfigurations configurations;
protected UserConfigurations configurations;

@PostConstruct
void init() {
Expand All @@ -60,10 +61,11 @@ public UserConfig() {
}

@Override
public IUserConfigurations getUserConfigurations() {
return configurations;
public IUserConfigurations getConfigurations() {
return configurations == null ? new UserConfigurations() : configurations;
}

@JsonIgnore
@Override
public IRuntimeConfig getRuntimeConfig() {
if (this instanceof RuntimeConfig runtimeConfig) {
Expand All @@ -80,10 +82,6 @@ public UserRuntimeConfig copy() {
return runtimeConfig;
}

public UserConfigurations getConfigurations() {
return configurations == null ? new UserConfigurations() : configurations;
}

public String getErixaHotfolder() {
return getConfigurations().getErixaHotfolder();
}
Expand Down
26 changes: 1 addition & 25 deletions src/main/java/health/ere/ps/model/config/UserConfigurations.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

@SuppressWarnings("unchecked")
public class UserConfigurations implements IUserConfigurations {

private static final Logger log = Logger.getLogger(UserConfigurations.class.getName());
Expand Down Expand Up @@ -129,27 +130,6 @@ public UserConfigurations(HttpServletRequest httpServletRequest) {
updateWithRequest(httpServletRequest);
}

public UserConfigurations updateWithRequest(HttpServletRequest httpServletRequest) {
Enumeration<String> enumeration = httpServletRequest.getHeaderNames();
List<String> list = Collections.list(enumeration);
for (String headerName : list) {
if (headerName.startsWith("X-") && !"X-eHBAHandle".equals(headerName) && !"X-SMCBHandle".equals(headerName) && !"X-sendPreview".equals(headerName)) {
String propertyName = headerName.substring(2);
Field field;
try {
field = UserConfigurations.class.getDeclaredField(propertyName);
if (field != null) {
field.set(this, httpServletRequest.getHeader(headerName));
}
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException |
IllegalAccessException e) {
log.log(Level.WARNING, "Could not extract values from header", e);
}
}
}
return this;
}

private void fillValues(Function<String, Object> getValue) {
for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
try {
Expand Down Expand Up @@ -181,10 +161,6 @@ public Properties properties() {
return properties;
}

public static BeanInfo getBeanInfo() {
return beanInfo;
}

public String getErixaHotfolder() {
return erixaHotfolder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void createSSLContext() {
}
}

public SSLContext createSSLContext(UserConfigurations userConfigurations) {
public SSLContext createSSLContext(IUserConfigurations userConfigurations) {
byte[] clientCertificateBytes = getClientCertificateBytes(userConfigurations);
try (ByteArrayInputStream certificateInputStream = new ByteArrayInputStream(clientCertificateBytes)) {
return createSSLContext(userConfigurations.getClientCertificatePassword(), certificateInputStream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void obtainConfiguration(boolean throwEndpointException) throws IOExcepti
.path("/connector.sds")
.request();

IUserConfigurations userConfigurations = userConfig.getUserConfigurations();
IUserConfigurations userConfigurations = userConfig.getConfigurations();
String basicAuthUsername = userConfigurations.getBasicAuthUsername();
String basicAuthPassword = userConfigurations.getBasicAuthPassword();
if(basicAuthUsername != null && !basicAuthUsername.equals("")) {
Expand Down Expand Up @@ -208,10 +208,10 @@ private void extractAndSetConnectorVersion(Document document) {

if (versionContainingText.contains("PTV4+") || versionContainingText.contains("PTV4Plus")) {
log.info("Connector version PTV4+ found in connector.sds");
userConfig.getUserConfigurations().setVersion("PTV4+");
userConfig.getConfigurations().setVersion("PTV4+");
} else if (versionContainingText.contains("PTV4")) {
log.info("Connector version PTV4 found in connector.sds");
userConfig.getUserConfigurations().setVersion("PTV4");
userConfig.getConfigurations().setVersion("PTV4");
} else {
log.warning("Could not determine the version of the connector to use from connector.sds, " +
"using the one from the configuration:" + userConfig.getConnectorVersion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private void configureBindingProvider(BindingProvider bindingProvider) {
bindingProvider.getRequestContext().put("com.sun.xml.ws.transport.https.client.hostname.verifier",
new SSLUtilities.FakeHostnameVerifier());

IUserConfigurations userConfigurations = getUserConfig().getUserConfigurations();
IUserConfigurations userConfigurations = getUserConfig().getConfigurations();
String basicAuthUsername = userConfigurations.getBasicAuthUsername();
String basicAuthPassword = userConfigurations.getBasicAuthPassword();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public SingleConnectorServicesProvider(UserRuntimeConfig userConfig, Event<Excep
this.secretsManagerService = new SecretsManagerService();

// Try to read SSL Certificates from the userConfig (this can also be the runtime config)
IUserConfigurations userConfigurations = userConfig.getUserConfigurations();
IUserConfigurations userConfigurations = userConfig.getConfigurations();
String configKeystoreUri = userConfigurations.getClientCertificate();
String configKeystorePass = userConfigurations.getClientCertificatePassword();

Expand Down
Loading

0 comments on commit d1312a8

Please sign in to comment.