GitHub PullRequestReviewCommentEvent at 2014-11-14 15:50:37
Repository: qabel-core
Actor: thechauffeur
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/Qabel/qabel-core/pulls/comments/20366405","id":20366405,"diff_hunk":"@@ -100,4 +109,168 @@ public Contacts getContacts() {\n \tpublic void setContacts(Contacts mContacts) {\n \t\tthis.mContacts = mContacts;\n \t}\n+\n+\tGsonBuilder gb;\n+\tGson gson;\n+\n+\n+\tprivate final static Logger logger = LogManager.getLogger(DropController.class.getName());\n+\n+\n+\n+\t/**\n+\t * Sends the message and waits for acknowledgement.\n+\t * Uses sendAndForget() for now.\n+\t *\n+\t * TODO: implement\n+\t */\n+\tpublic boolean send(DropMessage<? extends ModelObject> message, Collection<Contact> contacts) {\n+\t\treturn sendAndForget(message, contacts);\n+\t}\n+\n+\n+\n+\t/**\n+\t * Sends the message to a collection of contacts and does not wait for acknowledgement\n+\t *\n+\t * @param message  Message to send\n+\t * @param contacts Contacts to send message to\n+\t * @return HTTP status code from the drop-server.\n+\t */\n+\tpublic <T extends ModelObject> boolean sendAndForget(DropMessage<T> message, Collection<Contact> contacts) {\n+\t\tDropHTTP http = new DropHTTP();\n+\t\tString m = serialize(message);\n+\t\tboolean res = false;\n+\t\tfor (Contact c : contacts) {\n+\t\t\tbyte[] cryptedMessage;\n+\t\t\ttry {\n+\t\t\t\tcryptedMessage = encryptDrop(\n+\t\t\t\t\t\tm,\n+\t\t\t\t\t\tc.getEncryptionPublicKey(),\n+\t\t\t\t\t\tc.getContactOwner().getPrimaryKeyPair().getSignKeyPairs()\n+\t\t\t\t);\n+\t\t\t\tfor (DropURL u : c.getDropUrls()) {\n+\t\t\t\t\tif(http.send(u.getUrl(), cryptedMessage) == 200)\n+\t\t\t\t\t\tres = true;\n+\t\t\t\t}\n+\t\t\t} catch (InvalidKeyException e) {\n+\t\t\t\tlogger.error(\"Invalid key in contact. Cannot send message!\");\n+\t\t\t}\n+\t\t}\n+\t\treturn res;\n+\t}\n+\n+\t/**\n+\t * Sends the object to one contact and does not wait for acknowledgement\n+\t *\n+\t * @param object Object to send\n+\t * @param contact Contact to send message to\n+\t * @return true if one DropServers of the contact returns 200\n+\t */\n+\tpublic <T extends ModelObject> boolean sendAndForget(T object, Contact contact) {\n+\t\tDropHTTP http = new DropHTTP();\n+\n+\t\tDropMessage<T> dm = new DropMessage<T>();\n+\n+\t\tdm.setData(object);\n+\t\tdm.setTime(new Date());\n+\t\tdm.setModelObject((Class<T>) object.getClass());\n+\n+\t\treturn sendAndForget(dm, Arrays.asList(contact));\n+\t}\n+\n+\t/**\n+\t * Sends the message to one contact and does not wait for acknowledgement\n+\t *\n+\t * @param message Message to send\n+\t * @param contact Contact to send message to\n+\t * @return true if one DropServers of the contact returns 200\n+\t */\n+\tpublic <T extends ModelObject> boolean sendAndForget(DropMessage<T> message, Contact contact) {\n+\t\treturn sendAndForget(message, Arrays.asList(contact));\n+\t}\n+\n+\t/**\n+\t * Retrieves a drop message from given URL\n+\t *\n+\t * @param url      URL where to retrieve the drop from\n+\t * @param contacts Contacts to check the signature with\n+\t * @return Retrieved, encrypted Dropmessages.\n+\t */\n+\tpublic Collection<DropMessage> retrieve(URL url, Collection<Contact> contacts) {\n+\t\tDropHTTP http = new DropHTTP();\n+\t\tCollection<byte[]> cipherMessages = http.receiveMessages(url);\n+\t\tCollection<DropMessage> plainMessages = new ArrayList<DropMessage>();\n+\t\tString plainJson = null;\n+\n+\t\tList<Contact> ccc = new ArrayList<Contact>(contacts);\n+\t\tCollections.shuffle(ccc, new SecureRandom());\n+\n+\t\tfor (byte[] cipherMessage : cipherMessages) {\n+\t\t\tfor (Contact c : contacts) {\n+\t\t\t\ttry {\n+\t\t\t\t\tplainJson = decryptDrop(cipherMessage,\n+\t\t\t\t\t\t\tc.getContactOwner().getPrimaryKeyPair(),\n+\t\t\t\t\t\t\tc.getSignaturePublicKey()\n+\t\t\t\t\t);\n+\t\t\t\t} catch (InvalidKeyException e) {\n+\t\t\t\t\t// TODO Invalid keys in Contacts are currently ignored\n+\t\t\t\t}\n+\t\t\t\tif (plainJson == null) {\n+\t\t\t\t\tcontinue;\n+\t\t\t\t} else {\n+\t\t\t\t\tplainMessages.add(deserialize(plainJson));\n+\t\t\t\t\tbreak;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t\treturn plainMessages;\n+\t}\n+\n+\t/**\n+\t * Serializes the message\n+\t *\n+\t * @param message DropMessage to serialize\n+\t * @return String with message as json\n+\t */\n+\tprivate String serialize(DropMessage<? extends ModelObject> message) {\n+\t\treturn gson.toJson(message);\n+\t}\n+\n+\t/**\n+\t * Deserializes the message\n+\t *\n+\t * @param plainJson plain Json String\n+\t * @return deserialized Dropmessage\n+\t */\n+\tprivate DropMessage deserialize(String plainJson) {\n+\t\treturn gson.fromJson(plainJson, DropMessage.class);\n+\t}\n+\n+\t/**\n+\t * Deserializes the message\n+\t *\n+\t * @param jsonMessage plain Json String to encrypt\n+\t * @param publickey   Publickey to encrypt the jsonMessage with\n+\t * @param skp         Sign key pair to sign the message\n+\t * @return the cyphertext as byte[]\n+\t * @throws InvalidKeyException\n+\t */\n+\tprivate byte[] encryptDrop(String jsonMessage, QblEncPublicKey publickey, QblSignKeyPair skp) throws InvalidKeyException {\n+\t\tCryptoUtils cu = CryptoUtils.getInstance();","path":"src/main/java/de/qabel/core/drop/DropController.java","position":211,"original_position":214,"commit_id":"8773e150b18eaff80f5fdb5eb996503f5ca0827b","original_commit_id":"ab2f243afea897933953dae3f8a8c1300ff85f8f","user":{"login":"thechauffeur","id":150507,"avatar_url":"https://avatars.githubusercontent.com/u/150507?v=3","gravatar_id":"","url":"https://api.github.com/users/thechauffeur","html_url":"https://github.com/thechauffeur","followers_url":"https://api.github.com/users/thechauffeur/followers","following_url":"https://api.github.com/users/thechauffeur/following{/other_user}","gists_url":"https://api.github.com/users/thechauffeur/gists{/gist_id}","starred_url":"https://api.github.com/users/thechauffeur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thechauffeur/subscriptions","organizations_url":"https://api.github.com/users/thechauffeur/orgs","repos_url":"https://api.github.com/users/thechauffeur/repos","events_url":"https://api.github.com/users/thechauffeur/events{/privacy}","received_events_url":"https://api.github.com/users/thechauffeur/received_events","type":"User","site_admin":false},"body":"FYI, the mentioned PR #205 has been merged now.","created_at":"2014-11-14T15:50:37Z","updated_at":"2014-11-14T15:50:37Z","html_url":"https://github.com/Qabel/qabel-core/pull/204#discussion_r20366405","pull_request_url":"https://api.github.com/repos/Qabel/qabel-core/pulls/204","_links":{"self":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/comments/20366405"},"html":{"href":"https://github.com/Qabel/qabel-core/pull/204#discussion_r20366405"},"pull_request":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/204"}}},"pull_request":{"url":"https://api.github.com/repos/Qabel/qabel-core/pulls/204","id":24241551,"html_url":"https://github.com/Qabel/qabel-core/pull/204","diff_url":"https://github.com/Qabel/qabel-core/pull/204.diff","patch_url":"https://github.com/Qabel/qabel-core/pull/204.patch","issue_url":"https://api.github.com/repos/Qabel/qabel-core/issues/204","number":204,"state":"open","locked":false,"title":"Merged class Drop into DropController","user":{"login":"jan-schreib","id":2648381,"avatar_url":"https://avatars.githubusercontent.com/u/2648381?v=3","gravatar_id":"","url":"https://api.github.com/users/jan-schreib","html_url":"https://github.com/jan-schreib","followers_url":"https://api.github.com/users/jan-schreib/followers","following_url":"https://api.github.com/users/jan-schreib/following{/other_user}","gists_url":"https://api.github.com/users/jan-schreib/gists{/gist_id}","starred_url":"https://api.github.com/users/jan-schreib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jan-schreib/subscriptions","organizations_url":"https://api.github.com/users/jan-schreib/orgs","repos_url":"https://api.github.com/users/jan-schreib/repos","events_url":"https://api.github.com/users/jan-schreib/events{/privacy}","received_events_url":"https://api.github.com/users/jan-schreib/received_events","type":"User","site_admin":false},"body":"closes #112.\n\n* Moved functions from Drop.java into DropController.java\n* Deleted Drop.java\n* Renamed DropTest.java to DropControllerTest.java","created_at":"2014-11-11T19:01:59Z","updated_at":"2014-11-14T15:50:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ccb3aa39ae4fa0089fa9850f654a2914e9ad3996","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Qabel/qabel-core/pulls/204/commits","review_comments_url":"https://api.github.com/repos/Qabel/qabel-core/pulls/204/comments","review_comment_url":"https://api.github.com/repos/Qabel/qabel-core/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Qabel/qabel-core/issues/204/comments","statuses_url":"https://api.github.com/repos/Qabel/qabel-core/statuses/8773e150b18eaff80f5fdb5eb996503f5ca0827b","head":{"label":"jan-schreib:drop_refactoring","ref":"drop_refactoring","sha":"8773e150b18eaff80f5fdb5eb996503f5ca0827b","user":{"login":"jan-schreib","id":2648381,"avatar_url":"https://avatars.githubusercontent.com/u/2648381?v=3","gravatar_id":"","url":"https://api.github.com/users/jan-schreib","html_url":"https://github.com/jan-schreib","followers_url":"https://api.github.com/users/jan-schreib/followers","following_url":"https://api.github.com/users/jan-schreib/following{/other_user}","gists_url":"https://api.github.com/users/jan-schreib/gists{/gist_id}","starred_url":"https://api.github.com/users/jan-schreib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jan-schreib/subscriptions","organizations_url":"https://api.github.com/users/jan-schreib/orgs","repos_url":"https://api.github.com/users/jan-schreib/repos","events_url":"https://api.github.com/users/jan-schreib/events{/privacy}","received_events_url":"https://api.github.com/users/jan-schreib/received_events","type":"User","site_admin":false},"repo":{"id":24614960,"name":"qabel-core","full_name":"jan-schreib/qabel-core","owner":{"login":"jan-schreib","id":2648381,"avatar_url":"https://avatars.githubusercontent.com/u/2648381?v=3","gravatar_id":"","url":"https://api.github.com/users/jan-schreib","html_url":"https://github.com/jan-schreib","followers_url":"https://api.github.com/users/jan-schreib/followers","following_url":"https://api.github.com/users/jan-schreib/following{/other_user}","gists_url":"https://api.github.com/users/jan-schreib/gists{/gist_id}","starred_url":"https://api.github.com/users/jan-schreib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jan-schreib/subscriptions","organizations_url":"https://api.github.com/users/jan-schreib/orgs","repos_url":"https://api.github.com/users/jan-schreib/repos","events_url":"https://api.github.com/users/jan-schreib/events{/privacy}","received_events_url":"https://api.github.com/users/jan-schreib/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jan-schreib/qabel-core","description":"Implementation of Qabel-Core in Java","fork":true,"url":"https://api.github.com/repos/jan-schreib/qabel-core","forks_url":"https://api.github.com/repos/jan-schreib/qabel-core/forks","keys_url":"https://api.github.com/repos/jan-schreib/qabel-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jan-schreib/qabel-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jan-schreib/qabel-core/teams","hooks_url":"https://api.github.com/repos/jan-schreib/qabel-core/hooks","issue_events_url":"https://api.github.com/repos/jan-schreib/qabel-core/issues/events{/number}","events_url":"https://api.github.com/repos/jan-schreib/qabel-core/events","assignees_url":"https://api.github.com/repos/jan-schreib/qabel-core/assignees{/user}","branches_url":"https://api.github.com/repos/jan-schreib/qabel-core/branches{/branch}","tags_url":"https://api.github.com/repos/jan-schreib/qabel-core/tags","blobs_url":"https://api.github.com/repos/jan-schreib/qabel-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jan-schreib/qabel-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jan-schreib/qabel-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/jan-schreib/qabel-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jan-schreib/qabel-core/statuses/{sha}","languages_url":"https://api.github.com/repos/jan-schreib/qabel-core/languages","stargazers_url":"https://api.github.com/repos/jan-schreib/qabel-core/stargazers","contributors_url":"https://api.github.com/repos/jan-schreib/qabel-core/contributors","subscribers_url":"https://api.github.com/repos/jan-schreib/qabel-core/subscribers","subscription_url":"https://api.github.com/repos/jan-schreib/qabel-core/subscription","commits_url":"https://api.github.com/repos/jan-schreib/qabel-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/jan-schreib/qabel-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/jan-schreib/qabel-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/jan-schreib/qabel-core/issues/comments/{number}","contents_url":"https://api.github.com/repos/jan-schreib/qabel-core/contents/{+path}","compare_url":"https://api.github.com/repos/jan-schreib/qabel-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jan-schreib/qabel-core/merges","archive_url":"https://api.github.com/repos/jan-schreib/qabel-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jan-schreib/qabel-core/downloads","issues_url":"https://api.github.com/repos/jan-schreib/qabel-core/issues{/number}","pulls_url":"https://api.github.com/repos/jan-schreib/qabel-core/pulls{/number}","milestones_url":"https://api.github.com/repos/jan-schreib/qabel-core/milestones{/number}","notifications_url":"https://api.github.com/repos/jan-schreib/qabel-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jan-schreib/qabel-core/labels{/name}","releases_url":"https://api.github.com/repos/jan-schreib/qabel-core/releases{/id}","created_at":"2014-09-29T22:09:48Z","updated_at":"2014-09-30T12:21:35Z","pushed_at":"2014-11-13T12:23:36Z","git_url":"git://github.com/jan-schreib/qabel-core.git","ssh_url":"git@github.com:jan-schreib/qabel-core.git","clone_url":"https://github.com/jan-schreib/qabel-core.git","svn_url":"https://github.com/jan-schreib/qabel-core","homepage":null,"size":2394,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Qabel:master","ref":"master","sha":"e0c8d5490d7b00d466f8d2f58a0abe6c33c4e360","user":{"login":"Qabel","id":7711470,"avatar_url":"https://avatars.githubusercontent.com/u/7711470?v=3","gravatar_id":"","url":"https://api.github.com/users/Qabel","html_url":"https://github.com/Qabel","followers_url":"https://api.github.com/users/Qabel/followers","following_url":"https://api.github.com/users/Qabel/following{/other_user}","gists_url":"https://api.github.com/users/Qabel/gists{/gist_id}","starred_url":"https://api.github.com/users/Qabel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qabel/subscriptions","organizations_url":"https://api.github.com/users/Qabel/orgs","repos_url":"https://api.github.com/users/Qabel/repos","events_url":"https://api.github.com/users/Qabel/events{/privacy}","received_events_url":"https://api.github.com/users/Qabel/received_events","type":"Organization","site_admin":false},"repo":{"id":22873447,"name":"qabel-core","full_name":"Qabel/qabel-core","owner":{"login":"Qabel","id":7711470,"avatar_url":"https://avatars.githubusercontent.com/u/7711470?v=3","gravatar_id":"","url":"https://api.github.com/users/Qabel","html_url":"https://github.com/Qabel","followers_url":"https://api.github.com/users/Qabel/followers","following_url":"https://api.github.com/users/Qabel/following{/other_user}","gists_url":"https://api.github.com/users/Qabel/gists{/gist_id}","starred_url":"https://api.github.com/users/Qabel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Qabel/subscriptions","organizations_url":"https://api.github.com/users/Qabel/orgs","repos_url":"https://api.github.com/users/Qabel/repos","events_url":"https://api.github.com/users/Qabel/events{/privacy}","received_events_url":"https://api.github.com/users/Qabel/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Qabel/qabel-core","description":"Implementation of Qabel-Core in Java","fork":false,"url":"https://api.github.com/repos/Qabel/qabel-core","forks_url":"https://api.github.com/repos/Qabel/qabel-core/forks","keys_url":"https://api.github.com/repos/Qabel/qabel-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Qabel/qabel-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Qabel/qabel-core/teams","hooks_url":"https://api.github.com/repos/Qabel/qabel-core/hooks","issue_events_url":"https://api.github.com/repos/Qabel/qabel-core/issues/events{/number}","events_url":"https://api.github.com/repos/Qabel/qabel-core/events","assignees_url":"https://api.github.com/repos/Qabel/qabel-core/assignees{/user}","branches_url":"https://api.github.com/repos/Qabel/qabel-core/branches{/branch}","tags_url":"https://api.github.com/repos/Qabel/qabel-core/tags","blobs_url":"https://api.github.com/repos/Qabel/qabel-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Qabel/qabel-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Qabel/qabel-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/Qabel/qabel-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Qabel/qabel-core/statuses/{sha}","languages_url":"https://api.github.com/repos/Qabel/qabel-core/languages","stargazers_url":"https://api.github.com/repos/Qabel/qabel-core/stargazers","contributors_url":"https://api.github.com/repos/Qabel/qabel-core/contributors","subscribers_url":"https://api.github.com/repos/Qabel/qabel-core/subscribers","subscription_url":"https://api.github.com/repos/Qabel/qabel-core/subscription","commits_url":"https://api.github.com/repos/Qabel/qabel-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/Qabel/qabel-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/Qabel/qabel-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/Qabel/qabel-core/issues/comments/{number}","contents_url":"https://api.github.com/repos/Qabel/qabel-core/contents/{+path}","compare_url":"https://api.github.com/repos/Qabel/qabel-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Qabel/qabel-core/merges","archive_url":"https://api.github.com/repos/Qabel/qabel-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Qabel/qabel-core/downloads","issues_url":"https://api.github.com/repos/Qabel/qabel-core/issues{/number}","pulls_url":"https://api.github.com/repos/Qabel/qabel-core/pulls{/number}","milestones_url":"https://api.github.com/repos/Qabel/qabel-core/milestones{/number}","notifications_url":"https://api.github.com/repos/Qabel/qabel-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Qabel/qabel-core/labels{/name}","releases_url":"https://api.github.com/repos/Qabel/qabel-core/releases{/id}","created_at":"2014-08-12T10:25:10Z","updated_at":"2014-11-08T11:02:19Z","pushed_at":"2014-11-14T15:27:57Z","git_url":"git://github.com/Qabel/qabel-core.git","ssh_url":"git@github.com:Qabel/qabel-core.git","clone_url":"https://github.com/Qabel/qabel-core.git","svn_url":"https://github.com/Qabel/qabel-core","homepage":null,"size":4742,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":37,"forks":11,"open_issues":37,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/204"},"html":{"href":"https://github.com/Qabel/qabel-core/pull/204"},"issue":{"href":"https://api.github.com/repos/Qabel/qabel-core/issues/204"},"comments":{"href":"https://api.github.com/repos/Qabel/qabel-core/issues/204/comments"},"review_comments":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/204/comments"},"review_comment":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Qabel/qabel-core/pulls/204/commits"},"statuses":{"href":"https://api.github.com/repos/Qabel/qabel-core/statuses/8773e150b18eaff80f5fdb5eb996503f5ca0827b"}}}}