Skip to content

Commit

Permalink
Merge pull request #580 from FraunhoferISST/fix/missingbase64decoding
Browse files Browse the repository at this point in the history
fix: missing base64 decoding in mpr controller
  • Loading branch information
tom-rm-meyer-ISST authored Oct 2, 2024
2 parents c3a5477 + d7ca575 commit a12db3e
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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. ");
Expand Down Expand Up @@ -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. ");
Expand Down

0 comments on commit a12db3e

Please sign in to comment.