/** * Builds the signature base string from the data this instance was * configured with. * * @return the signature base string * @throws OAuthMessageSignerException */ public String generate() throws OAuthMessageSignerException { try { String normalizedUrl = normalizeRequestUrl(); String normalizedParams = normalizeRequestParameters(); return request.getMethod() + '&' + OAuth.percentEncode(normalizedUrl) + '&' + OAuth.percentEncode(normalizedParams); } catch (Exception e) { throw new OAuthMessageSignerException(e); } }
params.put("realm", "www.example.com", true); params.put("oauth_signature", "12345", true); String result = new SignatureBaseString(httpGetMock, params).normalizeRequestParameters(); assertEquals("a=1", result); params.put("z", "t", true); String expected = "a=1&c=hi%20there&f=25&f=50&f=a&z=p&z=t"; result = new SignatureBaseString(httpGetMock, params).normalizeRequestParameters(); assertEquals(expected, result); params.put("a", "x y", true); expected = "a=x%20y&a=x%21y"; result = new SignatureBaseString(httpGetMock, params).normalizeRequestParameters(); assertEquals(expected, result); params.put("name", "", true); assertEquals("name=", new SignatureBaseString(httpGetMock, params) .normalizeRequestParameters()); params.putNull("name", null); assertEquals("name=", new SignatureBaseString(httpGetMock, params) .normalizeRequestParameters());
/** * Builds the signature base string from the data this instance was * configured with. * * @return the signature base string * @throws OAuthMessageSignerException */ public String generate() throws OAuthMessageSignerException { try { String normalizedUrl = normalizeRequestUrl(); String normalizedParams = normalizeRequestParameters(); return request.getMethod() + '&' + OAuth.percentEncode(normalizedUrl) + '&' + OAuth.percentEncode(normalizedParams); } catch (Exception e) { throw new OAuthMessageSignerException(e); } }