@@ -29,36 +29,44 @@ public class OAuthSignature {
2929
3030 private OAuthSignature () {}
3131
32- public static Map <String , String > getAsMap (OAuthConfig config , String endpoint , HttpMethod httpMethod ) {
32+ public static Map <String , String > getAsMap (OAuthConfig config , String endpoint , HttpMethod httpMethod , Map < String , String > params ) {
3333 if (config == null || endpoint == null || httpMethod == null ) {
3434 return Collections .emptyMap ();
3535 }
36- Map <String ,String > params = new HashMap <>();
37- params .put (OAuthHeader .OAUTH_CONSUMER_KEY .getValue (), config .getConsumerKey ());
38- params .put (OAuthHeader .OAUTH_TIMESTAMP .getValue (), String .valueOf (System .currentTimeMillis () / 1000L ));
39- params .put (OAuthHeader .OAUTH_NONCE .getValue (), UUID .randomUUID ().toString ());
40- params .put (OAuthHeader .OAUTH_SIGNATURE_METHOD .getValue (), SIGNATURE_METHOD_HMAC_SHA256 );
36+ Map <String ,String > authParams = new HashMap <>();
37+ authParams .put (OAuthHeader .OAUTH_CONSUMER_KEY .getValue (), config .getConsumerKey ());
38+ authParams .put (OAuthHeader .OAUTH_TIMESTAMP .getValue (), String .valueOf (System .currentTimeMillis () / 1000L ));
39+ authParams .put (OAuthHeader .OAUTH_NONCE .getValue (), UUID .randomUUID ().toString ());
40+ authParams .put (OAuthHeader .OAUTH_SIGNATURE_METHOD .getValue (), SIGNATURE_METHOD_HMAC_SHA256 );
41+ authParams .putAll (params );
4142
4243 // WooCommerce specified param
4344 if (HttpMethod .DELETE .equals (httpMethod )) {
44- params .put (DELETE_PARAM_FORCE , Boolean .TRUE .toString ());
45+ authParams .put (DELETE_PARAM_FORCE , Boolean .TRUE .toString ());
4546 }
46- String oAuthSignature = generateOAuthSignature (config .getConsumerSecret (), endpoint , httpMethod , params );
47- params .put (OAuthHeader .OAUTH_SIGNATURE .getValue (), oAuthSignature );
48- return params ;
47+ String oAuthSignature = generateOAuthSignature (config .getConsumerSecret (), endpoint , httpMethod , authParams );
48+ authParams .put (OAuthHeader .OAUTH_SIGNATURE .getValue (), oAuthSignature );
49+ return authParams ;
4950 }
5051
51- public static String getAsQueryString (OAuthConfig config , String endpoint , HttpMethod httpMethod ) {
52+ public static Map <String , String > getAsMap (OAuthConfig config , String endpoint , HttpMethod httpMethod ) {
53+ return getAsMap (config , endpoint , httpMethod , Collections .emptyMap ());
54+ }
55+
56+ public static String getAsQueryString (OAuthConfig config , String endpoint , HttpMethod httpMethod , Map <String , String > params ) {
5257 if (config == null || endpoint == null || httpMethod == null ) {
5358 return "" ;
5459 }
55- Map <String , String > oauthParameters = getAsMap (config , endpoint , httpMethod );
60+ Map <String , String > oauthParameters = getAsMap (config , endpoint , httpMethod , params );
5661 String encodedSignature = oauthParameters .get (OAuthHeader .OAUTH_SIGNATURE .getValue ())
5762 .replace (SpecialSymbol .PLUS .getPlain (), SpecialSymbol .PLUS .getEncoded ());
5863 oauthParameters .put (OAuthHeader .OAUTH_SIGNATURE .getValue (), encodedSignature );
5964 return mapToString (oauthParameters , SpecialSymbol .EQUAL .getPlain (), SpecialSymbol .AMP .getPlain ());
6065 }
6166
67+ public static String getAsQueryString (OAuthConfig config , String endpoint , HttpMethod httpMethod ) {
68+ return getAsQueryString (config , endpoint , httpMethod , Collections .emptyMap ());
69+ }
6270
6371 private static String generateOAuthSignature (String customerSecret , String endpoint , HttpMethod httpMethod , Map <String , String > parameters ) {
6472 String signatureBaseString = getSignatureBaseString (endpoint , httpMethod .name (), parameters );
0 commit comments