@@ -92,19 +92,19 @@ private String encodedParams(long oauthTimestamp, String nonce, List<Param> form
9292 OAuthParameterSet allParameters = new OAuthParameterSet (allParametersSize );
9393
9494 // start with standard OAuth parameters we need
95- allParameters .add (KEY_OAUTH_CONSUMER_KEY , Utf8UrlEncoder .encodeQueryElement (consumerAuth .getKey ()));
96- allParameters .add (KEY_OAUTH_NONCE , Utf8UrlEncoder .encodeQueryElement (nonce ));
95+ allParameters .add (KEY_OAUTH_CONSUMER_KEY , Utf8UrlEncoder .percentEncodeQueryElement (consumerAuth .getKey ()));
96+ allParameters .add (KEY_OAUTH_NONCE , Utf8UrlEncoder .percentEncodeQueryElement (nonce ));
9797 allParameters .add (KEY_OAUTH_SIGNATURE_METHOD , OAUTH_SIGNATURE_METHOD );
9898 allParameters .add (KEY_OAUTH_TIMESTAMP , String .valueOf (oauthTimestamp ));
9999 if (userAuth .getKey () != null ) {
100- allParameters .add (KEY_OAUTH_TOKEN , Utf8UrlEncoder .encodeQueryElement (userAuth .getKey ()));
100+ allParameters .add (KEY_OAUTH_TOKEN , Utf8UrlEncoder .percentEncodeQueryElement (userAuth .getKey ()));
101101 }
102102 allParameters .add (KEY_OAUTH_VERSION , OAUTH_VERSION_1_0 );
103103
104104 if (formParams != null ) {
105105 for (Param param : formParams ) {
106106 // formParams are not already encoded
107- allParameters .add (Utf8UrlEncoder .encodeQueryElement (param .getName ()), Utf8UrlEncoder .encodeQueryElement (param .getValue ()));
107+ allParameters .add (Utf8UrlEncoder .percentEncodeQueryElement (param .getName ()), Utf8UrlEncoder .percentEncodeQueryElement (param .getValue ()));
108108 }
109109 }
110110 if (queryParams != null ) {
@@ -164,11 +164,11 @@ StringBuilder signatureBaseString(Request request, long oauthTimestamp, String n
164164 StringBuilder sb = StringUtils .stringBuilder ();
165165 sb .append (request .getMethod ()); // POST / GET etc (nothing to URL encode)
166166 sb .append ('&' );
167- Utf8UrlEncoder .encodeAndAppendQueryElement (sb , baseUrl );
167+ Utf8UrlEncoder .encodeAndAppendPercentEncoded (sb , baseUrl );
168168
169169 // and all that needs to be URL encoded (... again!)
170170 sb .append ('&' );
171- Utf8UrlEncoder .encodeAndAppendQueryElement (sb , encodedParams );
171+ Utf8UrlEncoder .encodeAndAppendPercentEncoded (sb , encodedParams );
172172 return sb ;
173173 }
174174
@@ -182,7 +182,7 @@ String calculateSignature(Request request, long oauthTimestamp, String nonce) {
182182 return Base64 .encode (rawSignature );
183183 }
184184
185- private String constructAuthHeader (String signature , String nonce , long oauthTimestamp ) {
185+ String constructAuthHeader (String signature , String nonce , long oauthTimestamp ) {
186186 StringBuilder sb = StringUtils .stringBuilder ();
187187 sb .append ("OAuth " );
188188 sb .append (KEY_OAUTH_CONSUMER_KEY ).append ("=\" " ).append (consumerAuth .getKey ()).append ("\" , " );
@@ -193,23 +193,23 @@ private String constructAuthHeader(String signature, String nonce, long oauthTim
193193
194194 // careful: base64 has chars that need URL encoding:
195195 sb .append (KEY_OAUTH_SIGNATURE ).append ("=\" " );
196- Utf8UrlEncoder .encodeAndAppendQueryElement (sb , signature ).append ("\" , " );
196+ Utf8UrlEncoder .encodeAndAppendPercentEncoded (sb , signature ).append ("\" , " );
197197 sb .append (KEY_OAUTH_TIMESTAMP ).append ("=\" " ).append (oauthTimestamp ).append ("\" , " );
198198
199199 // also: nonce may contain things that need URL encoding (esp. when using base64):
200200 sb .append (KEY_OAUTH_NONCE ).append ("=\" " );
201- Utf8UrlEncoder .encodeAndAppendQueryElement (sb , nonce );
201+ Utf8UrlEncoder .encodeAndAppendPercentEncoded (sb , nonce );
202202 sb .append ("\" , " );
203203
204204 sb .append (KEY_OAUTH_VERSION ).append ("=\" " ).append (OAUTH_VERSION_1_0 ).append ("\" " );
205205 return sb .toString ();
206206 }
207207
208- protected long generateTimestamp () {
208+ long generateTimestamp () {
209209 return System .currentTimeMillis () / 1000L ;
210210 }
211211
212- protected String generateNonce () {
212+ String generateNonce () {
213213 byte [] nonceBuffer = NONCE_BUFFER .get ();
214214 ThreadLocalRandom .current ().nextBytes (nonceBuffer );
215215 // let's use base64 encoding over hex, slightly more compact than hex or decimals
0 commit comments