{"action":"created","comment":{"url":"https://api.github.com/repos/airlift/airlift/pulls/comments/28199812","id":28199812,"diff_hunk":"@@ -0,0 +1,243 @@\n+package io.airlift.security.utils;\n+\n+import com.google.common.base.Throwables;\n+import io.airlift.log.Logger;\n+import io.airlift.security.exception.AuthenticationException;\n+import org.ietf.jgss.GSSContext;\n+import org.ietf.jgss.GSSCredential;\n+import org.ietf.jgss.GSSException;\n+import org.ietf.jgss.GSSManager;\n+import org.ietf.jgss.GSSName;\n+import org.ietf.jgss.Oid;\n+\n+import javax.security.auth.Subject;\n+import javax.security.auth.login.AppConfigurationEntry;\n+import javax.security.auth.login.Configuration;\n+import javax.security.auth.login.LoginContext;\n+import javax.security.auth.login.LoginException;\n+import java.lang.reflect.Field;\n+import java.lang.reflect.InvocationTargetException;\n+import java.lang.reflect.Method;\n+import java.net.InetAddress;\n+import java.net.UnknownHostException;\n+import java.security.Principal;\n+import java.security.PrivilegedAction;\n+import java.util.HashMap;\n+import java.util.Locale;\n+import java.util.Map;\n+\n+import static com.google.common.base.Preconditions.checkState;\n+\n+public class KerberosUtil\n+{\n+    private static final Oid SPNEGO_OID;\n+    private static final Oid KERBEROS_OID;\n+    private static final Oid[] SUPPORTED_OIDS;\n+\n+    static {\n+        try {\n+            SPNEGO_OID = new Oid(\"1.3.6.1.5.5.2\");\n+            KERBEROS_OID = new Oid(\"1.2.840.113554.1.2.2\");\n+            SUPPORTED_OIDS = new Oid[]{SPNEGO_OID, KERBEROS_OID};\n+        } catch (GSSException e) {\n+            throw new AuthenticationException(e);\n+        }\n+    }\n+\n+    /* Return the Kerberos login module name */\n+    public static String getKrb5LoginModuleName()\n+    {\n+        return System.getProperty(\"java.vendor\").contains(\"IBM\")\n+                ? \"com.ibm.security.auth.module.Krb5LoginModule\"\n+                : \"com.sun.security.auth.module.Krb5LoginModule\";\n+    }\n+\n+    public static Oid getOidInstance(String oidName)\n+            throws GSSException, ClassNotFoundException, NoSuchFieldException,\n+            IllegalAccessException\n+    {\n+        Class<?> oidClass;\n+        if (System.getProperty(\"java.vendor\").contains(\"IBM\")) {\n+            oidClass = Class.forName(\"com.ibm.security.jgss.GSSUtil\");\n+        }\n+        else {\n+            oidClass = Class.forName(\"sun.security.jgss.GSSUtil\");\n+        }\n+        Field oidField = oidClass.getDeclaredField(oidName);\n+        return (Oid) oidField.get(oidClass);\n+    }\n+\n+    public static String getDefaultRealm()\n+            throws ClassNotFoundException, NoSuchMethodException,\n+            IllegalArgumentException, IllegalAccessException,\n+            InvocationTargetException\n+    {\n+        Object kerbConf;\n+        Class<?> classRef;\n+        Method getInstanceMethod;\n+        Method getDefaultRealmMethod;","path":"security/src/main/java/io/airlift/security/utils/KerberosUtil.java","position":78,"original_position":78,"commit_id":"1306374bcffc80cc68264eced94502365252075e","original_commit_id":"1306374bcffc80cc68264eced94502365252075e","user":{"login":"martint","id":14387,"avatar_url":"https://avatars.githubusercontent.com/u/14387?v=3","gravatar_id":"","url":"https://api.github.com/users/martint","html_url":"https://github.com/martint","followers_url":"https://api.github.com/users/martint/followers","following_url":"https://api.github.com/users/martint/following{/other_user}","gists_url":"https://api.github.com/users/martint/gists{/gist_id}","starred_url":"https://api.github.com/users/martint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martint/subscriptions","organizations_url":"https://api.github.com/users/martint/orgs","repos_url":"https://api.github.com/users/martint/repos","events_url":"https://api.github.com/users/martint/events{/privacy}","received_events_url":"https://api.github.com/users/martint/received_events","type":"User","site_admin":false},"body":"Move the declarations to where the variables are initialized","created_at":"2015-04-12T01:13:16Z","updated_at":"2015-04-12T01:13:16Z","html_url":"https://github.com/airlift/airlift/pull/291#discussion_r28199812","pull_request_url":"https://api.github.com/repos/airlift/airlift/pulls/291","_links":{"self":{"href":"https://api.github.com/repos/airlift/airlift/pulls/comments/28199812"},"html":{"href":"https://github.com/airlift/airlift/pull/291#discussion_r28199812"},"pull_request":{"href":"https://api.github.com/repos/airlift/airlift/pulls/291"}}},"pull_request":{"url":"https://api.github.com/repos/airlift/airlift/pulls/291","id":31370926,"html_url":"https://github.com/airlift/airlift/pull/291","diff_url":"https://github.com/airlift/airlift/pull/291.diff","patch_url":"https://github.com/airlift/airlift/pull/291.patch","issue_url":"https://api.github.com/repos/airlift/airlift/issues/291","number":291,"state":"open","locked":false,"title":"Add support for client authentication","user":{"login":"zhenyuy-fb","id":9911545,"avatar_url":"https://avatars.githubusercontent.com/u/9911545?v=3","gravatar_id":"","url":"https://api.github.com/users/zhenyuy-fb","html_url":"https://github.com/zhenyuy-fb","followers_url":"https://api.github.com/users/zhenyuy-fb/followers","following_url":"https://api.github.com/users/zhenyuy-fb/following{/other_user}","gists_url":"https://api.github.com/users/zhenyuy-fb/gists{/gist_id}","starred_url":"https://api.github.com/users/zhenyuy-fb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhenyuy-fb/subscriptions","organizations_url":"https://api.github.com/users/zhenyuy-fb/orgs","repos_url":"https://api.github.com/users/zhenyuy-fb/repos","events_url":"https://api.github.com/users/zhenyuy-fb/events{/privacy}","received_events_url":"https://api.github.com/users/zhenyuy-fb/received_events","type":"User","site_admin":false},"body":"Add support for client authentication.","created_at":"2015-03-17T19:47:04Z","updated_at":"2015-04-12T01:13:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6ef3c4cf104f7341e5418cf671a51b48bb03cbe3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/airlift/airlift/pulls/291/commits","review_comments_url":"https://api.github.com/repos/airlift/airlift/pulls/291/comments","review_comment_url":"https://api.github.com/repos/airlift/airlift/pulls/comments{/number}","comments_url":"https://api.github.com/repos/airlift/airlift/issues/291/comments","statuses_url":"https://api.github.com/repos/airlift/airlift/statuses/1306374bcffc80cc68264eced94502365252075e","head":{"label":"zhenyuy-fb:master","ref":"master","sha":"1306374bcffc80cc68264eced94502365252075e","user":{"login":"zhenyuy-fb","id":9911545,"avatar_url":"https://avatars.githubusercontent.com/u/9911545?v=3","gravatar_id":"","url":"https://api.github.com/users/zhenyuy-fb","html_url":"https://github.com/zhenyuy-fb","followers_url":"https://api.github.com/users/zhenyuy-fb/followers","following_url":"https://api.github.com/users/zhenyuy-fb/following{/other_user}","gists_url":"https://api.github.com/users/zhenyuy-fb/gists{/gist_id}","starred_url":"https://api.github.com/users/zhenyuy-fb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhenyuy-fb/subscriptions","organizations_url":"https://api.github.com/users/zhenyuy-fb/orgs","repos_url":"https://api.github.com/users/zhenyuy-fb/repos","events_url":"https://api.github.com/users/zhenyuy-fb/events{/privacy}","received_events_url":"https://api.github.com/users/zhenyuy-fb/received_events","type":"User","site_admin":false},"repo":{"id":30994348,"name":"airlift","full_name":"zhenyuy-fb/airlift","owner":{"login":"zhenyuy-fb","id":9911545,"avatar_url":"https://avatars.githubusercontent.com/u/9911545?v=3","gravatar_id":"","url":"https://api.github.com/users/zhenyuy-fb","html_url":"https://github.com/zhenyuy-fb","followers_url":"https://api.github.com/users/zhenyuy-fb/followers","following_url":"https://api.github.com/users/zhenyuy-fb/following{/other_user}","gists_url":"https://api.github.com/users/zhenyuy-fb/gists{/gist_id}","starred_url":"https://api.github.com/users/zhenyuy-fb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zhenyuy-fb/subscriptions","organizations_url":"https://api.github.com/users/zhenyuy-fb/orgs","repos_url":"https://api.github.com/users/zhenyuy-fb/repos","events_url":"https://api.github.com/users/zhenyuy-fb/events{/privacy}","received_events_url":"https://api.github.com/users/zhenyuy-fb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zhenyuy-fb/airlift","description":"Airlift framework for building REST services","fork":true,"url":"https://api.github.com/repos/zhenyuy-fb/airlift","forks_url":"https://api.github.com/repos/zhenyuy-fb/airlift/forks","keys_url":"https://api.github.com/repos/zhenyuy-fb/airlift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zhenyuy-fb/airlift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zhenyuy-fb/airlift/teams","hooks_url":"https://api.github.com/repos/zhenyuy-fb/airlift/hooks","issue_events_url":"https://api.github.com/repos/zhenyuy-fb/airlift/issues/events{/number}","events_url":"https://api.github.com/repos/zhenyuy-fb/airlift/events","assignees_url":"https://api.github.com/repos/zhenyuy-fb/airlift/assignees{/user}","branches_url":"https://api.github.com/repos/zhenyuy-fb/airlift/branches{/branch}","tags_url":"https://api.github.com/repos/zhenyuy-fb/airlift/tags","blobs_url":"https://api.github.com/repos/zhenyuy-fb/airlift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zhenyuy-fb/airlift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zhenyuy-fb/airlift/git/refs{/sha}","trees_url":"https://api.github.com/repos/zhenyuy-fb/airlift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zhenyuy-fb/airlift/statuses/{sha}","languages_url":"https://api.github.com/repos/zhenyuy-fb/airlift/languages","stargazers_url":"https://api.github.com/repos/zhenyuy-fb/airlift/stargazers","contributors_url":"https://api.github.com/repos/zhenyuy-fb/airlift/contributors","subscribers_url":"https://api.github.com/repos/zhenyuy-fb/airlift/subscribers","subscription_url":"https://api.github.com/repos/zhenyuy-fb/airlift/subscription","commits_url":"https://api.github.com/repos/zhenyuy-fb/airlift/commits{/sha}","git_commits_url":"https://api.github.com/repos/zhenyuy-fb/airlift/git/commits{/sha}","comments_url":"https://api.github.com/repos/zhenyuy-fb/airlift/comments{/number}","issue_comment_url":"https://api.github.com/repos/zhenyuy-fb/airlift/issues/comments{/number}","contents_url":"https://api.github.com/repos/zhenyuy-fb/airlift/contents/{+path}","compare_url":"https://api.github.com/repos/zhenyuy-fb/airlift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zhenyuy-fb/airlift/merges","archive_url":"https://api.github.com/repos/zhenyuy-fb/airlift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zhenyuy-fb/airlift/downloads","issues_url":"https://api.github.com/repos/zhenyuy-fb/airlift/issues{/number}","pulls_url":"https://api.github.com/repos/zhenyuy-fb/airlift/pulls{/number}","milestones_url":"https://api.github.com/repos/zhenyuy-fb/airlift/milestones{/number}","notifications_url":"https://api.github.com/repos/zhenyuy-fb/airlift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zhenyuy-fb/airlift/labels{/name}","releases_url":"https://api.github.com/repos/zhenyuy-fb/airlift/releases{/id}","created_at":"2015-02-19T00:18:23Z","updated_at":"2015-04-01T22:54:06Z","pushed_at":"2015-04-01T22:54:06Z","git_url":"git://github.com/zhenyuy-fb/airlift.git","ssh_url":"git@github.com:zhenyuy-fb/airlift.git","clone_url":"https://github.com/zhenyuy-fb/airlift.git","svn_url":"https://github.com/zhenyuy-fb/airlift","homepage":"","size":7799,"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":"airlift:master","ref":"master","sha":"a9b05de925d22b80f06991becb50e2f67184b87d","user":{"login":"airlift","id":1855389,"avatar_url":"https://avatars.githubusercontent.com/u/1855389?v=3","gravatar_id":"","url":"https://api.github.com/users/airlift","html_url":"https://github.com/airlift","followers_url":"https://api.github.com/users/airlift/followers","following_url":"https://api.github.com/users/airlift/following{/other_user}","gists_url":"https://api.github.com/users/airlift/gists{/gist_id}","starred_url":"https://api.github.com/users/airlift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airlift/subscriptions","organizations_url":"https://api.github.com/users/airlift/orgs","repos_url":"https://api.github.com/users/airlift/repos","events_url":"https://api.github.com/users/airlift/events{/privacy}","received_events_url":"https://api.github.com/users/airlift/received_events","type":"Organization","site_admin":false},"repo":{"id":4681328,"name":"airlift","full_name":"airlift/airlift","owner":{"login":"airlift","id":1855389,"avatar_url":"https://avatars.githubusercontent.com/u/1855389?v=3","gravatar_id":"","url":"https://api.github.com/users/airlift","html_url":"https://github.com/airlift","followers_url":"https://api.github.com/users/airlift/followers","following_url":"https://api.github.com/users/airlift/following{/other_user}","gists_url":"https://api.github.com/users/airlift/gists{/gist_id}","starred_url":"https://api.github.com/users/airlift/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/airlift/subscriptions","organizations_url":"https://api.github.com/users/airlift/orgs","repos_url":"https://api.github.com/users/airlift/repos","events_url":"https://api.github.com/users/airlift/events{/privacy}","received_events_url":"https://api.github.com/users/airlift/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/airlift/airlift","description":"Airlift framework for building REST services","fork":false,"url":"https://api.github.com/repos/airlift/airlift","forks_url":"https://api.github.com/repos/airlift/airlift/forks","keys_url":"https://api.github.com/repos/airlift/airlift/keys{/key_id}","collaborators_url":"https://api.github.com/repos/airlift/airlift/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/airlift/airlift/teams","hooks_url":"https://api.github.com/repos/airlift/airlift/hooks","issue_events_url":"https://api.github.com/repos/airlift/airlift/issues/events{/number}","events_url":"https://api.github.com/repos/airlift/airlift/events","assignees_url":"https://api.github.com/repos/airlift/airlift/assignees{/user}","branches_url":"https://api.github.com/repos/airlift/airlift/branches{/branch}","tags_url":"https://api.github.com/repos/airlift/airlift/tags","blobs_url":"https://api.github.com/repos/airlift/airlift/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/airlift/airlift/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/airlift/airlift/git/refs{/sha}","trees_url":"https://api.github.com/repos/airlift/airlift/git/trees{/sha}","statuses_url":"https://api.github.com/repos/airlift/airlift/statuses/{sha}","languages_url":"https://api.github.com/repos/airlift/airlift/languages","stargazers_url":"https://api.github.com/repos/airlift/airlift/stargazers","contributors_url":"https://api.github.com/repos/airlift/airlift/contributors","subscribers_url":"https://api.github.com/repos/airlift/airlift/subscribers","subscription_url":"https://api.github.com/repos/airlift/airlift/subscription","commits_url":"https://api.github.com/repos/airlift/airlift/commits{/sha}","git_commits_url":"https://api.github.com/repos/airlift/airlift/git/commits{/sha}","comments_url":"https://api.github.com/repos/airlift/airlift/comments{/number}","issue_comment_url":"https://api.github.com/repos/airlift/airlift/issues/comments{/number}","contents_url":"https://api.github.com/repos/airlift/airlift/contents/{+path}","compare_url":"https://api.github.com/repos/airlift/airlift/compare/{base}...{head}","merges_url":"https://api.github.com/repos/airlift/airlift/merges","archive_url":"https://api.github.com/repos/airlift/airlift/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/airlift/airlift/downloads","issues_url":"https://api.github.com/repos/airlift/airlift/issues{/number}","pulls_url":"https://api.github.com/repos/airlift/airlift/pulls{/number}","milestones_url":"https://api.github.com/repos/airlift/airlift/milestones{/number}","notifications_url":"https://api.github.com/repos/airlift/airlift/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/airlift/airlift/labels{/name}","releases_url":"https://api.github.com/repos/airlift/airlift/releases{/id}","created_at":"2012-06-16T00:33:13Z","updated_at":"2015-04-10T05:03:40Z","pushed_at":"2015-04-01T22:54:06Z","git_url":"git://github.com/airlift/airlift.git","ssh_url":"git@github.com:airlift/airlift.git","clone_url":"https://github.com/airlift/airlift.git","svn_url":"https://github.com/airlift/airlift","homepage":"","size":14828,"stargazers_count":85,"watchers_count":85,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":39,"mirror_url":null,"open_issues_count":24,"forks":39,"open_issues":24,"watchers":85,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/airlift/airlift/pulls/291"},"html":{"href":"https://github.com/airlift/airlift/pull/291"},"issue":{"href":"https://api.github.com/repos/airlift/airlift/issues/291"},"comments":{"href":"https://api.github.com/repos/airlift/airlift/issues/291/comments"},"review_comments":{"href":"https://api.github.com/repos/airlift/airlift/pulls/291/comments"},"review_comment":{"href":"https://api.github.com/repos/airlift/airlift/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/airlift/airlift/pulls/291/commits"},"statuses":{"href":"https://api.github.com/repos/airlift/airlift/statuses/1306374bcffc80cc68264eced94502365252075e"}}}}