From d7ca57546442394c070d4c5f795a40546dea4dd3 Mon Sep 17 00:00:00 2001 From: Ernst-Christoph Schrewe Date: Tue, 10 Sep 2024 11:23:35 +0200 Subject: [PATCH] fix: initial commit --- .../MaterialPartnerRelationsController.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java index cba29c8a..bf342d3b 100644 --- a/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java +++ b/backend/src/main/java/org/eclipse/tractusx/puris/backend/masterdata/controller/MaterialPartnerRelationsController.java @@ -85,9 +85,13 @@ public ResponseEntity createMaterialPartnerRelation( example = "true") @RequestParam boolean partnerSupplies, @Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.", example = "true") @RequestParam boolean partnerBuys) { - - ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); - partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber)); + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber)); + } catch (Exception e) { + log.error("parameters were not properly encoded in base64"); + return new ResponseEntity<>(HttpStatusCode.valueOf(400)); + } if (!materialPattern.matcher(ownMaterialNumber).matches() || !materialPattern.matcher(partnerMaterialNumber).matches() || !bpnlPattern.matcher(partnerBpnl).matches()) { log.warn("Rejected message parameters. "); @@ -146,9 +150,14 @@ public ResponseEntity updateMaterialPartnerRelation( example = "true") @RequestParam(required = false) Boolean partnerSupplies, @Parameter(description = "This boolean flag indicates whether this Partner is a potential customer of this Material.", example = "true") @RequestParam(required = false) Boolean partnerBuys) { - ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + try { + ownMaterialNumber = new String(Base64.getDecoder().decode(ownMaterialNumber)); + partnerMaterialNumber = new String(Base64.getDecoder().decode(partnerMaterialNumber)); + } catch (Exception e) { + log.error("parameters were not properly encoded in base64"); + return new ResponseEntity<>(HttpStatusCode.valueOf(400)); + } MaterialPartnerRelation existingRelation = null; - if (!bpnlPattern.matcher(partnerBpnl).matches() || !materialPattern.matcher(ownMaterialNumber).matches() || (partnerMaterialNumber != null && !materialPattern.matcher(partnerMaterialNumber).matches())) { log.warn("Rejected message parameters. ");