private Request sign(Request request, OAuthAccessor accessor) { try { final URI requestUri = request.getUri(); Preconditions.checkArgument(requestUri.normalize().getPath().equals(requestUri.getPath()), "Refusing to sign non-normalized URL: " + requestUri); OAuthMessage oauthMessage = accessor.newRequestMessage( request.getMethod().name(), requestUri.toString(), asOAuthParameters(request.getParameters()) ); log.debug("Signed request {}", oauthMessage); return new Request(request.getMethod(), requestUri, fromOAuthParameters(oauthMessage.getParameters())); } catch (net.oauth.OAuthException e) { throw new OAuthSigningException("Failed to sign the request", e); } catch (IOException e) { // this shouldn't happen as the message is not being read from any IO streams, but the OAuth library throws // these around like they're candy, but far less sweet and tasty. throw new RuntimeException(e); } catch (URISyntaxException e) { // this shouldn't happen unless the caller somehow passed us an invalid URI object throw new RuntimeException(e); } }