From f2e1263702901581512131ea587fad7a2ba45baa Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Wed, 17 Jul 2019 13:17:21 +0200 Subject: Put MoaZSException on Diet & Handle Edge Cases Reason: MoaZSException (and: its builder) were used to collect intermediary results while stepping through the delivery request backend. These results were needed to generate meaningful responses towards the sender application in case of error. However, the builder sprawled over too many interfaces (e.g. DeliveryRequestBackend and TNVZHelper) and it became difficult to understand from where intermediary results originated. Solution: Put MoaZSException on diet: - Remove all DeliveryAnswer fields from MoaZSException and refactor code base to ensure that the removed fields get sourced by other means. - Remove Builder since amount of parameters is manageable. Refactor DeliveryRequestBackend: - Instead of passing down the builder and using MoaZSException as the only source for intermediary results, we collect available results at the outermost stack frame (DeliveryRequestBackend.accept) and only retrieve results via exception if those results appear somewhere down the stack frame (E.g. PredviceNoteSent). We collect available results with the "fallbackAnswerBuilder" and switch to the msg client response, once received. Refactor MsgResponseBackend: - Handle cases (response missing, binary response missing) properly. - Integrate changes from MsgResponse.generateError() Refactor TVNZHelper: - Remove MoaZSExceptionBuilder from all interfaces. Refactor MsgResponse.generateError: - Change interface such that it's more intuitive. - Implement NotificationResponse.generateError. - Implement RequestStatusResponse.generateError. Others: - Replace all invocations against MoaZSException.Builder. --- src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java') diff --git a/src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java b/src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java index f9bbeb3..874e4f4 100644 --- a/src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java +++ b/src/main/java/at/gv/egiz/moazs/backend/SignatureVerifier.java @@ -3,13 +3,13 @@ package at.gv.egiz.moazs.backend; import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.ISignatureVerificationService; import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.api.data.IXMLSignatureVerificationResponse; import at.gv.egiz.eid.authhandler.modules.sigverify.moasig.exceptions.MOASigServiceException; +import at.gv.egiz.moazs.MoaZSException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.function.Consumer; import static at.gv.egiz.moazs.MoaZSException.moaZSException; -import static at.gv.egiz.moazs.MoaZSException.moaZSExceptionBuilder; import static java.lang.String.format; public class SignatureVerifier implements Consumer { @@ -21,6 +21,8 @@ public class SignatureVerifier implements Consumer { private static final String CERT_CODE_ERROR_MSG = "Certificate chain is not valid: Check code was %d. "; private static final String MANIFEST_CODE_ERROR_MSG = "Signature Manifest is not valid: Check code was %d. "; private static final String XMLMANIFEST_CODE_ERROR_MSG = "XmlDSIGManifest is not valid: Check code was %d. "; + + //TODO: Dont make this multiline! private static final String XML_SIGNATURE_RESPONSE_TEMPLATE = " XmlDsigSubjectName: %s\n" + " SignatureManifestCheckCode: %s\n" + @@ -93,14 +95,12 @@ public class SignatureVerifier implements Consumer { var msg = builder.toString(); - if(msg.length() > 0) { + if(!msg.isEmpty()) { throw moaZSException(msg); } } catch (MOASigServiceException e) { - throw moaZSExceptionBuilder(MOASIG_SERVICE_ERROR_MSG) - .withCause(e) - .build(); + throw moaZSException(MOASIG_SERVICE_ERROR_MSG, e); } } -- cgit v1.2.3