{"action":"created","comment":{"url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/comments/22572421","id":22572421,"diff_hunk":"@@ -0,0 +1,210 @@\n+package com.emc.greenplum.hadoop.plugins;\n+\n+import java.lang.Exception;\n+import java.lang.reflect.InvocationTargetException;\n+import java.lang.reflect.Method;\n+import java.lang.reflect.UndeclaredThrowableException;\n+import java.net.InetAddress;\n+import java.net.URI;\n+import java.security.PrivilegedActionException;\n+import java.security.PrivilegedExceptionAction;\n+import java.util.*;\n+import java.util.logging.*;\n+import java.io.*;\n+\n+import org.apache.hadoop.conf.Configuration;\n+import org.apache.hadoop.fs.FileSystem;\n+import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifier;\n+import org.apache.hadoop.io.Text;\n+import org.apache.hadoop.net.NetUtils;\n+import org.apache.hadoop.security.UserGroupInformation;\n+import org.apache.hadoop.security.token.Token;\n+\n+/**\n+ *\n+ * Modified from SecurityUtil2.scala in the alpine code.\n+ */\n+\n+public class HdfsSecurityUtil {\n+\n+    public static final String METHOD_DOAS = \"doAs\";\n+    public static final String METHOD_CREATE_REMOTE_USER = \"createRemoteUser\";\n+    public static final String HDFS_DELEGATION_TOKEN = \"hdfs.delegation.token\";\n+    public static final String ALPINE_KEYTAB    =  \"alpine.keytab\";\n+    public static final String ALPINE_PRINCIPAL =  \"alpine.principal\";\n+    public static final String AUTHENTICATION_KEY = \"hadoop.security.authentication\";\n+    public static final String PROPERTY_FS_NAME = \"fs.default.name\";\n+    public static final String HDFS_PREFIX = \"hdfs://\";\n+\n+    // import scala.collection.mutable\n+    private static Map<String, UserGroupInformation> ugiMap = new HashMap<String, UserGroupInformation>();\n+    private static Set<UserGroupInformation> hdfsTokenUGIs = new HashSet<UserGroupInformation>();\n+\n+    // Retrieve cached UGI object based on Hadoop connection name and principal\n+    public static UserGroupInformation getCachedUserGroupInfo(String connName, String principal) {\n+        return ugiMap.get(connName + \"_\" + principal);\n+    }\n+\n+    public static UserGroupInformation createUserForHDFS(String user, Configuration configuration, String host, String port, String connectionName, boolean isHA, String chorusUsername) throws Exception {\n+\n+        UserGroupInformation loginUser = kerberosInitForHDFS(configuration, host, port, connectionName, isHA);","path":"hdfs-plugin-v3/src/com/emc/greenplum/hadoop/plugins/HdfsSecurityUtil.java","position":50,"original_position":50,"commit_id":"64d18007a0576008fc8350a554356267b7f422f1","original_commit_id":"64d18007a0576008fc8350a554356267b7f422f1","user":{"login":"jleealpine","id":5476605,"avatar_url":"https://avatars.githubusercontent.com/u/5476605?v=3","gravatar_id":"","url":"https://api.github.com/users/jleealpine","html_url":"https://github.com/jleealpine","followers_url":"https://api.github.com/users/jleealpine/followers","following_url":"https://api.github.com/users/jleealpine/following{/other_user}","gists_url":"https://api.github.com/users/jleealpine/gists{/gist_id}","starred_url":"https://api.github.com/users/jleealpine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jleealpine/subscriptions","organizations_url":"https://api.github.com/users/jleealpine/orgs","repos_url":"https://api.github.com/users/jleealpine/repos","events_url":"https://api.github.com/users/jleealpine/events{/privacy}","received_events_url":"https://api.github.com/users/jleealpine/received_events","type":"User","site_admin":false},"body":"changed","created_at":"2015-01-07T06:17:19Z","updated_at":"2015-01-07T06:17:19Z","html_url":"https://github.com/Chorus/chorushdfs/pull/2#discussion_r22572421","pull_request_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/comments/22572421"},"html":{"href":"https://github.com/Chorus/chorushdfs/pull/2#discussion_r22572421"},"pull_request":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2","id":26929164,"html_url":"https://github.com/Chorus/chorushdfs/pull/2","diff_url":"https://github.com/Chorus/chorushdfs/pull/2.diff","patch_url":"https://github.com/Chorus/chorushdfs/pull/2.patch","issue_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/2","number":2,"state":"open","locked":false,"title":"Kerberos stuff","user":{"login":"jleealpine","id":5476605,"avatar_url":"https://avatars.githubusercontent.com/u/5476605?v=3","gravatar_id":"","url":"https://api.github.com/users/jleealpine","html_url":"https://github.com/jleealpine","followers_url":"https://api.github.com/users/jleealpine/followers","following_url":"https://api.github.com/users/jleealpine/following{/other_user}","gists_url":"https://api.github.com/users/jleealpine/gists{/gist_id}","starred_url":"https://api.github.com/users/jleealpine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jleealpine/subscriptions","organizations_url":"https://api.github.com/users/jleealpine/orgs","repos_url":"https://api.github.com/users/jleealpine/repos","events_url":"https://api.github.com/users/jleealpine/events{/privacy}","received_events_url":"https://api.github.com/users/jleealpine/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-07T00:20:47Z","updated_at":"2015-01-07T06:17:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8b67493afde9ba79a5bfd431a38fdfbfd71fef1b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/2/comments","statuses_url":"https://api.github.com/repos/Chorus/chorushdfs/statuses/64d18007a0576008fc8350a554356267b7f422f1","head":{"label":"Chorus:kerberos_stuff","ref":"kerberos_stuff","sha":"64d18007a0576008fc8350a554356267b7f422f1","user":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"repo":{"id":4410137,"name":"chorushdfs","full_name":"Chorus/chorushdfs","owner":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Chorus/chorushdfs","description":"This is an interface for loading Hadoop jars for different versions. It supports the Chorus data analytics project","fork":false,"url":"https://api.github.com/repos/Chorus/chorushdfs","forks_url":"https://api.github.com/repos/Chorus/chorushdfs/forks","keys_url":"https://api.github.com/repos/Chorus/chorushdfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Chorus/chorushdfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Chorus/chorushdfs/teams","hooks_url":"https://api.github.com/repos/Chorus/chorushdfs/hooks","issue_events_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/events{/number}","events_url":"https://api.github.com/repos/Chorus/chorushdfs/events","assignees_url":"https://api.github.com/repos/Chorus/chorushdfs/assignees{/user}","branches_url":"https://api.github.com/repos/Chorus/chorushdfs/branches{/branch}","tags_url":"https://api.github.com/repos/Chorus/chorushdfs/tags","blobs_url":"https://api.github.com/repos/Chorus/chorushdfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Chorus/chorushdfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Chorus/chorushdfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Chorus/chorushdfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Chorus/chorushdfs/statuses/{sha}","languages_url":"https://api.github.com/repos/Chorus/chorushdfs/languages","stargazers_url":"https://api.github.com/repos/Chorus/chorushdfs/stargazers","contributors_url":"https://api.github.com/repos/Chorus/chorushdfs/contributors","subscribers_url":"https://api.github.com/repos/Chorus/chorushdfs/subscribers","subscription_url":"https://api.github.com/repos/Chorus/chorushdfs/subscription","commits_url":"https://api.github.com/repos/Chorus/chorushdfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Chorus/chorushdfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Chorus/chorushdfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/Chorus/chorushdfs/contents/{+path}","compare_url":"https://api.github.com/repos/Chorus/chorushdfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Chorus/chorushdfs/merges","archive_url":"https://api.github.com/repos/Chorus/chorushdfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Chorus/chorushdfs/downloads","issues_url":"https://api.github.com/repos/Chorus/chorushdfs/issues{/number}","pulls_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls{/number}","milestones_url":"https://api.github.com/repos/Chorus/chorushdfs/milestones{/number}","notifications_url":"https://api.github.com/repos/Chorus/chorushdfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Chorus/chorushdfs/labels{/name}","releases_url":"https://api.github.com/repos/Chorus/chorushdfs/releases{/id}","created_at":"2012-05-22T17:30:28Z","updated_at":"2014-12-12T19:16:18Z","pushed_at":"2015-01-07T00:19:58Z","git_url":"git://github.com/Chorus/chorushdfs.git","ssh_url":"git@github.com:Chorus/chorushdfs.git","clone_url":"https://github.com/Chorus/chorushdfs.git","svn_url":"https://github.com/Chorus/chorushdfs","homepage":"https://github.com/Chorus/chorus/","size":63797,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"Chorus:master","ref":"master","sha":"f6b7ab9936f6032c4358a11d3e5c643264d026c5","user":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"repo":{"id":4410137,"name":"chorushdfs","full_name":"Chorus/chorushdfs","owner":{"login":"Chorus","id":5614676,"avatar_url":"https://avatars.githubusercontent.com/u/5614676?v=3","gravatar_id":"","url":"https://api.github.com/users/Chorus","html_url":"https://github.com/Chorus","followers_url":"https://api.github.com/users/Chorus/followers","following_url":"https://api.github.com/users/Chorus/following{/other_user}","gists_url":"https://api.github.com/users/Chorus/gists{/gist_id}","starred_url":"https://api.github.com/users/Chorus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chorus/subscriptions","organizations_url":"https://api.github.com/users/Chorus/orgs","repos_url":"https://api.github.com/users/Chorus/repos","events_url":"https://api.github.com/users/Chorus/events{/privacy}","received_events_url":"https://api.github.com/users/Chorus/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Chorus/chorushdfs","description":"This is an interface for loading Hadoop jars for different versions. It supports the Chorus data analytics project","fork":false,"url":"https://api.github.com/repos/Chorus/chorushdfs","forks_url":"https://api.github.com/repos/Chorus/chorushdfs/forks","keys_url":"https://api.github.com/repos/Chorus/chorushdfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Chorus/chorushdfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Chorus/chorushdfs/teams","hooks_url":"https://api.github.com/repos/Chorus/chorushdfs/hooks","issue_events_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/events{/number}","events_url":"https://api.github.com/repos/Chorus/chorushdfs/events","assignees_url":"https://api.github.com/repos/Chorus/chorushdfs/assignees{/user}","branches_url":"https://api.github.com/repos/Chorus/chorushdfs/branches{/branch}","tags_url":"https://api.github.com/repos/Chorus/chorushdfs/tags","blobs_url":"https://api.github.com/repos/Chorus/chorushdfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Chorus/chorushdfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Chorus/chorushdfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/Chorus/chorushdfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Chorus/chorushdfs/statuses/{sha}","languages_url":"https://api.github.com/repos/Chorus/chorushdfs/languages","stargazers_url":"https://api.github.com/repos/Chorus/chorushdfs/stargazers","contributors_url":"https://api.github.com/repos/Chorus/chorushdfs/contributors","subscribers_url":"https://api.github.com/repos/Chorus/chorushdfs/subscribers","subscription_url":"https://api.github.com/repos/Chorus/chorushdfs/subscription","commits_url":"https://api.github.com/repos/Chorus/chorushdfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/Chorus/chorushdfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/Chorus/chorushdfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/Chorus/chorushdfs/issues/comments/{number}","contents_url":"https://api.github.com/repos/Chorus/chorushdfs/contents/{+path}","compare_url":"https://api.github.com/repos/Chorus/chorushdfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Chorus/chorushdfs/merges","archive_url":"https://api.github.com/repos/Chorus/chorushdfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Chorus/chorushdfs/downloads","issues_url":"https://api.github.com/repos/Chorus/chorushdfs/issues{/number}","pulls_url":"https://api.github.com/repos/Chorus/chorushdfs/pulls{/number}","milestones_url":"https://api.github.com/repos/Chorus/chorushdfs/milestones{/number}","notifications_url":"https://api.github.com/repos/Chorus/chorushdfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Chorus/chorushdfs/labels{/name}","releases_url":"https://api.github.com/repos/Chorus/chorushdfs/releases{/id}","created_at":"2012-05-22T17:30:28Z","updated_at":"2014-12-12T19:16:18Z","pushed_at":"2015-01-07T00:19:58Z","git_url":"git://github.com/Chorus/chorushdfs.git","ssh_url":"git@github.com:Chorus/chorushdfs.git","clone_url":"https://github.com/Chorus/chorushdfs.git","svn_url":"https://github.com/Chorus/chorushdfs","homepage":"https://github.com/Chorus/chorus/","size":63797,"stargazers_count":3,"watchers_count":3,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2"},"html":{"href":"https://github.com/Chorus/chorushdfs/pull/2"},"issue":{"href":"https://api.github.com/repos/Chorus/chorushdfs/issues/2"},"comments":{"href":"https://api.github.com/repos/Chorus/chorushdfs/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Chorus/chorushdfs/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Chorus/chorushdfs/statuses/64d18007a0576008fc8350a554356267b7f422f1"}}}}