OAuth { public static HttpParameters oauthHeaderToParamsMap(String oauthHeader) { HttpParameters params = new HttpParameters(); if (oauthHeader == null || !oauthHeader.startsWith("OAuth ")) { return params; } oauthHeader = oauthHeader.substring("OAuth ".length()); String[] elements = oauthHeader.split(","); for (String keyValuePair : elements) { String[] keyValue = keyValuePair.split("="); params.put(keyValue[0].trim(), keyValue[1].replace("\"", "").trim()); } return params; }  static String percentEncode(String s); static String percentDecode(String s); static void formEncode(Collection<T> parameters,
            OutputStream into); static String formEncode(Collection<T> parameters); static HttpParameters decodeForm(String form); static HttpParameters decodeForm(InputStream content); static Map<String, String> toMap(Collection<T> from); static final String safeToString(Object from); static boolean isEmpty(String str); static String addQueryParameters(String url, String... kvPairs); static String addQueryParameters(String url, Map<String, String> params); static String addQueryString(String url, String queryString); static String prepareOAuthHeader(String... kvPairs); static HttpParameters oauthHeaderToParamsMap(String oauthHeader); static String toHeaderElement(String name, String value); static void debugOut(String key, String value); static final String VERSION_1_0; static final String ENCODING; static final String FORM_ENCODED; static final String HTTP_AUTHORIZATION_HEADER; static final String OAUTH_CONSUMER_KEY; static final String OAUTH_TOKEN; static final String OAUTH_TOKEN_SECRET; static final String OAUTH_SIGNATURE_METHOD; static final String OAUTH_SIGNATURE; static final String OAUTH_TIMESTAMP; static final String OAUTH_NONCE; static final String OAUTH_VERSION; static final String OAUTH_CALLBACK; static final String OAUTH_CALLBACK_CONFIRMED; static final String OAUTH_VERIFIER; static final String OUT_OF_BAND; }
@Test public void shouldCorrectlyParseOAuthAuthorizationHeader() { String header = "OAuth realm=\"http: HttpParameters params = OAuth.oauthHeaderToParamsMap(header); assertEquals("http: assertEquals("oob", params.getFirst("oauth_callback")); }