aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/preprocess
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-08 18:02:37 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-07-08 18:02:37 +0200
commitc1a1a5130a4ecf755da72941ad3525beb919447f (patch)
treeecaca5da80571e10f25186402ee73d8e062d4544 /src/main/java/at/gv/egiz/moazs/preprocess
parent78f0715d86a055aed11138df5f66b0794e72326a (diff)
downloadmoa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.tar.gz
moa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.tar.bz2
moa-zs-c1a1a5130a4ecf755da72941ad3525beb919447f.zip
Implement Zuse2App Services
- Add zuse2app.wsdl contract. - Add MsgResponse as an type-agnostic view for DeliveryRequestStatus and DeliveryNotification messages. Reason: Both DeliveryNotification and DeliveryRequestStatus messages have similar fields and need to be treated similarly (e.g.: receive from msg service, store to repository, verify signature, store to file...). In order to prevent duplicated code, the wrapper interface provides a type-agnostic view onto these messages for depending components to operate on. - Add MsgResponseHandler interface; decides how to process MsgResponse. Also implement this handler with a multi-threaded single-node implementation. - Add MsgResponseSink interface; decides how to archive MsgResponse. - Implement and test SafeResponseToFileSink. Change Identifier for MsgResponses: - Before, DeliveryRequestStatus and DeliveryNotifications had their own repositories. Now, both types are stored in the same repository (the MsgResponse repository) to streamline the handling of MsgResponses. We need to change the identification of MsgReponses, otherwise the identifiers (AppDeliveryID) clash. - MsgResponses are not identified by: <AppDeliveryId>+<typeSpecificSuffix> - Rewrite StoreSOAPInterceptor to accommodate fact that, both DeliveryRequestStatus and DeliveryNotification messages have different IDs upon storage / retrieval. Restructure packages and components as follows: - client: All components that are involved when consuming a web service. - process: "fabric" of MoaZS; contains business logic that orchestrates back-end tasks of MoaZS's operational services, e.g.: by processing a delivery request. - service: Implementation of MoaZS's front-end services. Refactoring: - MoaZSException: Remove unused fields. Before: Store mzsrequest, tnvzresult, msgrequest and msgresult as members. Now: Only keep the fields that are needed later, e.g for generating a msg:DeliveryRequestStatus element. Add copy constructor to Builder. - Put storage of byte[] into a dedicated "BinaryRepository". Reason: This was useful in a former design. Now it's not really needed anymore. - Put "create Endpoint" code into EndpointFactory. Reason: Eliminate duplicated code when configuring a service. Testing: - Activate Stacktraces in surefire.
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/preprocess')
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/ConfigProfileGenerator.java1
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/DeliveryRequestAugmenter.java1
-rw-r--r--src/main/java/at/gv/egiz/moazs/preprocess/MzsDeliveryRequestValidator.java74
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);
+ }
+}