{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/comments/82892498","pull_request_review_id":3767921,"id":82892498,"diff_hunk":"@@ -0,0 +1,142 @@\n+/*\n+ * The MIT License\n+ *\n+ * Copyright 2013 jglick.\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included in\n+ * all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n+ * THE SOFTWARE.\n+ */\n+\n+package org.jenkinsci.plugins.credentialsbinding.impl;\n+\n+import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey;\n+import hudson.Extension;\n+import hudson.FilePath;\n+import hudson.Launcher;\n+import hudson.model.Run;\n+import hudson.model.TaskListener;\n+import hudson.remoting.VirtualChannel;\n+import hudson.util.Secret;\n+import org.jenkinsci.plugins.credentialsbinding.BindingDescriptor;\n+import org.jenkinsci.plugins.credentialsbinding.MultiBinding;\n+import org.jenkinsci.remoting.RoleChecker;\n+import org.kohsuke.stapler.DataBoundConstructor;\n+\n+import java.io.File;\n+import java.io.IOException;\n+import java.io.PrintWriter;\n+import java.io.StringWriter;\n+import java.util.*;\n+\n+public class SSHUserPrivateKeyBinding extends MultiBinding<SSHUserPrivateKey> {\n+\n+    public final String keyFileVariable;\n+    public final String usernameVariable;\n+    public final String passphraseVariable;\n+\n+    @DataBoundConstructor public SSHUserPrivateKeyBinding(String keyFileVariable, String passphraseVariable, String usernameVariable, String credentialsId) {\n+        super(credentialsId);\n+        this.keyFileVariable = keyFileVariable;\n+        this.usernameVariable = usernameVariable;\n+        this.passphraseVariable = passphraseVariable;\n+    }\n+\n+    @Override protected Class<SSHUserPrivateKey> type() {\n+        return SSHUserPrivateKey.class;\n+    }\n+\n+    private static FilePath newTempFile(FilePath workspace, final String prefix, final String suffix) throws IOException, InterruptedException {\n+        try {\n+            return new FilePath(workspace.getChannel(), workspace.act(new FilePath.FileCallable<String>() {\n+                @Override\n+                public String invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException {\n+                    File f = File.createTempFile(prefix, suffix);\n+                    return f.getAbsolutePath();\n+                }\n+\n+                @Override\n+                public void checkRoles(RoleChecker checker) throws SecurityException {\n+                    // no op\n+                }\n+            }));\n+        } catch (IOException e) {\n+            throw new IOException(\"Failed to create a temp file on \" + workspace.getRemote(), e);\n+        }\n+    }\n+\n+    @Override public Set<String> variables() {\n+        return new HashSet<String>(Arrays.asList(keyFileVariable, usernameVariable, passphraseVariable));","path":"src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/SSHUserPrivateKeyBinding.java","position":83,"original_position":83,"commit_id":"cce9aa295bafbf06bb3ae0d3afeddf09b642db8d","original_commit_id":"cce9aa295bafbf06bb3ae0d3afeddf09b642db8d","user":{"login":"jglick","id":154109,"avatar_url":"https://avatars.githubusercontent.com/u/154109?v=3","gravatar_id":"","url":"https://api.github.com/users/jglick","html_url":"https://github.com/jglick","followers_url":"https://api.github.com/users/jglick/followers","following_url":"https://api.github.com/users/jglick/following{/other_user}","gists_url":"https://api.github.com/users/jglick/gists{/gist_id}","starred_url":"https://api.github.com/users/jglick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jglick/subscriptions","organizations_url":"https://api.github.com/users/jglick/orgs","repos_url":"https://api.github.com/users/jglick/repos","events_url":"https://api.github.com/users/jglick/events{/privacy}","received_events_url":"https://api.github.com/users/jglick/received_events","type":"User","site_admin":false},"body":"tip: `ImmutableSet.of`","created_at":"2016-10-11T21:24:31Z","updated_at":"2016-10-11T21:24:31Z","html_url":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18#discussion_r82892498","pull_request_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/comments/82892498"},"html":{"href":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18#discussion_r82892498"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18","id":75167691,"html_url":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18","diff_url":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18.diff","patch_url":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18.patch","issue_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/18","number":18,"state":"open","locked":false,"title":"[JENKINS-28399] Add binding for SSH private keys","user":{"login":"matthauck","id":1308591,"avatar_url":"https://avatars.githubusercontent.com/u/1308591?v=3","gravatar_id":"","url":"https://api.github.com/users/matthauck","html_url":"https://github.com/matthauck","followers_url":"https://api.github.com/users/matthauck/followers","following_url":"https://api.github.com/users/matthauck/following{/other_user}","gists_url":"https://api.github.com/users/matthauck/gists{/gist_id}","starred_url":"https://api.github.com/users/matthauck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthauck/subscriptions","organizations_url":"https://api.github.com/users/matthauck/orgs","repos_url":"https://api.github.com/users/matthauck/repos","events_url":"https://api.github.com/users/matthauck/events{/privacy}","received_events_url":"https://api.github.com/users/matthauck/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-06-24T20:16:40Z","updated_at":"2016-10-11T21:29:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"363dc7e2776aa9580c9ae1642b914a062b60fdca","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/18/comments","statuses_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/statuses/cce9aa295bafbf06bb3ae0d3afeddf09b642db8d","head":{"label":"matthauck:ssh-key-creds","ref":"ssh-key-creds","sha":"cce9aa295bafbf06bb3ae0d3afeddf09b642db8d","user":{"login":"matthauck","id":1308591,"avatar_url":"https://avatars.githubusercontent.com/u/1308591?v=3","gravatar_id":"","url":"https://api.github.com/users/matthauck","html_url":"https://github.com/matthauck","followers_url":"https://api.github.com/users/matthauck/followers","following_url":"https://api.github.com/users/matthauck/following{/other_user}","gists_url":"https://api.github.com/users/matthauck/gists{/gist_id}","starred_url":"https://api.github.com/users/matthauck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthauck/subscriptions","organizations_url":"https://api.github.com/users/matthauck/orgs","repos_url":"https://api.github.com/users/matthauck/repos","events_url":"https://api.github.com/users/matthauck/events{/privacy}","received_events_url":"https://api.github.com/users/matthauck/received_events","type":"User","site_admin":false},"repo":{"id":61835319,"name":"credentials-binding-plugin","full_name":"matthauck/credentials-binding-plugin","owner":{"login":"matthauck","id":1308591,"avatar_url":"https://avatars.githubusercontent.com/u/1308591?v=3","gravatar_id":"","url":"https://api.github.com/users/matthauck","html_url":"https://github.com/matthauck","followers_url":"https://api.github.com/users/matthauck/followers","following_url":"https://api.github.com/users/matthauck/following{/other_user}","gists_url":"https://api.github.com/users/matthauck/gists{/gist_id}","starred_url":"https://api.github.com/users/matthauck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthauck/subscriptions","organizations_url":"https://api.github.com/users/matthauck/orgs","repos_url":"https://api.github.com/users/matthauck/repos","events_url":"https://api.github.com/users/matthauck/events{/privacy}","received_events_url":"https://api.github.com/users/matthauck/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/matthauck/credentials-binding-plugin","description":"","fork":true,"url":"https://api.github.com/repos/matthauck/credentials-binding-plugin","forks_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/forks","keys_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/teams","hooks_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/hooks","issue_events_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/events","assignees_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/tags","blobs_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/languages","stargazers_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/stargazers","contributors_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/contributors","subscribers_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/subscribers","subscription_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/subscription","commits_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/merges","archive_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/downloads","issues_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/labels{/name}","releases_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/matthauck/credentials-binding-plugin/deployments","created_at":"2016-06-23T20:37:32Z","updated_at":"2016-06-23T20:37:33Z","pushed_at":"2016-06-24T20:34:44Z","git_url":"git://github.com/matthauck/credentials-binding-plugin.git","ssh_url":"git@github.com:matthauck/credentials-binding-plugin.git","clone_url":"https://github.com/matthauck/credentials-binding-plugin.git","svn_url":"https://github.com/matthauck/credentials-binding-plugin","homepage":"","size":123,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"jenkinsci:master","ref":"master","sha":"ce2641a4244b8c9de44f808725b23ff8d86adbae","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":13251519,"name":"credentials-binding-plugin","full_name":"jenkinsci/credentials-binding-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/credentials-binding-plugin","description":"","fork":false,"url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin","forks_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/deployments","created_at":"2013-10-01T18:18:46Z","updated_at":"2016-09-05T03:13:22Z","pushed_at":"2016-09-22T15:58:42Z","git_url":"git://github.com/jenkinsci/credentials-binding-plugin.git","ssh_url":"git@github.com:jenkinsci/credentials-binding-plugin.git","clone_url":"https://github.com/jenkinsci/credentials-binding-plugin.git","svn_url":"https://github.com/jenkinsci/credentials-binding-plugin","homepage":"","size":195,"stargazers_count":6,"watchers_count":6,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":6,"forks":26,"open_issues":6,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18"},"html":{"href":"https://github.com/jenkinsci/credentials-binding-plugin/pull/18"},"issue":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/18"},"comments":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/credentials-binding-plugin/statuses/cce9aa295bafbf06bb3ae0d3afeddf09b642db8d"}}}}
{"actor":{"display_login":"jglick"}}