diff options
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess')
3 files changed, 74 insertions, 2 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java index d651570..5e81f0d 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java @@ -1,7 +1,6 @@ package at.gv.egiz.moazs.preprocess; import at.gv.egiz.moazs.MoaZSException; -import at.gv.egiz.moazs.scheme.MzsDeliveryRequestValidator; import at.gv.egiz.moazs.util.StringUtils; import at.gv.zustellung.app2mzs.xsd.ConfigType; import org.slf4j.Logger; diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java b/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java index 783536c..eac7ea6 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java @@ -1,6 +1,5 @@ package at.gv.egiz.moazs.preprocess; -import at.gv.egiz.moazs.scheme.MzsDeliveryRequestValidator; import at.gv.zustellung.app2mzs.xsd.ConfigType; import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java b/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java new file mode 100644 index 0000000..8f9cd27 --- /dev/null +++ b/src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java @@ -0,0 +1,74 @@ +package at.gv.egiz.moazs.preprocess; + +import at.gv.zustellung.app2mzs.xsd.ClientType; +import at.gv.zustellung.app2mzs.xsd.ConfigType; +import at.gv.zustellung.app2mzs.xsd.DeliveryRequestType; +import at.gv.zustellung.app2mzs.xsd.KeyStoreType; +import org.springframework.lang.Nullable; +import org.springframework.stereotype.Component; + +@Component +public class MzsDeliveryRequestValidator { + + /** + * Checks if the mandatory fields that are needed to send a tnvz:QueryPersonRequest are present. + * @param request + * @return true if mandatory fields are present. + */ + public boolean isTnvzComplete(DeliveryRequestType request) { + return !request.getConfig().isPerformQueryPersonRequest() || + (request.getTnvzMetaData() != null + && request.getSender().getCorporateBody() != null); + + + } + + /** + * Check if all mandatory fields of configuration are present. + * + * @param profile + * @return true if all mandatory fields are present. + */ + public boolean isConfigProfileComplete(@Nullable ConfigType profile) { + return profile != null + && profile.isPerformQueryPersonRequest() != null + && isTVNZClientConfigured(profile.getTNVZClient(), profile.isPerformQueryPersonRequest()) + && isMSGClientConfigured(profile.getMSGClient()); + } + + private boolean isTVNZClientConfigured(ClientType tnvzClient, Boolean isPerformQueryPersonRequest) { + return !isPerformQueryPersonRequest || (tnvzClient != null + && tnvzClient.getURL() != null + && tnvzClient.getReceiveTimeout() != null + && tnvzClient.getConnectionTimeout() != null + && isSSLConfigured(tnvzClient)); + } + + private boolean isMSGClientConfigured(ClientType msgClientParams) { + return msgClientParams != null + && msgClientParams.getURL() != null + && isSSLConfigured(msgClientParams) + && msgClientParams.getReceiveTimeout() != null + && msgClientParams.getConnectionTimeout() != null; + } + + 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()) + && isTrustStoreConfigured(clientParams.getSSL().getTrustStore())); + } + + private boolean isKeyStoreConfigured(KeyStoreType keyStore) { + return keyStore == null || (keyStore.getPassword() != null + && keyStore.getFileType() != null + && keyStore.getFileName() != null); + } + + private boolean isTrustStoreConfigured(KeyStoreType trustStore) { + return trustStore == null || (trustStore.getPassword() != null + && "JKS".equals(trustStore.getFileType()) + && trustStore.getFileName() != null); + } +} |