From 52306ddf6e786bd1ceaba09cbe37b42778b715fe Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Fri, 28 Jun 2019 08:00:42 +0200 Subject: Simplified Config Validation - Also: Ensure that truststore is of type JKS because PKCS12 is not supported. --- .../at/gv/egiz/moazs/preprocess/ConfigUtil.java | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/main/java/at/gv') 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 14fb377..6c9d264 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java @@ -229,13 +229,11 @@ public class ConfigUtil { } private boolean isTVNZClientConfigured(ClientType tnvzClient, Boolean isPerformQueryPersonRequest) { - return (isPerformQueryPersonRequest - && tnvzClient != null - && tnvzClient.getURL() != null - && tnvzClient.getReceiveTimeout() != null - && tnvzClient.getConnectionTimeout() != null - && isSSLConfigured(tnvzClient)) - || !isPerformQueryPersonRequest; + return !isPerformQueryPersonRequest || (tnvzClient != null + && tnvzClient.getURL() != null + && tnvzClient.getReceiveTimeout() != null + && tnvzClient.getConnectionTimeout() != null + && isSSLConfigured(tnvzClient)); } private boolean isMSGClientConfigured(ClientType msgClientParams) { @@ -247,21 +245,23 @@ public class ConfigUtil { } private boolean isSSLConfigured(ClientType clientParams) { - return (clientParams.getURL().startsWith("https") - && clientParams.getSSL() != null + 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"); + && isTrustStoreConfigured(clientParams.getSSL().getTrustStore())); } private boolean isKeyStoreConfigured(KeyStoreType keyStore) { - return (keyStore != null - && keyStore.getPassword() != null + return keyStore == null || (keyStore.getPassword() != null && keyStore.getFileType() != null - && keyStore.getFileName() != null) - || keyStore == null; + && keyStore.getFileName() != null); + } + + private boolean isTrustStoreConfigured(KeyStoreType trustStore) { + return trustStore == null || (trustStore.getPassword() != null + && "JKS".equals(trustStore.getFileType()) + && trustStore.getFileName() != null); } -- cgit v1.2.3