aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/moazs/scheme
diff options
context:
space:
mode:
authorChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-23 10:20:38 +0200
committerChristof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>2019-05-23 10:26:08 +0200
commit7665997a90c87a400f92ae9bf1ec6cc5a3099e16 (patch)
treef8a143a834a9204fbdfc64591ce0f61b60cb495b /src/main/java/at/gv/egiz/moazs/scheme
parent59a13bea5783aa666bcbcec793df19f129965ff3 (diff)
downloadmoa-zs-7665997a90c87a400f92ae9bf1ec6cc5a3099e16.tar.gz
moa-zs-7665997a90c87a400f92ae9bf1ec6cc5a3099e16.tar.bz2
moa-zs-7665997a90c87a400f92ae9bf1ec6cc5a3099e16.zip
MZS Schema Changes + Changes in Interface
- MZS cant reply with a msg:DeliveryRequestStatusType to a mzs:DeliveryRequest. Reason: unmarshalling a msg:DeliveryRequestStatusType with JAXB (after receiving the msg reply) breaks the signature in msg:DeliveryRequestStatusType. Why? Because JAXB marshalling tinkers with the namespaces and, as for the current state of knowledge, we cannot configure the JAXB marshaller to reconstruct a XML Document byte-by-byte such that a signature that went through this process can be verified successfully (see [1]). - For this reason, we revert back to mzs:DeliveryResponse and add new fields / remove obsolete fields / capture all changes between zusemsg 1.5.3 and zusemsg 2.0.0. - The easier solution would be to wrap and transmit signed data + signature in a binary (base64) container, such that apache cxf and other web service frameworks won't unmarshall them. This doesnt work because zusemsg 2.0.0 is final. app2mzs.xsd Changes in Detail : - Add DeliverySystem, ZSDeliveryID and GZ to MessageType (MessageType is the base type of DeliveryResponse.Success, -PartialSuccess, and -Error); Reason: It was added to zusemsg 2.0.0. - Add SignedDeliveryRequestStatus to MessageType. Reason: If msg returns signed reply, this element contains the reply as byte[] such that the signature does not break. - Add optional PreadvicenoteSend to ErrorType (because it was added in zusemsg 2.0.0) - Remove MZSDeliveryID from every instance because this ID does not exist anymore (moa zs does not maintain requests in a database). - Remove DocumentReference from ErrorType as it was removed from zusemsg 2.0.0. - Remove DeliveryConfirmation as node in DeliveryNotificiationType because it does not exist anymore in zusemsg 2.0.0; DeliveryConfirmation is also obsolete because all msg' replies are signed and need to be transferred to the sender application as a byte[], which is done by SignedDeliveryRequestStatus node in MessageType. - Remove DeliveryStatement as node in DeliveryNotificiationType because it does not exist anymore in zusemsg 2.0.0. Other Changes - Adapt codebase: MzsService returns mzs:DeliveryResponse. - Implement conversion from msg:DeliveryRequestStatus to mzs:DeliveryResponse. - Add store / retrieve interface to DeliveryRepository that stores signed delivery request statuses as byte[]. Temporary Changes - Disable integration tests which have external dependencies. [1] https://download.oracle.com/javaee-archive/jaxb.java.net/users/2007/03/6674.html Signed-off-by: Christof Rabensteiner <christof.rabensteiner@iaik.tugraz.at>
Diffstat (limited to 'src/main/java/at/gv/egiz/moazs/scheme')
-rw-r--r--src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java
new file mode 100644
index 0000000..67f3d13
--- /dev/null
+++ b/src/main/java/at/gv/egiz/moazs/scheme/Msg2MzsConverter.java
@@ -0,0 +1,75 @@
+package at.gv.egiz.moazs.scheme;
+
+import at.gv.zustellung.app2mzs.xsd.DeliveryResponseType;
+import at.gv.zustellung.app2mzs.xsd.ErrorType;
+import at.gv.zustellung.app2mzs.xsd.PartialSuccessType;
+import at.gv.zustellung.app2mzs.xsd.SuccessType;
+import at.gv.zustellung.msg.xsd.DeliveryAnswerType;
+import at.gv.zustellung.msg.xsd.DeliveryRequestStatusType;
+import org.springframework.stereotype.Component;
+
+import java.math.BigInteger;
+import java.util.Optional;
+
+import static at.gv.zustellung.app2mzs.xsd.DeliveryResponseType.deliveryResponseTypeBuilder;
+import static at.gv.zustellung.app2mzs.xsd.ErrorType.errorTypeBuilder;
+import static at.gv.zustellung.app2mzs.xsd.PartialSuccessType.partialSuccessTypeBuilder;
+import static at.gv.zustellung.app2mzs.xsd.SuccessType.successTypeBuilder;
+
+@Component
+public class Msg2MzsConverter {
+
+ public DeliveryResponseType convert(DeliveryRequestStatusType status, Optional<byte[]> signedStatus) {
+
+ var responseBuilder = deliveryResponseTypeBuilder();
+
+ if (status.getError() != null) {
+ responseBuilder.withError(convert(status.getError(), signedStatus));
+ } else if (status.getSuccess() != null) {
+ responseBuilder.withSuccess(convert(status.getSuccess(), signedStatus));
+ } else {
+ responseBuilder.withPartialSuccess(convert(status.getPartialSuccess(), signedStatus));
+ }
+
+ return responseBuilder.build();
+ }
+
+ private SuccessType convert(DeliveryRequestStatusType.Success success, Optional<byte[]> signedStatus) {
+ return successTypeBuilder()
+ .withAppDeliveryID(success.getAppDeliveryID())
+ .withDeliverySystem(success.getDeliverySystem())
+ .withGZ(success.getGZ())
+ .withZSDeliveryID(success.getZSDeliveryID())
+ .withSignedDeliveryRequestStatus(signedStatus.orElse(null))
+ .withRelayedViaERV(success.isRelayedViaERV())
+ .withDeliveryTimestamp(success.getDeliveryTimestamp())
+ .build();
+ }
+
+ private PartialSuccessType convert(DeliveryAnswerType answer, Optional<byte[]> signedStatus) {
+ return partialSuccessTypeBuilder()
+ .withAppDeliveryID(answer.getAppDeliveryID())
+ .withDeliverySystem(answer.getDeliverySystem())
+ .withGZ(answer.getGZ())
+ .withZSDeliveryID(answer.getZSDeliveryID())
+ .withSignedDeliveryRequestStatus(signedStatus.orElse(null))
+ .build();
+ }
+
+ private ErrorType convert(DeliveryRequestStatusType.Error error, Optional<byte[]> signedStatus) {
+ var builder = errorTypeBuilder()
+ .withAppDeliveryID(error.getAppDeliveryID())
+ .withDeliverySystem(error.getDeliverySystem())
+ .withGZ(error.getGZ())
+ .withZSDeliveryID(error.getZSDeliveryID())
+ .withSignedDeliveryRequestStatus(signedStatus.orElse(null))
+ .withPreAdviceNoteSent(error.getPreAdviceNoteSent())
+ .withCode(new BigInteger(error.getErrorInfo().getCode()));
+
+ if(error.getErrorInfo().getText() != null) builder.withText(error.getErrorInfo().getText());
+
+ return builder.build();
+ }
+
+
+}