aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/preprocess
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-27 14:41:51 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-06-27 14:47:22 +0200
commit9556dc6bd7e327dfbfc3c2d5228ad920ad7b9f8e (patch)
tree01db0a1c4c94c66118256e17ecdb821e04ed657c /src/main/java/at/gv/egiz/moazs/preprocess
parenta8e726382b0472ad030d7a579fe8d6878a216bd4 (diff)
downloadmoa-zs-9556dc6bd7e327dfbfc3c2d5228ad920ad7b9f8e.tar.gz
moa-zs-9556dc6bd7e327dfbfc3c2d5228ad920ad7b9f8e.tar.bz2
moa-zs-9556dc6bd7e327dfbfc3c2d5228ad920ad7b9f8e.zip
Inject Configurable HTTP Policies to MsgClient
- Refactor: Get rid of MsgClient, because MsgClientFactory can do all the work. - Add Connection Timeout and Request Timeout (Policies of HTTP Client) to mzs:DeliveryRequest/Config and application.yaml. - Update readme: Add JDK 12 Requirement
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess')
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java54
1 files changed, 41 insertions, 13 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
index aa86873..2392ce0 100644
--- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
+++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java
@@ -8,6 +8,7 @@ import at.gv.zustellung.app2mzs.xsd.SSLType;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
+import java.math.BigInteger;
import java.util.Map;
import static at.gv.zustellung.app2mzs.xsd.ClientType.clientTypeBuilder;
@@ -31,6 +32,8 @@ public class ConfigUtil {
public static final String FILENAME_KEY = "filename";
public static final String FILETYPE_KEY = "filetype";
public static final String PASSWORD_KEY = "password";
+ public static final String RECEIVE_TIMEOUT = "receive-timeout";
+ public static final String CONNECTION_TIMEOUT_KEY = "connection-timeout";
/**
@@ -69,11 +72,24 @@ public class ConfigUtil {
var url = clientParams.get(URL_KEY);
+ BigInteger connectionTimeout = clientParams.containsKey(CONNECTION_TIMEOUT_KEY)
+ ? new BigInteger(clientParams.get(CONNECTION_TIMEOUT_KEY))
+ : null;
+
+ BigInteger receiveTimeout = clientParams.containsKey(RECEIVE_TIMEOUT)
+ ? new BigInteger(clientParams.get(RECEIVE_TIMEOUT))
+ : null;
+
var sslParams = filterMapByPrefix(clientParams, SSL_KEY);
SSLType ssl = sslParams.isEmpty()
? null : buildSSL(sslParams);
- return clientTypeBuilder().withURL(url).withSSL(ssl).build();
+ return clientTypeBuilder()
+ .withURL(url)
+ .withSSL(ssl)
+ .withConnectionTimeout(connectionTimeout)
+ .withReceiveTimeout(receiveTimeout)
+ .build();
}
@@ -153,6 +169,14 @@ public class ConfigUtil {
builder.withSSL(merge(primary.getSSL(), fallback.getSSL()));
}
+ if (primary.getConnectionTimeout() != null) {
+ builder.withConnectionTimeout(primary.getConnectionTimeout());
+ }
+
+ if (primary.getReceiveTimeout() != null) {
+ builder.withConnectionTimeout(primary.getReceiveTimeout());
+ }
+
return builder.build();
}
@@ -207,24 +231,28 @@ public class ConfigUtil {
private boolean isTVNZClientConfigured(ClientType tnvzClient, Boolean isPerformQueryPersonRequest) {
return (tnvzClient != null
&& tnvzClient.getURL() != null
+ && tnvzClient.getReceiveTimeout() != null
+ && tnvzClient.getConnectionTimeout() != null
&& isSSLConfigured(tnvzClient))
|| isPerformQueryPersonRequest == false;
}
- private boolean isMSGClientConfigured(ClientType msgClient) {
- return msgClient != null
- && msgClient.getURL() != null
- && isSSLConfigured(msgClient);
+ private boolean isMSGClientConfigured(ClientType msgClientParams) {
+ return msgClientParams != null
+ && msgClientParams.getURL() != null
+ && isSSLConfigured(msgClientParams)
+ && msgClientParams.getReceiveTimeout() != null
+ && msgClientParams.getConnectionTimeout() != null;
}
- private boolean isSSLConfigured(ClientType params) {
- return (params.getURL().startsWith("https")
- && params.getSSL() != null
- && params.getSSL().isTrustAll() != null
- && params.getSSL().isLaxHostNameVerification() != null
- && isKeyStoreConfigured(params.getSSL().getKeyStore())
- && isKeyStoreConfigured(params.getSSL().getTrustStore()))
- || !params.getURL().startsWith("https");
+ private boolean isSSLConfigured(ClientType clientParams) {
+ return (clientParams.getURL().startsWith("https")
+ && clientParams.getSSL() != null
+ && clientParams.getSSL().isTrustAll() != null
+ && clientParams.getSSL().isLaxHostNameVerification() != null
+ && isKeyStoreConfigured(clientParams.getSSL().getKeyStore())
+ && isKeyStoreConfigured(clientParams.getSSL().getTrustStore()))
+ || !clientParams.getURL().startsWith("https");
}
private boolean isKeyStoreConfigured(KeyStoreType keyStore) {