[REQ] Code Improvement suggestion for unnecessary character replacment in the Util.percentEncode.
Is your feature request related to a problem?
No
Describe the solution you'd like
The java class src/main/java/com/mastercard/developer/oauth/OAuth.java line 64 contains the below
// Signature
String signature = signSignatureBaseString(sbs, signingKey, charset);
oauthParams.put("oauth_signature", Util.percentEncode(signature, charset));
The method Util.percentEncode tries to replace the below characters
"+", "*" and "%7E"
I am aware the java.net.URLEncode.encode does replace "+" with "%2B" and replace space character with "+" character
The "signature" String is already base64 encoded which contains only from character 'A' to '0',.... '9'...'+','/', '='
see Base64 character table
The '+' will be already encoded by the URLEncoder so the three characters replacement in the Util java class as below
.replace("+", "%20")
.replace("*", "%2A")
.replace("%7E", "~");
Are not needed I think.
Describe alternatives you've considered
Please reconsider to remove the character replacement in the Util class com.mastercard.developer.oauth.Util line 32 to 34
Additional context
Do you recommend me to create a pull request (PR) to address the optimization issue mentioned above ?
Hi @alanmehio
Thanks for reporting this issue. You are welcome to create a PR with your suggested optimization, our team can review this.
Closing due to inactivity.