private String getRequestTrace() { StringBuilder trace = new StringBuilder(); trace.append("\n==== Original request:\n"); trace.append(originalRequest); trace.append("\n===="); int i = 1; for (Pair<HttpRequest, HttpResponse> event : requestTrace) { trace.append("\n==== Sent request ").append(i).append(":\n"); if (event.one != null) { trace.append(filterSecrets(event.one.toString())); } trace.append("\n==== Received response ").append(i).append(":\n"); if (event.two != null) { trace.append(filterSecrets(event.two.toString())); } trace.append("\n===="); ++i; } return trace.toString(); }
private String getRequestTrace() { StringBuilder trace = new StringBuilder(); trace.append("\n==== Original request:\n"); trace.append(originalRequest); trace.append("\n===="); int i = 1; for (Pair<HttpRequest, HttpResponse> event : requestTrace) { trace.append("\n==== Sent request ").append(i).append(":\n"); if (event.one != null) { trace.append(filterSecrets(event.one.toString())); } trace.append("\n==== Received response ").append(i).append(":\n"); if (event.two != null) { trace.append(filterSecrets(event.two.toString())); } trace.append("\n===="); ++i; } return trace.toString(); }
private String getRequestTrace() { StringBuilder trace = new StringBuilder(); trace.append("\n==== Original request:\n"); trace.append(originalRequest); trace.append("\n===="); int i = 1; for (Pair<HttpRequest, HttpResponse> event : requestTrace) { trace.append("\n==== Sent request ").append(i).append(":\n"); if (event.one != null) { trace.append(filterSecrets(event.one.toString())); } trace.append("\n==== Received response ").append(i).append(":\n"); if (event.two != null) { trace.append(filterSecrets(event.two.toString())); } trace.append("\n===="); ++i; } return trace.toString(); }
@Test public void testStripSecretsFromRequestUrl() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/access?param=foo&openso" + "cial_owner_id=owner&opensocial_viewer_id=owner&opensocial_app_id=app&" + "oauth_session_handle" + "=http%3A%2F%2Fwww.example.com%2Fgadget.xml&oauth_version=1.0&oauth_timestamp=12" + "31461132&oauth_consumer_key=consumer&oauth_signature_method=HMAC-SHA1&oauth_nonce=1" + "231461160262578000&oauth_signature=HuFQ%2BRYTrRzcgsi3al6ld9Msvoo%3D")); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }
private String verifyStrip(String body) { HttpResponseBuilder resp = new HttpResponseBuilder() .setHttpStatusCode(200) .setHeader("Date", "Date: Fri, 09 Jan 2009 00:35:08 GMT") .setResponseString(body); String out = OAuthResponseParams.filterSecrets(resp.create().toString()); if (out.contains("oauth_token_secret")) { checkStringContains("should remove secret", out, "oauth_token_secret=REMOVED"); } if (out.contains("oauth_session_handle")) { checkStringContains("should remove handle", out, "oauth_session_handle=REMOVED"); } return out; }
@Test public void testStripSecretsFromRequestUrl() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/access?param=foo&openso" + "cial_owner_id=owner&opensocial_viewer_id=owner&opensocial_app_id=app&" + "oauth_session_handle" + "=http%3A%2F%2Fwww.example.com%2Fgadget.xml&oauth_version=1.0&oauth_timestamp=12" + "31461132&oauth_consumer_key=consumer&oauth_signature_method=HMAC-SHA1&oauth_nonce=1" + "231461160262578000&oauth_signature=HuFQ%2BRYTrRzcgsi3al6ld9Msvoo%3D")); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }
@Test public void testStripSecretsFromRequestUrl() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/access?param=foo&openso" + "cial_owner_id=owner&opensocial_viewer_id=owner&opensocial_app_id=app&" + "oauth_session_handle" + "=http%3A%2F%2Fwww.example.com%2Fgadget.xml&oauth_version=1.0&oauth_timestamp=12" + "31461132&oauth_consumer_key=consumer&oauth_signature_method=HMAC-SHA1&oauth_nonce=1" + "231461160262578000&oauth_signature=HuFQ%2BRYTrRzcgsi3al6ld9Msvoo%3D")); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }
private String verifyStrip(String body) { HttpResponseBuilder resp = new HttpResponseBuilder() .setHttpStatusCode(200) .setHeader("Date", "Date: Fri, 09 Jan 2009 00:35:08 GMT") .setResponseString(body); String out = OAuthResponseParams.filterSecrets(resp.create().toString()); if (out.contains("oauth_token_secret")) { checkStringContains("should remove secret", out, "oauth_token_secret=REMOVED"); } if (out.contains("oauth_session_handle")) { checkStringContains("should remove handle", out, "oauth_session_handle=REMOVED"); } return out; }
private String verifyStrip(String body) { HttpResponseBuilder resp = new HttpResponseBuilder() .setHttpStatusCode(200) .setHeader("Date", "Date: Fri, 09 Jan 2009 00:35:08 GMT") .setResponseString(body); String out = OAuthResponseParams.filterSecrets(resp.create().toString()); if (out.contains("oauth_token_secret")) { checkStringContains("should remove secret", out, "oauth_token_secret=REMOVED"); } if (out.contains("oauth_session_handle")) { checkStringContains("should remove handle", out, "oauth_session_handle=REMOVED"); } return out; }
@Test public void testStripSecretsFromRequestHeader() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/foo")); req.setHeader("Authorization", "OAuth opensocial_owner_id=\"owner\", opensocial_viewer_id=" + "\"owner\", opensocial_app_id=\"app\", opensocial_app_url=\"http%3A%2F%2Fwww.examp" + "le.com%2Fheader.xml\", oauth_version=\"1.0\", oauth_timestamp=\"1231461306\", oau" + "th_consumer_key=\"consumer\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce" + "=\"1231461308333563000\", oauth_session_handle=\"w0zAI1yN5ZRvmBX5kcVdra5%2BbZE%" + "3D\""); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }
@Test public void testStripSecretsFromRequestHeader() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/foo")); req.setHeader("Authorization", "OAuth opensocial_owner_id=\"owner\", opensocial_viewer_id=" + "\"owner\", opensocial_app_id=\"app\", opensocial_app_url=\"http%3A%2F%2Fwww.examp" + "le.com%2Fheader.xml\", oauth_version=\"1.0\", oauth_timestamp=\"1231461306\", oau" + "th_consumer_key=\"consumer\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce" + "=\"1231461308333563000\", oauth_session_handle=\"w0zAI1yN5ZRvmBX5kcVdra5%2BbZE%" + "3D\""); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }
@Test public void testStripSecretsFromRequestHeader() { HttpRequest req = new HttpRequest(Uri.parse("http://www.example.com/foo")); req.setHeader("Authorization", "OAuth opensocial_owner_id=\"owner\", opensocial_viewer_id=" + "\"owner\", opensocial_app_id=\"app\", opensocial_app_url=\"http%3A%2F%2Fwww.examp" + "le.com%2Fheader.xml\", oauth_version=\"1.0\", oauth_timestamp=\"1231461306\", oau" + "th_consumer_key=\"consumer\", oauth_signature_method=\"HMAC-SHA1\", oauth_nonce" + "=\"1231461308333563000\", oauth_session_handle=\"w0zAI1yN5ZRvmBX5kcVdra5%2BbZE%" + "3D\""); String filtered = OAuthResponseParams.filterSecrets(req.toString()); checkStringContains(filtered, "oauth_session_handle=REMOVED"); }