private MultiValueMap<String, String> readFormParameters(MediaType bodyType, byte[] bodyBytes) { if (bodyType != null && bodyType.equals(MediaType.APPLICATION_FORM_URLENCODED)) { String body; try { body = new String(bodyBytes, UTF8_CHARSET_NAME); } catch (UnsupportedEncodingException shouldntHappen) { throw new IllegalStateException(shouldntHappen); } return parseFormParameters(body); } else { return EmptyMultiValueMap.instance(); } }
private MultiValueMap<String, String> readFormParameters(MediaType bodyType, byte[] bodyBytes) { if (bodyType != null && bodyType.equals(MediaType.APPLICATION_FORM_URLENCODED)) { String body; try { body = new String(bodyBytes, UTF8_CHARSET_NAME); } catch (UnsupportedEncodingException shouldntHappen) { throw new IllegalStateException(shouldntHappen); } return parseFormParameters(body); } else { return EmptyMultiValueMap.instance(); } }
/** * Builds an authorization header from a request. * Expects that the request's query parameters are form-encoded. */ public String buildAuthorizationHeaderValue(HttpRequest request, byte[] body, OAuth1Credentials oauth1Credentials) { Map<String, String> oauthParameters = commonOAuthParameters(oauth1Credentials.getConsumerKey()); oauthParameters.put("oauth_token", oauth1Credentials.getAccessToken()); MultiValueMap<String, String> additionalParameters = union(readFormParameters(request.getHeaders().getContentType(), body), parseFormParameters(request.getURI().getRawQuery())); return buildAuthorizationHeaderValue(request.getMethod(), request.getURI(), oauthParameters, additionalParameters, oauth1Credentials.getConsumerSecret(), oauth1Credentials.getAccessTokenSecret()); }
/** * Builds an authorization header from a request. * Expects that the request's query parameters are form-encoded. */ public String buildAuthorizationHeaderValue(HttpRequest request, byte[] body, OAuth1Credentials oauth1Credentials) { Map<String, String> oauthParameters = commonOAuthParameters(oauth1Credentials.getConsumerKey()); oauthParameters.put("oauth_token", oauth1Credentials.getAccessToken()); MultiValueMap<String, String> additionalParameters = union(readFormParameters(request.getHeaders().getContentType(), body), parseFormParameters(request.getURI().getRawQuery())); return buildAuthorizationHeaderValue(request.getMethod(), request.getURI(), oauthParameters, additionalParameters, oauth1Credentials.getConsumerSecret(), oauth1Credentials.getAccessTokenSecret()); }