GitHub PullRequestReviewCommentEvent at 2014-07-15 21:42:53
Repository: thali
Actor: yaronyg
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/thaliproject/thali/pulls/comments/14965581","id":14965581,"diff_hunk":"@@ -0,0 +1,310 @@\n+/*\n+Copyright (c) Microsoft Open Technologies, Inc.\n+All Rights Reserved\n+Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the\n+License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0\n+\n+THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,\n+INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\n+MERCHANTABLITY OR NON-INFRINGEMENT.\n+\n+See the Apache 2 License for the specific language governing permissions and limitations under the License.\n+*/\n+\n+package com.msopentech.thali.relay;\n+\n+import com.msopentech.thali.CouchDBListener.ThaliListener;\n+import com.msopentech.thali.utilities.universal.*;\n+\n+import org.apache.commons.io.IOUtils;\n+import org.apache.commons.lang3.exception.ExceptionUtils;\n+import org.apache.http.Header;\n+import org.apache.http.HttpHost;\n+import org.apache.http.HttpResponse;\n+import org.apache.http.client.HttpClient;\n+import org.apache.http.entity.StringEntity;\n+import org.apache.http.message.BasicHttpEntityEnclosingRequest;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.io.File;\n+import java.security.*;\n+import java.util.HashMap;\n+import java.util.Map;\n+import java.io.*;\n+import java.util.Scanner;\n+\n+import com.msopentech.thali.nanohttp.NanoHTTPD;\n+\n+public class RelayWebServer extends NanoHTTPD {\n+\n+    // Host and port for the relay\n+    public static final String relayHost = \"localhost\";\n+    public static final int relayPort = 58000;\n+\n+    // Host and port for the TDH\n+    private final String thaliDeviceHubHost = \"localhost\";\n+    private int thaliDeviceHubPort;\n+\n+    private final KeyStore keyStore;\n+    private final CreateClientBuilder createClientBuilder;\n+    private final PublicKey serverPublicKey;\n+\n+    private final Logger Log = LoggerFactory.getLogger(RelayWebServer.class);\n+\n+    public RelayWebServer(CreateClientBuilder clientBuilder, File keystoreDirectory) throws UnrecoverableEntryException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException {\n+         this(clientBuilder, keystoreDirectory, ThaliListener.DefaultThaliDeviceHubPort);\n+    }\n+\n+    public RelayWebServer(CreateClientBuilder clientBuilder, File keystoreDirectory, int thaliDeviceHubPort) throws UnrecoverableEntryException, KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException {\n+        super(relayHost, relayPort);\n+\n+        this.thaliDeviceHubPort = thaliDeviceHubPort;\n+\n+        keyStore = ThaliCryptoUtilities.getThaliKeyStoreByAnyMeansNecessary(keystoreDirectory);\n+        createClientBuilder = clientBuilder;\n+\n+        // Retrieve server public key\n+        serverPublicKey = RetrieveServerPublicKey();\n+\n+        // Prepare client public key\n+        PrepareClientPublicKey();\n+\n+        Log.info(\"RelayWebServer initialized\");\n+    }\n+\n+\n+    // Simplifies unit testing\n+    public HTTPSession createSession(TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) {\n+        return new HTTPSession(tempFileManager, inputStream, outputStream);\n+    }\n+\n+    @Override\n+    public Response serve(IHTTPSession session) {\n+        Method method = session.getMethod();\n+        String queryString = session.getQueryParameterString();\n+        String uri = session.getUri();\n+        Map<String, String> headers = session.getHeaders();\n+        String requestBody = null;\n+\n+        // If there is a query string, append it to URI\n+        if (queryString != null && !queryString.isEmpty()) {\n+            uri = uri.concat(\"?\" + queryString);\n+        }\n+\n+        Log.info(\"URI: \" + uri);\n+        Log.info(\"METHOD: \" + method.toString());\n+        Log.info(\"ORIGIN: \" + headers.get(\"origin\"));\n+\n+        // Handle an OPTIONS request without relaying anything\n+        if (method.name().equals(\"OPTIONS\")) {\n+            Response optionsResponse = new Response(\"OK\");\n+            AppendCorsHeaders(optionsResponse, headers);\n+            optionsResponse.setStatus(Response.Status.OK);\n+            return optionsResponse;\n+        }\n+\n+        // Get the body of the request as a string\n+        // and return error responses if we can't parse it\n+        try {\n+            requestBody = parseRequestBody(session);","path":"Production/Utilities/UniversalUtilities/src/main/java/com/msopentech/thali/relay/RelayWebServer.java","position":110,"original_position":110,"commit_id":"f769887fe927adbf5d344fdbbcbab8b633598a64","original_commit_id":"8883adc04b0387283482b12ae992520254de90ea","user":{"login":"yaronyg","id":1480964,"avatar_url":"https://avatars.githubusercontent.com/u/1480964?","gravatar_id":"71841108006178331121f8d73343bd6b","url":"https://api.github.com/users/yaronyg","html_url":"https://github.com/yaronyg","followers_url":"https://api.github.com/users/yaronyg/followers","following_url":"https://api.github.com/users/yaronyg/following{/other_user}","gists_url":"https://api.github.com/users/yaronyg/gists{/gist_id}","starred_url":"https://api.github.com/users/yaronyg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaronyg/subscriptions","organizations_url":"https://api.github.com/users/yaronyg/orgs","repos_url":"https://api.github.com/users/yaronyg/repos","events_url":"https://api.github.com/users/yaronyg/events{/privacy}","received_events_url":"https://api.github.com/users/yaronyg/received_events","type":"User","site_admin":false},"body":"This is actually a p0 show stopper. Pictures were a big part of the ppnet demo and this makes that impossible. So please file a p0 bug against milestone 0 saying we have to switch to Apache's Listener. We can take the checkin with this bug for now just to get things moving but we need to fix it, this week ideally.","created_at":"2014-07-15T21:42:53Z","updated_at":"2014-07-15T21:42:53Z","html_url":"https://github.com/thaliproject/thali/pull/5#discussion_r14965581","pull_request_url":"https://api.github.com/repos/thaliproject/thali/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/comments/14965581"},"html":{"href":"https://github.com/thaliproject/thali/pull/5#discussion_r14965581"},"pull_request":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/thaliproject/thali/pulls/5","id":18241457,"html_url":"https://github.com/thaliproject/thali/pull/5","diff_url":"https://github.com/thaliproject/thali/pull/5.diff","patch_url":"https://github.com/thaliproject/thali/pull/5.patch","issue_url":"https://api.github.com/repos/thaliproject/thali/issues/5","number":5,"state":"open","title":"Relay prototype","user":{"login":"stefangordon","id":4087345,"avatar_url":"https://avatars.githubusercontent.com/u/4087345?","gravatar_id":"a88e3c0e152374b501f2b77be9d5afb8","url":"https://api.github.com/users/stefangordon","html_url":"https://github.com/stefangordon","followers_url":"https://api.github.com/users/stefangordon/followers","following_url":"https://api.github.com/users/stefangordon/following{/other_user}","gists_url":"https://api.github.com/users/stefangordon/gists{/gist_id}","starred_url":"https://api.github.com/users/stefangordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefangordon/subscriptions","organizations_url":"https://api.github.com/users/stefangordon/orgs","repos_url":"https://api.github.com/users/stefangordon/repos","events_url":"https://api.github.com/users/stefangordon/events{/privacy}","received_events_url":"https://api.github.com/users/stefangordon/received_events","type":"User","site_admin":false},"body":"Considering getting this simple relay implementation into ThaliProject while I finish up the other aspects of it - to simplify folks using the HTML5 seed.   Perhaps into a new branch on ThaliProject - but then you wouldn't be able to see the diff for review.\r\n\r\nOnly one source file here for the relay - RelayWebServer.java (and RelayWebServerTest.java).  The other bits are all NanoHTTPD.  Open questions on code file headers for those....","created_at":"2014-07-10T19:38:46Z","updated_at":"2014-07-15T21:42:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"69458c78ba3eaa99d304c6ae261fdb90f4743f5f","assignee":{"login":"stefangordon","id":4087345,"avatar_url":"https://avatars.githubusercontent.com/u/4087345?","gravatar_id":"a88e3c0e152374b501f2b77be9d5afb8","url":"https://api.github.com/users/stefangordon","html_url":"https://github.com/stefangordon","followers_url":"https://api.github.com/users/stefangordon/followers","following_url":"https://api.github.com/users/stefangordon/following{/other_user}","gists_url":"https://api.github.com/users/stefangordon/gists{/gist_id}","starred_url":"https://api.github.com/users/stefangordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefangordon/subscriptions","organizations_url":"https://api.github.com/users/stefangordon/orgs","repos_url":"https://api.github.com/users/stefangordon/repos","events_url":"https://api.github.com/users/stefangordon/events{/privacy}","received_events_url":"https://api.github.com/users/stefangordon/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/thaliproject/thali/milestones/1","labels_url":"https://api.github.com/repos/thaliproject/thali/milestones/1/labels","id":720941,"number":1,"title":"September Demo","description":"In September we will do a demo of Thali to our executive management. See https://github.com/thaliproject/thali/wiki/September-Demo for details.","creator":{"login":"yaronyg","id":1480964,"avatar_url":"https://avatars.githubusercontent.com/u/1480964?","gravatar_id":"71841108006178331121f8d73343bd6b","url":"https://api.github.com/users/yaronyg","html_url":"https://github.com/yaronyg","followers_url":"https://api.github.com/users/yaronyg/followers","following_url":"https://api.github.com/users/yaronyg/following{/other_user}","gists_url":"https://api.github.com/users/yaronyg/gists{/gist_id}","starred_url":"https://api.github.com/users/yaronyg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yaronyg/subscriptions","organizations_url":"https://api.github.com/users/yaronyg/orgs","repos_url":"https://api.github.com/users/yaronyg/repos","events_url":"https://api.github.com/users/yaronyg/events{/privacy}","received_events_url":"https://api.github.com/users/yaronyg/received_events","type":"User","site_admin":false},"open_issues":13,"closed_issues":1,"state":"open","created_at":"2014-07-14T21:25:36Z","updated_at":"2014-07-14T21:59:10Z","due_on":"2014-09-01T07:00:00Z"},"commits_url":"https://api.github.com/repos/thaliproject/thali/pulls/5/commits","review_comments_url":"https://api.github.com/repos/thaliproject/thali/pulls/5/comments","review_comment_url":"https://api.github.com/repos/thaliproject/thali/pulls/comments/{number}","comments_url":"https://api.github.com/repos/thaliproject/thali/issues/5/comments","statuses_url":"https://api.github.com/repos/thaliproject/thali/statuses/f769887fe927adbf5d344fdbbcbab8b633598a64","head":{"label":"stefangordon:relay_prototype","ref":"relay_prototype","sha":"f769887fe927adbf5d344fdbbcbab8b633598a64","user":{"login":"stefangordon","id":4087345,"avatar_url":"https://avatars.githubusercontent.com/u/4087345?","gravatar_id":"a88e3c0e152374b501f2b77be9d5afb8","url":"https://api.github.com/users/stefangordon","html_url":"https://github.com/stefangordon","followers_url":"https://api.github.com/users/stefangordon/followers","following_url":"https://api.github.com/users/stefangordon/following{/other_user}","gists_url":"https://api.github.com/users/stefangordon/gists{/gist_id}","starred_url":"https://api.github.com/users/stefangordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefangordon/subscriptions","organizations_url":"https://api.github.com/users/stefangordon/orgs","repos_url":"https://api.github.com/users/stefangordon/repos","events_url":"https://api.github.com/users/stefangordon/events{/privacy}","received_events_url":"https://api.github.com/users/stefangordon/received_events","type":"User","site_admin":false},"repo":{"id":21251516,"name":"thali-1","full_name":"stefangordon/thali-1","owner":{"login":"stefangordon","id":4087345,"avatar_url":"https://avatars.githubusercontent.com/u/4087345?","gravatar_id":"a88e3c0e152374b501f2b77be9d5afb8","url":"https://api.github.com/users/stefangordon","html_url":"https://github.com/stefangordon","followers_url":"https://api.github.com/users/stefangordon/followers","following_url":"https://api.github.com/users/stefangordon/following{/other_user}","gists_url":"https://api.github.com/users/stefangordon/gists{/gist_id}","starred_url":"https://api.github.com/users/stefangordon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefangordon/subscriptions","organizations_url":"https://api.github.com/users/stefangordon/orgs","repos_url":"https://api.github.com/users/stefangordon/repos","events_url":"https://api.github.com/users/stefangordon/events{/privacy}","received_events_url":"https://api.github.com/users/stefangordon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/stefangordon/thali-1","description":"Our root repository for all of our projects","fork":true,"url":"https://api.github.com/repos/stefangordon/thali-1","forks_url":"https://api.github.com/repos/stefangordon/thali-1/forks","keys_url":"https://api.github.com/repos/stefangordon/thali-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stefangordon/thali-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stefangordon/thali-1/teams","hooks_url":"https://api.github.com/repos/stefangordon/thali-1/hooks","issue_events_url":"https://api.github.com/repos/stefangordon/thali-1/issues/events{/number}","events_url":"https://api.github.com/repos/stefangordon/thali-1/events","assignees_url":"https://api.github.com/repos/stefangordon/thali-1/assignees{/user}","branches_url":"https://api.github.com/repos/stefangordon/thali-1/branches{/branch}","tags_url":"https://api.github.com/repos/stefangordon/thali-1/tags","blobs_url":"https://api.github.com/repos/stefangordon/thali-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stefangordon/thali-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stefangordon/thali-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/stefangordon/thali-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stefangordon/thali-1/statuses/{sha}","languages_url":"https://api.github.com/repos/stefangordon/thali-1/languages","stargazers_url":"https://api.github.com/repos/stefangordon/thali-1/stargazers","contributors_url":"https://api.github.com/repos/stefangordon/thali-1/contributors","subscribers_url":"https://api.github.com/repos/stefangordon/thali-1/subscribers","subscription_url":"https://api.github.com/repos/stefangordon/thali-1/subscription","commits_url":"https://api.github.com/repos/stefangordon/thali-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/stefangordon/thali-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/stefangordon/thali-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/stefangordon/thali-1/issues/comments/{number}","contents_url":"https://api.github.com/repos/stefangordon/thali-1/contents/{+path}","compare_url":"https://api.github.com/repos/stefangordon/thali-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stefangordon/thali-1/merges","archive_url":"https://api.github.com/repos/stefangordon/thali-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stefangordon/thali-1/downloads","issues_url":"https://api.github.com/repos/stefangordon/thali-1/issues{/number}","pulls_url":"https://api.github.com/repos/stefangordon/thali-1/pulls{/number}","milestones_url":"https://api.github.com/repos/stefangordon/thali-1/milestones{/number}","notifications_url":"https://api.github.com/repos/stefangordon/thali-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stefangordon/thali-1/labels{/name}","releases_url":"https://api.github.com/repos/stefangordon/thali-1/releases{/id}","created_at":"2014-06-26T19:01:44Z","updated_at":"2014-06-19T19:36:48Z","pushed_at":"2014-07-15T17:07:06Z","git_url":"git://github.com/stefangordon/thali-1.git","ssh_url":"git@github.com:stefangordon/thali-1.git","clone_url":"https://github.com/stefangordon/thali-1.git","svn_url":"https://github.com/stefangordon/thali-1","homepage":null,"size":20225,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thaliproject:master","ref":"master","sha":"a51e156d8400006880e0b6aa05be2283d04c2239","user":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?","gravatar_id":null,"url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"repo":{"id":20944673,"name":"thali","full_name":"thaliproject/thali","owner":{"login":"thaliproject","id":7918300,"avatar_url":"https://avatars.githubusercontent.com/u/7918300?","gravatar_id":null,"url":"https://api.github.com/users/thaliproject","html_url":"https://github.com/thaliproject","followers_url":"https://api.github.com/users/thaliproject/followers","following_url":"https://api.github.com/users/thaliproject/following{/other_user}","gists_url":"https://api.github.com/users/thaliproject/gists{/gist_id}","starred_url":"https://api.github.com/users/thaliproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaliproject/subscriptions","organizations_url":"https://api.github.com/users/thaliproject/orgs","repos_url":"https://api.github.com/users/thaliproject/repos","events_url":"https://api.github.com/users/thaliproject/events{/privacy}","received_events_url":"https://api.github.com/users/thaliproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thaliproject/thali","description":"Our root repository for all of our projects","fork":false,"url":"https://api.github.com/repos/thaliproject/thali","forks_url":"https://api.github.com/repos/thaliproject/thali/forks","keys_url":"https://api.github.com/repos/thaliproject/thali/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thaliproject/thali/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thaliproject/thali/teams","hooks_url":"https://api.github.com/repos/thaliproject/thali/hooks","issue_events_url":"https://api.github.com/repos/thaliproject/thali/issues/events{/number}","events_url":"https://api.github.com/repos/thaliproject/thali/events","assignees_url":"https://api.github.com/repos/thaliproject/thali/assignees{/user}","branches_url":"https://api.github.com/repos/thaliproject/thali/branches{/branch}","tags_url":"https://api.github.com/repos/thaliproject/thali/tags","blobs_url":"https://api.github.com/repos/thaliproject/thali/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thaliproject/thali/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thaliproject/thali/git/refs{/sha}","trees_url":"https://api.github.com/repos/thaliproject/thali/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thaliproject/thali/statuses/{sha}","languages_url":"https://api.github.com/repos/thaliproject/thali/languages","stargazers_url":"https://api.github.com/repos/thaliproject/thali/stargazers","contributors_url":"https://api.github.com/repos/thaliproject/thali/contributors","subscribers_url":"https://api.github.com/repos/thaliproject/thali/subscribers","subscription_url":"https://api.github.com/repos/thaliproject/thali/subscription","commits_url":"https://api.github.com/repos/thaliproject/thali/commits{/sha}","git_commits_url":"https://api.github.com/repos/thaliproject/thali/git/commits{/sha}","comments_url":"https://api.github.com/repos/thaliproject/thali/comments{/number}","issue_comment_url":"https://api.github.com/repos/thaliproject/thali/issues/comments/{number}","contents_url":"https://api.github.com/repos/thaliproject/thali/contents/{+path}","compare_url":"https://api.github.com/repos/thaliproject/thali/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thaliproject/thali/merges","archive_url":"https://api.github.com/repos/thaliproject/thali/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thaliproject/thali/downloads","issues_url":"https://api.github.com/repos/thaliproject/thali/issues{/number}","pulls_url":"https://api.github.com/repos/thaliproject/thali/pulls{/number}","milestones_url":"https://api.github.com/repos/thaliproject/thali/milestones{/number}","notifications_url":"https://api.github.com/repos/thaliproject/thali/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thaliproject/thali/labels{/name}","releases_url":"https://api.github.com/repos/thaliproject/thali/releases{/id}","created_at":"2014-06-18T01:06:19Z","updated_at":"2014-07-14T21:07:24Z","pushed_at":"2014-06-19T19:15:48Z","git_url":"git://github.com/thaliproject/thali.git","ssh_url":"git@github.com:thaliproject/thali.git","clone_url":"https://github.com/thaliproject/thali.git","svn_url":"https://github.com/thaliproject/thali","homepage":null,"size":19097,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"forks_count":5,"mirror_url":null,"open_issues_count":17,"forks":5,"open_issues":17,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/5"},"html":{"href":"https://github.com/thaliproject/thali/pull/5"},"issue":{"href":"https://api.github.com/repos/thaliproject/thali/issues/5"},"comments":{"href":"https://api.github.com/repos/thaliproject/thali/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/thaliproject/thali/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/thaliproject/thali/statuses/f769887fe927adbf5d344fdbbcbab8b633598a64"}}}}