{"action":"created","comment":{"url":"https://api.github.com/repos/codenvy/che-plugins/pulls/comments/40913567","id":40913567,"diff_hunk":"@@ -10,193 +10,266 @@\n  *******************************************************************************/\n package org.eclipse.che.ide.ext.ssh.server;\n \n+import com.google.gson.reflect.TypeToken;\n import com.jcraft.jsch.JSch;\n import com.jcraft.jsch.JSchException;\n import com.jcraft.jsch.KeyPair;\n \n-import org.eclipse.che.api.core.NotFoundException;\n-import org.eclipse.che.api.core.ServerException;\n-import org.eclipse.che.api.user.server.dao.PreferenceDao;\n-import org.eclipse.che.api.user.server.dao.User;\n-import org.eclipse.che.api.user.server.dao.UserDao;\n-import org.eclipse.che.commons.env.EnvironmentContext;\n+import org.eclipse.che.api.core.ApiException;\n+import org.eclipse.che.api.core.rest.HttpJsonHelper;\n+import org.eclipse.che.api.user.shared.dto.ProfileDescriptor;\n+import org.eclipse.che.commons.json.JsonHelper;\n+import org.eclipse.che.commons.json.JsonParseException;\n+import org.eclipse.che.commons.lang.Pair;\n \n import javax.inject.Inject;\n+import javax.inject.Named;\n import java.io.ByteArrayOutputStream;\n+import java.io.IOException;\n+import java.nio.charset.Charset;\n import java.util.HashSet;\n import java.util.Iterator;\n import java.util.Map;\n import java.util.Set;\n+import java.util.stream.Collectors;\n \n-/** @author andrew00x */\n+/**\n+ * @author andrew00x\n+ * @author Anton Korneta\n+ */\n public class UserProfileSshKeyStore implements SshKeyStore {\n     private static final int    PRIVATE                      = 0;\n     private static final int    PUBLIC                       = 1;\n     private static final String KEY_ATTRIBUTE_PREFIX         = \"ssh.key.\";\n-    /** Prefix for attribute of user profile that store private SSH key. */\n+    // Prefix for attribute of user profile that store private SSH key.\n     private static final String PRIVATE_KEY_ATTRIBUTE_PREFIX = KEY_ATTRIBUTE_PREFIX + \"private.\";\n-    /** Prefix for attribute of user profile that store public SSH key. */\n+    // Prefix for attribute of user profile that store public SSH key.\n     private static final String PUBLIC_KEY_ATTRIBUTE_PREFIX  = KEY_ATTRIBUTE_PREFIX + \"public.\";\n \n-    private final JSch          genJsch;\n-    private final UserDao       userDao;\n-    private final PreferenceDao preferenceDao;\n+    private final JSch   genJsch;\n+    private final String profileApiUrl;\n \n     @Inject\n-    public UserProfileSshKeyStore(PreferenceDao preferenceDao, UserDao userDao) {\n+    public UserProfileSshKeyStore(@Named(\"api.endpoint\") String apiUrl) {\n         this.genJsch = new JSch();\n-        this.userDao = userDao;\n-        this.preferenceDao = preferenceDao;\n+        this.profileApiUrl = apiUrl + \"/profile\";\n     }\n \n+    /**\n+     * Adds the private key in the user preferences.","path":"plugin-ssh/che-plugin-ssh-ext-sshkey/src/main/java/org/eclipse/che/ide/ext/ssh/server/UserProfileSshKeyStore.java","position":65,"original_position":65,"commit_id":"5e17696b3af10325311188c0772c88cfedf520e5","original_commit_id":"5e17696b3af10325311188c0772c88cfedf520e5","user":{"login":"garagatyi","id":1851863,"avatar_url":"https://avatars.githubusercontent.com/u/1851863?v=3","gravatar_id":"","url":"https://api.github.com/users/garagatyi","html_url":"https://github.com/garagatyi","followers_url":"https://api.github.com/users/garagatyi/followers","following_url":"https://api.github.com/users/garagatyi/following{/other_user}","gists_url":"https://api.github.com/users/garagatyi/gists{/gist_id}","starred_url":"https://api.github.com/users/garagatyi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garagatyi/subscriptions","organizations_url":"https://api.github.com/users/garagatyi/orgs","repos_url":"https://api.github.com/users/garagatyi/repos","events_url":"https://api.github.com/users/garagatyi/events{/privacy}","received_events_url":"https://api.github.com/users/garagatyi/received_events","type":"User","site_admin":false},"body":"to the","created_at":"2015-10-01T13:40:23Z","updated_at":"2015-10-01T13:40:23Z","html_url":"https://github.com/codenvy/che-plugins/pull/290#discussion_r40913567","pull_request_url":"https://api.github.com/repos/codenvy/che-plugins/pulls/290","_links":{"self":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/comments/40913567"},"html":{"href":"https://github.com/codenvy/che-plugins/pull/290#discussion_r40913567"},"pull_request":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/290"}}},"pull_request":{"url":"https://api.github.com/repos/codenvy/che-plugins/pulls/290","id":46505327,"html_url":"https://github.com/codenvy/che-plugins/pull/290","diff_url":"https://github.com/codenvy/che-plugins/pull/290.diff","patch_url":"https://github.com/codenvy/che-plugins/pull/290.patch","issue_url":"https://api.github.com/repos/codenvy/che-plugins/issues/290","number":290,"state":"open","locked":false,"title":"IDEX-3101: removed PreferenceDao from UserProfileSshKeyStore","user":{"login":"akorneta","id":12269156,"avatar_url":"https://avatars.githubusercontent.com/u/12269156?v=3","gravatar_id":"","url":"https://api.github.com/users/akorneta","html_url":"https://github.com/akorneta","followers_url":"https://api.github.com/users/akorneta/followers","following_url":"https://api.github.com/users/akorneta/following{/other_user}","gists_url":"https://api.github.com/users/akorneta/gists{/gist_id}","starred_url":"https://api.github.com/users/akorneta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akorneta/subscriptions","organizations_url":"https://api.github.com/users/akorneta/orgs","repos_url":"https://api.github.com/users/akorneta/repos","events_url":"https://api.github.com/users/akorneta/events{/privacy}","received_events_url":"https://api.github.com/users/akorneta/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-01T10:06:35Z","updated_at":"2015-10-01T13:40:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"29d6cc81f31cccc417fc2cba19ce5077e3356bc1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/codenvy/che-plugins/pulls/290/commits","review_comments_url":"https://api.github.com/repos/codenvy/che-plugins/pulls/290/comments","review_comment_url":"https://api.github.com/repos/codenvy/che-plugins/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codenvy/che-plugins/issues/290/comments","statuses_url":"https://api.github.com/repos/codenvy/che-plugins/statuses/5e17696b3af10325311188c0772c88cfedf520e5","head":{"label":"codenvy:IDEX-3101","ref":"IDEX-3101","sha":"5e17696b3af10325311188c0772c88cfedf520e5","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":32935729,"name":"che-plugins","full_name":"codenvy/che-plugins","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/che-plugins","description":"Plugins for che","fork":false,"url":"https://api.github.com/repos/codenvy/che-plugins","forks_url":"https://api.github.com/repos/codenvy/che-plugins/forks","keys_url":"https://api.github.com/repos/codenvy/che-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/che-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/che-plugins/teams","hooks_url":"https://api.github.com/repos/codenvy/che-plugins/hooks","issue_events_url":"https://api.github.com/repos/codenvy/che-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/che-plugins/events","assignees_url":"https://api.github.com/repos/codenvy/che-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/che-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/che-plugins/tags","blobs_url":"https://api.github.com/repos/codenvy/che-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/che-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/che-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/che-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/che-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/che-plugins/languages","stargazers_url":"https://api.github.com/repos/codenvy/che-plugins/stargazers","contributors_url":"https://api.github.com/repos/codenvy/che-plugins/contributors","subscribers_url":"https://api.github.com/repos/codenvy/che-plugins/subscribers","subscription_url":"https://api.github.com/repos/codenvy/che-plugins/subscription","commits_url":"https://api.github.com/repos/codenvy/che-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/che-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/che-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/che-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/che-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/che-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/che-plugins/merges","archive_url":"https://api.github.com/repos/codenvy/che-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/che-plugins/downloads","issues_url":"https://api.github.com/repos/codenvy/che-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/che-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/che-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/che-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/che-plugins/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/che-plugins/releases{/id}","created_at":"2015-03-26T15:30:37Z","updated_at":"2015-09-08T03:20:21Z","pushed_at":"2015-10-01T13:35:25Z","git_url":"git://github.com/codenvy/che-plugins.git","ssh_url":"git@github.com:codenvy/che-plugins.git","clone_url":"https://github.com/codenvy/che-plugins.git","svn_url":"https://github.com/codenvy/che-plugins","homepage":null,"size":26977,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":5,"forks":15,"open_issues":5,"watchers":6,"default_branch":"master"}},"base":{"label":"codenvy:4.0","ref":"4.0","sha":"54fb114371bca9069ad3585b9a3c73780c699145","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":32935729,"name":"che-plugins","full_name":"codenvy/che-plugins","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/che-plugins","description":"Plugins for che","fork":false,"url":"https://api.github.com/repos/codenvy/che-plugins","forks_url":"https://api.github.com/repos/codenvy/che-plugins/forks","keys_url":"https://api.github.com/repos/codenvy/che-plugins/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/che-plugins/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/che-plugins/teams","hooks_url":"https://api.github.com/repos/codenvy/che-plugins/hooks","issue_events_url":"https://api.github.com/repos/codenvy/che-plugins/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/che-plugins/events","assignees_url":"https://api.github.com/repos/codenvy/che-plugins/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/che-plugins/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/che-plugins/tags","blobs_url":"https://api.github.com/repos/codenvy/che-plugins/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/che-plugins/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/che-plugins/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/che-plugins/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/che-plugins/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/che-plugins/languages","stargazers_url":"https://api.github.com/repos/codenvy/che-plugins/stargazers","contributors_url":"https://api.github.com/repos/codenvy/che-plugins/contributors","subscribers_url":"https://api.github.com/repos/codenvy/che-plugins/subscribers","subscription_url":"https://api.github.com/repos/codenvy/che-plugins/subscription","commits_url":"https://api.github.com/repos/codenvy/che-plugins/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/che-plugins/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/che-plugins/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/che-plugins/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/che-plugins/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/che-plugins/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/che-plugins/merges","archive_url":"https://api.github.com/repos/codenvy/che-plugins/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/che-plugins/downloads","issues_url":"https://api.github.com/repos/codenvy/che-plugins/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/che-plugins/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/che-plugins/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/che-plugins/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/che-plugins/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/che-plugins/releases{/id}","created_at":"2015-03-26T15:30:37Z","updated_at":"2015-09-08T03:20:21Z","pushed_at":"2015-10-01T13:35:25Z","git_url":"git://github.com/codenvy/che-plugins.git","ssh_url":"git@github.com:codenvy/che-plugins.git","clone_url":"https://github.com/codenvy/che-plugins.git","svn_url":"https://github.com/codenvy/che-plugins","homepage":null,"size":26977,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":15,"mirror_url":null,"open_issues_count":5,"forks":15,"open_issues":5,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/290"},"html":{"href":"https://github.com/codenvy/che-plugins/pull/290"},"issue":{"href":"https://api.github.com/repos/codenvy/che-plugins/issues/290"},"comments":{"href":"https://api.github.com/repos/codenvy/che-plugins/issues/290/comments"},"review_comments":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/290/comments"},"review_comment":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codenvy/che-plugins/pulls/290/commits"},"statuses":{"href":"https://api.github.com/repos/codenvy/che-plugins/statuses/5e17696b3af10325311188c0772c88cfedf520e5"}}}}