From 6f45f3dec6616e88ef0f890a185e940cf8ba7de2 Mon Sep 17 00:00:00 2001 From: Daniel Anechitoaie Date: Wed, 26 Feb 2020 17:48:37 +0200 Subject: [PATCH] Fixed bug randomly introduced by SFCC and undocumented where they started requireing the credentials to be URLEncoded before they are used as Basic HTTP Auth --- pom.xml | 23 ++++--------------- findbugs-exclude.xml => spotbugs-exclude.xml | 0 .../dataimport/OpenCommerceAPI.java | 7 +++--- 3 files changed, 9 insertions(+), 21 deletions(-) rename findbugs-exclude.xml => spotbugs-exclude.xml (100%) diff --git a/pom.xml b/pom.xml index 4712946..d641a35 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.jenkins-ci.plugins plugin - 3.6 + 3.56 @@ -43,7 +43,7 @@ 1.8 8 - 2.107.1 + 2.164.1 @@ -65,23 +65,10 @@ - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.16 + com.github.spotbugs + spotbugs-maven-plugin - - org.codehaus.mojo.signature - java18 - 1.0 - - - - - org.codehaus.mojo - findbugs-maven-plugin - 3.0.5 - - findbugs-exclude.xml + spotbugs-exclude.xml diff --git a/findbugs-exclude.xml b/spotbugs-exclude.xml similarity index 100% rename from findbugs-exclude.xml rename to spotbugs-exclude.xml diff --git a/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/dataimport/OpenCommerceAPI.java b/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/dataimport/OpenCommerceAPI.java index a21fc49..80d07a9 100644 --- a/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/dataimport/OpenCommerceAPI.java +++ b/src/main/java/org/jenkinsci/plugins/osfbuildersuiteforsfcc/dataimport/OpenCommerceAPI.java @@ -46,6 +46,7 @@ import java.io.Reader; import java.io.StringReader; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.security.*; import java.security.cert.CertificateException; import java.security.cert.CertificateExpiredException; @@ -567,9 +568,9 @@ private AuthResponse auth() throws IOException { Base64.getEncoder().encodeToString( String.format( "%s:%s", - ocCredentials.getClientId(), - ocCredentials.getClientPassword().getPlainText() - ).getBytes(Consts.UTF_8) + URLEncoder.encode(ocCredentials.getClientId(), "UTF-8"), + URLEncoder.encode(ocCredentials.getClientPassword().getPlainText(), "UTF-8") + ).getBytes(StandardCharsets.UTF_8) ) ));