{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/che/pulls/comments/128458397","pull_request_review_id":51137976,"id":128458397,"diff_hunk":"@@ -0,0 +1,184 @@\n+package org.eclipse.che.datasource.api.ssl;\n+\n+import com.google.gson.reflect.TypeToken;\n+import com.google.inject.Inject;\n+import com.google.inject.name.Named;\n+import org.apache.commons.fileupload.FileItem;\n+import org.apache.commons.codec.binary.Base64;\n+import org.eclipse.che.api.core.ApiException;\n+import org.eclipse.che.api.core.rest.HttpJsonHelper;\n+import org.eclipse.che.commons.env.EnvironmentContext;\n+import org.eclipse.che.commons.json.JsonHelper;\n+import org.eclipse.che.commons.json.JsonParseException;\n+import org.eclipse.che.datasource.shared.ssl.SslKeyStoreEntry;\n+import org.eclipse.che.dto.server.DtoFactory;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import javax.ws.rs.*;\n+import javax.ws.rs.core.Context;\n+import javax.ws.rs.core.MediaType;\n+import javax.ws.rs.core.Response;\n+import javax.ws.rs.core.UriInfo;\n+import java.io.ByteArrayInputStream;\n+import java.io.ByteArrayOutputStream;\n+import java.io.IOException;\n+import java.io.InputStream;\n+import java.security.KeyFactory;\n+import java.security.KeyStore;\n+import java.security.PrivateKey;\n+import java.security.cert.Certificate;\n+import java.security.cert.CertificateFactory;\n+import java.security.spec.PKCS8EncodedKeySpec;\n+import java.util.*;\n+\n+/**\n+ * Created by test on 7/15/17.\n+ */\n+public class KeyStoreObject {\n+    public static final String SSL_KEY_STORE_PREF_ID = \"sslKeyStore\";\n+\n+    public static final String TRUST_STORE_PREF_ID = \"trustStore\";\n+\n+    private static final Logger LOG = LoggerFactory.getLogger(KeyStoreObject.class);\n+\n+    protected String   keyStorePassword;\n+    protected KeyStore keystore;\n+\n+    protected String profileApiUrl;\n+\n+\n+    public KeyStoreObject() throws Exception {\n+        profileApiUrl = \"http://192.168.1.35:8080\" + \"/profile\";\n+        keystore = extractKeyStoreFromFile();\n+    }\n+\n+    public KeyStoreObject(String apiUrl) throws Exception {\n+        profileApiUrl = apiUrl + \"/profile\";\n+        keystore = extractKeyStoreFromFile();\n+    }\n+\n+\n+    protected KeyStore extractKeyStoreFromFile() throws Exception {\n+        String sslKeyStore = getPreferences().get(getKeyStorePreferenceName());\n+\n+        keyStorePassword = getKeyStorePassword();\n+        KeyStore ks = KeyStore.getInstance(\"JKS\");\n+\n+        if (sslKeyStore == null) {\n+            LOG.info(\"User KeyStore is null, creating a new one\");\n+            ks.load(null, keyStorePassword.toCharArray());\n+            return ks;\n+        }\n+        try (InputStream fis = new ByteArrayInputStream(Base64.decodeBase64(sslKeyStore))) {\n+            ks.load(fis, keyStorePassword.toCharArray());\n+        } catch (Exception e) {\n+            LOG.info(\"Couldn't load keystore file \");\n+            ks.load(null, keyStorePassword.toCharArray());\n+        }\n+\n+        return ks;\n+    }\n+\n+\n+    protected String getKeyStorePreferenceName() {\n+        return SSL_KEY_STORE_PREF_ID;\n+    }\n+\n+//    private String getUserId() {\n+//        return EnvironmentContext.getCurrent().;","path":"wsagent/che-datasource-api/src/main/java/org/eclipse/che/datasource/api/ssl/KeyStoreObject.java","position":89,"original_position":89,"commit_id":"e0921751c3ef6d7afe051f314d971009702ebf02","original_commit_id":"e0921751c3ef6d7afe051f314d971009702ebf02","user":{"login":"skabashnyuk","id":1614429,"avatar_url":"https://avatars0.githubusercontent.com/u/1614429?v=4","gravatar_id":"","url":"https://api.github.com/users/skabashnyuk","html_url":"https://github.com/skabashnyuk","followers_url":"https://api.github.com/users/skabashnyuk/followers","following_url":"https://api.github.com/users/skabashnyuk/following{/other_user}","gists_url":"https://api.github.com/users/skabashnyuk/gists{/gist_id}","starred_url":"https://api.github.com/users/skabashnyuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skabashnyuk/subscriptions","organizations_url":"https://api.github.com/users/skabashnyuk/orgs","repos_url":"https://api.github.com/users/skabashnyuk/repos","events_url":"https://api.github.com/users/skabashnyuk/events{/privacy}","received_events_url":"https://api.github.com/users/skabashnyuk/received_events","type":"User","site_admin":false},"body":"remove if not needed\r\n","created_at":"2017-07-20T08:50:42Z","updated_at":"2017-07-20T08:52:17Z","html_url":"https://github.com/eclipse/che/pull/5743#discussion_r128458397","pull_request_url":"https://api.github.com/repos/eclipse/che/pulls/5743","_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments/128458397"},"html":{"href":"https://github.com/eclipse/che/pull/5743#discussion_r128458397"},"pull_request":{"href":"https://api.github.com/repos/eclipse/che/pulls/5743"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/che/pulls/5743","id":131363830,"html_url":"https://github.com/eclipse/che/pull/5743","diff_url":"https://github.com/eclipse/che/pull/5743.diff","patch_url":"https://github.com/eclipse/che/pull/5743.patch","issue_url":"https://api.github.com/repos/eclipse/che/issues/5743","number":5743,"state":"open","locked":false,"title":"[WIP] Port Datasource Plugin From 3.X to 5.X ","user":{"login":"sudaraka94","id":15868287,"avatar_url":"https://avatars2.githubusercontent.com/u/15868287?v=4","gravatar_id":"","url":"https://api.github.com/users/sudaraka94","html_url":"https://github.com/sudaraka94","followers_url":"https://api.github.com/users/sudaraka94/followers","following_url":"https://api.github.com/users/sudaraka94/following{/other_user}","gists_url":"https://api.github.com/users/sudaraka94/gists{/gist_id}","starred_url":"https://api.github.com/users/sudaraka94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudaraka94/subscriptions","organizations_url":"https://api.github.com/users/sudaraka94/orgs","repos_url":"https://api.github.com/users/sudaraka94/repos","events_url":"https://api.github.com/users/sudaraka94/events{/privacy}","received_events_url":"https://api.github.com/users/sudaraka94/received_events","type":"User","site_admin":false},"body":"I am rewriting the deprecated datasource extension for che. ","created_at":"2017-07-19T16:22:25Z","updated_at":"2017-07-20T08:52:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d554dfd39540b1d73313670fafd5d6b8474d7883","assignee":null,"assignees":[],"requested_reviewers":[{"login":"evidolob","id":929743,"avatar_url":"https://avatars0.githubusercontent.com/u/929743?v=4","gravatar_id":"","url":"https://api.github.com/users/evidolob","html_url":"https://github.com/evidolob","followers_url":"https://api.github.com/users/evidolob/followers","following_url":"https://api.github.com/users/evidolob/following{/other_user}","gists_url":"https://api.github.com/users/evidolob/gists{/gist_id}","starred_url":"https://api.github.com/users/evidolob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evidolob/subscriptions","organizations_url":"https://api.github.com/users/evidolob/orgs","repos_url":"https://api.github.com/users/evidolob/repos","events_url":"https://api.github.com/users/evidolob/events{/privacy}","received_events_url":"https://api.github.com/users/evidolob/received_events","type":"User","site_admin":false},{"login":"dkuleshov","id":1632360,"avatar_url":"https://avatars0.githubusercontent.com/u/1632360?v=4","gravatar_id":"","url":"https://api.github.com/users/dkuleshov","html_url":"https://github.com/dkuleshov","followers_url":"https://api.github.com/users/dkuleshov/followers","following_url":"https://api.github.com/users/dkuleshov/following{/other_user}","gists_url":"https://api.github.com/users/dkuleshov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkuleshov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkuleshov/subscriptions","organizations_url":"https://api.github.com/users/dkuleshov/orgs","repos_url":"https://api.github.com/users/dkuleshov/repos","events_url":"https://api.github.com/users/dkuleshov/events{/privacy}","received_events_url":"https://api.github.com/users/dkuleshov/received_events","type":"User","site_admin":false},{"login":"vparfonov","id":1636592,"avatar_url":"https://avatars1.githubusercontent.com/u/1636592?v=4","gravatar_id":"","url":"https://api.github.com/users/vparfonov","html_url":"https://github.com/vparfonov","followers_url":"https://api.github.com/users/vparfonov/followers","following_url":"https://api.github.com/users/vparfonov/following{/other_user}","gists_url":"https://api.github.com/users/vparfonov/gists{/gist_id}","starred_url":"https://api.github.com/users/vparfonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vparfonov/subscriptions","organizations_url":"https://api.github.com/users/vparfonov/orgs","repos_url":"https://api.github.com/users/vparfonov/repos","events_url":"https://api.github.com/users/vparfonov/events{/privacy}","received_events_url":"https://api.github.com/users/vparfonov/received_events","type":"User","site_admin":false},{"login":"riuvshin","id":1636732,"avatar_url":"https://avatars2.githubusercontent.com/u/1636732?v=4","gravatar_id":"","url":"https://api.github.com/users/riuvshin","html_url":"https://github.com/riuvshin","followers_url":"https://api.github.com/users/riuvshin/followers","following_url":"https://api.github.com/users/riuvshin/following{/other_user}","gists_url":"https://api.github.com/users/riuvshin/gists{/gist_id}","starred_url":"https://api.github.com/users/riuvshin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/riuvshin/subscriptions","organizations_url":"https://api.github.com/users/riuvshin/orgs","repos_url":"https://api.github.com/users/riuvshin/repos","events_url":"https://api.github.com/users/riuvshin/events{/privacy}","received_events_url":"https://api.github.com/users/riuvshin/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/che/pulls/5743/commits","review_comments_url":"https://api.github.com/repos/eclipse/che/pulls/5743/comments","review_comment_url":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/che/issues/5743/comments","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/e0921751c3ef6d7afe051f314d971009702ebf02","head":{"label":"sudaraka94:master","ref":"master","sha":"e0921751c3ef6d7afe051f314d971009702ebf02","user":{"login":"sudaraka94","id":15868287,"avatar_url":"https://avatars2.githubusercontent.com/u/15868287?v=4","gravatar_id":"","url":"https://api.github.com/users/sudaraka94","html_url":"https://github.com/sudaraka94","followers_url":"https://api.github.com/users/sudaraka94/followers","following_url":"https://api.github.com/users/sudaraka94/following{/other_user}","gists_url":"https://api.github.com/users/sudaraka94/gists{/gist_id}","starred_url":"https://api.github.com/users/sudaraka94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudaraka94/subscriptions","organizations_url":"https://api.github.com/users/sudaraka94/orgs","repos_url":"https://api.github.com/users/sudaraka94/repos","events_url":"https://api.github.com/users/sudaraka94/events{/privacy}","received_events_url":"https://api.github.com/users/sudaraka94/received_events","type":"User","site_admin":false},"repo":{"id":96438872,"name":"che","full_name":"sudaraka94/che","owner":{"login":"sudaraka94","id":15868287,"avatar_url":"https://avatars2.githubusercontent.com/u/15868287?v=4","gravatar_id":"","url":"https://api.github.com/users/sudaraka94","html_url":"https://github.com/sudaraka94","followers_url":"https://api.github.com/users/sudaraka94/followers","following_url":"https://api.github.com/users/sudaraka94/following{/other_user}","gists_url":"https://api.github.com/users/sudaraka94/gists{/gist_id}","starred_url":"https://api.github.com/users/sudaraka94/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sudaraka94/subscriptions","organizations_url":"https://api.github.com/users/sudaraka94/orgs","repos_url":"https://api.github.com/users/sudaraka94/repos","events_url":"https://api.github.com/users/sudaraka94/events{/privacy}","received_events_url":"https://api.github.com/users/sudaraka94/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sudaraka94/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":true,"url":"https://api.github.com/repos/sudaraka94/che","forks_url":"https://api.github.com/repos/sudaraka94/che/forks","keys_url":"https://api.github.com/repos/sudaraka94/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sudaraka94/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sudaraka94/che/teams","hooks_url":"https://api.github.com/repos/sudaraka94/che/hooks","issue_events_url":"https://api.github.com/repos/sudaraka94/che/issues/events{/number}","events_url":"https://api.github.com/repos/sudaraka94/che/events","assignees_url":"https://api.github.com/repos/sudaraka94/che/assignees{/user}","branches_url":"https://api.github.com/repos/sudaraka94/che/branches{/branch}","tags_url":"https://api.github.com/repos/sudaraka94/che/tags","blobs_url":"https://api.github.com/repos/sudaraka94/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sudaraka94/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sudaraka94/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/sudaraka94/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sudaraka94/che/statuses/{sha}","languages_url":"https://api.github.com/repos/sudaraka94/che/languages","stargazers_url":"https://api.github.com/repos/sudaraka94/che/stargazers","contributors_url":"https://api.github.com/repos/sudaraka94/che/contributors","subscribers_url":"https://api.github.com/repos/sudaraka94/che/subscribers","subscription_url":"https://api.github.com/repos/sudaraka94/che/subscription","commits_url":"https://api.github.com/repos/sudaraka94/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/sudaraka94/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/sudaraka94/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/sudaraka94/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/sudaraka94/che/contents/{+path}","compare_url":"https://api.github.com/repos/sudaraka94/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sudaraka94/che/merges","archive_url":"https://api.github.com/repos/sudaraka94/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sudaraka94/che/downloads","issues_url":"https://api.github.com/repos/sudaraka94/che/issues{/number}","pulls_url":"https://api.github.com/repos/sudaraka94/che/pulls{/number}","milestones_url":"https://api.github.com/repos/sudaraka94/che/milestones{/number}","notifications_url":"https://api.github.com/repos/sudaraka94/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sudaraka94/che/labels{/name}","releases_url":"https://api.github.com/repos/sudaraka94/che/releases{/id}","deployments_url":"https://api.github.com/repos/sudaraka94/che/deployments","created_at":"2017-07-06T14:25:18Z","updated_at":"2017-07-06T14:25:43Z","pushed_at":"2017-07-17T19:26:12Z","git_url":"git://github.com/sudaraka94/che.git","ssh_url":"git@github.com:sudaraka94/che.git","clone_url":"https://github.com/sudaraka94/che.git","svn_url":"https://github.com/sudaraka94/che","homepage":"http://eclipse.org/che","size":50796,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"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":"eclipse:master","ref":"master","sha":"185273f8b92fe5523e676255cd7be172e90ee418","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":32935745,"name":"che","full_name":"eclipse/che","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/che","description":"Eclipse Che: Next-generation Eclipse IDE.  Open source workspace server and cloud IDE.","fork":false,"url":"https://api.github.com/repos/eclipse/che","forks_url":"https://api.github.com/repos/eclipse/che/forks","keys_url":"https://api.github.com/repos/eclipse/che/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/che/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/che/teams","hooks_url":"https://api.github.com/repos/eclipse/che/hooks","issue_events_url":"https://api.github.com/repos/eclipse/che/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/che/events","assignees_url":"https://api.github.com/repos/eclipse/che/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/che/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/che/tags","blobs_url":"https://api.github.com/repos/eclipse/che/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/che/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/che/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/che/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/che/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/che/languages","stargazers_url":"https://api.github.com/repos/eclipse/che/stargazers","contributors_url":"https://api.github.com/repos/eclipse/che/contributors","subscribers_url":"https://api.github.com/repos/eclipse/che/subscribers","subscription_url":"https://api.github.com/repos/eclipse/che/subscription","commits_url":"https://api.github.com/repos/eclipse/che/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/che/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/che/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/che/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/che/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/che/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/che/merges","archive_url":"https://api.github.com/repos/eclipse/che/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/che/downloads","issues_url":"https://api.github.com/repos/eclipse/che/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/che/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/che/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/che/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/che/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/che/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/che/deployments","created_at":"2015-03-26T15:31:01Z","updated_at":"2017-07-19T19:59:11Z","pushed_at":"2017-07-20T08:48:18Z","git_url":"git://github.com/eclipse/che.git","ssh_url":"git@github.com:eclipse/che.git","clone_url":"https://github.com/eclipse/che.git","svn_url":"https://github.com/eclipse/che","homepage":"http://eclipse.org/che","size":57483,"stargazers_count":4236,"watchers_count":4236,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":712,"mirror_url":null,"open_issues_count":431,"forks":712,"open_issues":431,"watchers":4236,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/che/pulls/5743"},"html":{"href":"https://github.com/eclipse/che/pull/5743"},"issue":{"href":"https://api.github.com/repos/eclipse/che/issues/5743"},"comments":{"href":"https://api.github.com/repos/eclipse/che/issues/5743/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/che/pulls/5743/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/che/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/che/pulls/5743/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/che/statuses/e0921751c3ef6d7afe051f314d971009702ebf02"}}}}
{"actor":{"display_login":"skabashnyuk"}}