{"action":"created","comment":{"url":"https://api.github.com/repos/apache/tomee/pulls/comments/172463870","pull_request_review_id":101481228,"id":172463870,"diff_hunk":"@@ -0,0 +1,127 @@\n+/*\n+ *     Licensed to the Apache Software Foundation (ASF) under one or more\n+ *     contributor license agreements.  See the NOTICE file distributed with\n+ *     this work for additional information regarding copyright ownership.\n+ *     The ASF licenses this file to You under the Apache License, Version 2.0\n+ *     (the \"License\"); you may not use this file except in compliance with\n+ *     the License.  You may obtain a copy of the License at\n+ *\n+ *        http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ *     Unless required by applicable law or agreed to in writing, software\n+ *     distributed under the License is distributed on an \"AS IS\" BASIS,\n+ *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ *     See the License for the specific language governing permissions and\n+ *     limitations under the License.\n+ */\n+package org.apache.tomee.microprofile.jwt.principal;\n+\n+import org.apache.tomee.microprofile.jwt.ParseException;\n+import org.apache.tomee.microprofile.jwt.config.JWTAuthContextInfo;\n+\n+import java.net.URL;\n+import java.security.AccessController;\n+import java.security.PrivilegedAction;\n+import java.util.ServiceLoader;\n+\n+/**\n+ * The factory class that provides the token string to JWTCallerPrincipal parsing for a given implementation.\n+ */\n+public abstract class JWTCallerPrincipalFactory {\n+    private static JWTCallerPrincipalFactory instance;\n+\n+    /**\n+     * Obtain the JWTCallerPrincipalFactory that has been set or by using the ServiceLoader pattern.\n+     *\n+     * @return the factory instance\n+     * @see #setInstance(JWTCallerPrincipalFactory)\n+     */\n+    public static JWTCallerPrincipalFactory instance() {\n+        if (instance == null) {\n+            synchronized (JWTCallerPrincipalFactory.class) {\n+                if (instance != null) {\n+                    return instance;\n+                }\n+\n+                ClassLoader cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {\n+                    @Override\n+                    public ClassLoader run() {\n+                        return Thread.currentThread().getContextClassLoader();\n+                    }\n+                });\n+                if (cl == null) {\n+                    cl = JWTCallerPrincipalFactory.class.getClassLoader();\n+                }\n+\n+                JWTCallerPrincipalFactory newInstance = loadSpi(cl);\n+\n+                if (newInstance == null && cl != JWTCallerPrincipalFactory.class.getClassLoader()) {\n+                    cl = JWTCallerPrincipalFactory.class.getClassLoader();\n+                    newInstance = loadSpi(cl);\n+                }\n+                if (newInstance == null) {\n+                    throw new IllegalStateException(\"No JWTCallerPrincipalFactory implementation found!\");\n+                }\n+\n+                instance = newInstance;\n+            }\n+        }\n+\n+        return instance;\n+    }\n+\n+    /**\n+     * Look for a JWTCallerPrincipalFactory service implementation using the ServiceLoader.\n+     *\n+     * @param cl - the ClassLoader to pass into the {@link ServiceLoader#load(Class, ClassLoader)} method.\n+     * @return the JWTCallerPrincipalFactory if found, null otherwise\n+     */\n+    private static JWTCallerPrincipalFactory loadSpi(ClassLoader cl) {\n+        if (cl == null) {\n+            return null;\n+        }\n+\n+        // start from the root CL and go back down to the TCCL\n+        JWTCallerPrincipalFactory instance = loadSpi(cl.getParent());\n+\n+        if (instance == null) {\n+            ServiceLoader<JWTCallerPrincipalFactory> sl = ServiceLoader.load(JWTCallerPrincipalFactory.class, cl);\n+            URL u = cl.getResource(\"/META-INF/services/org.apache.tomee.microprofile.jwt.JWTCallerPrincipalFactory\");\n+            System.out.printf(\"JWTCallerPrincipalFactory, cl=%s, u=%s, sl=%s\\n\", cl, u, sl);\n+            try {\n+                for (JWTCallerPrincipalFactory spi : sl) {\n+                    if (instance != null) {\n+                        throw new IllegalStateException(\n+                                \"Multiple JWTCallerPrincipalFactory implementations found: \"\n+                                        + spi.getClass().getName() + \" and \"\n+                                        + instance.getClass().getName());\n+                    } else {\n+                        System.out.printf(\"sl=%s, loaded=%s\\n\", sl, spi);\n+                        instance = spi;\n+                    }\n+                }\n+            } catch (Throwable e) {\n+                System.err.printf(\"Warning: %s\\n\", e.getMessage());","path":"tck/mp-jwt-embedded/src/main/java/org/apache/tomee/microprofile/jwt/principal/JWTCallerPrincipalFactory.java","position":104,"original_position":104,"commit_id":"e75018b231942bec07c5a81fa513d476ab877877","original_commit_id":"e75018b231942bec07c5a81fa513d476ab877877","user":{"login":"AndyGee","id":2536412,"avatar_url":"https://avatars2.githubusercontent.com/u/2536412?v=4","gravatar_id":"","url":"https://api.github.com/users/AndyGee","html_url":"https://github.com/AndyGee","followers_url":"https://api.github.com/users/AndyGee/followers","following_url":"https://api.github.com/users/AndyGee/following{/other_user}","gists_url":"https://api.github.com/users/AndyGee/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyGee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyGee/subscriptions","organizations_url":"https://api.github.com/users/AndyGee/orgs","repos_url":"https://api.github.com/users/AndyGee/repos","events_url":"https://api.github.com/users/AndyGee/events{/privacy}","received_events_url":"https://api.github.com/users/AndyGee/received_events","type":"User","site_admin":false},"body":"Logging","created_at":"2018-03-06T09:58:46Z","updated_at":"2018-03-06T09:58:47Z","html_url":"https://github.com/apache/tomee/pull/123#discussion_r172463870","pull_request_url":"https://api.github.com/repos/apache/tomee/pulls/123","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/apache/tomee/pulls/comments/172463870"},"html":{"href":"https://github.com/apache/tomee/pull/123#discussion_r172463870"},"pull_request":{"href":"https://api.github.com/repos/apache/tomee/pulls/123"}}},"pull_request":{"url":"https://api.github.com/repos/apache/tomee/pulls/123","id":173099546,"html_url":"https://github.com/apache/tomee/pull/123","diff_url":"https://github.com/apache/tomee/pull/123.diff","patch_url":"https://github.com/apache/tomee/pull/123.patch","issue_url":"https://api.github.com/repos/apache/tomee/issues/123","number":123,"state":"open","locked":false,"title":"WIP Playground for MP-JWT implementation","user":{"login":"jeanouii","id":1233474,"avatar_url":"https://avatars3.githubusercontent.com/u/1233474?v=4","gravatar_id":"","url":"https://api.github.com/users/jeanouii","html_url":"https://github.com/jeanouii","followers_url":"https://api.github.com/users/jeanouii/followers","following_url":"https://api.github.com/users/jeanouii/following{/other_user}","gists_url":"https://api.github.com/users/jeanouii/gists{/gist_id}","starred_url":"https://api.github.com/users/jeanouii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeanouii/subscriptions","organizations_url":"https://api.github.com/users/jeanouii/orgs","repos_url":"https://api.github.com/users/jeanouii/repos","events_url":"https://api.github.com/users/jeanouii/events{/privacy}","received_events_url":"https://api.github.com/users/jeanouii/received_events","type":"User","site_admin":false},"body":"Please don't merge this PR. It has some more tests and requires a bit of cleanup.\r\nMost of the code to look at is in tck/mp-jwt-embedded module.\r\n\r\nAny feedback or comments are welcome of course.\r\n\r\nCheers","created_at":"2018-03-06T09:23:34Z","updated_at":"2018-03-06T09:58:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c8b74a44f0b24f4fe76e4c59dd6218c7d8fc572e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/tomee/pulls/123/commits","review_comments_url":"https://api.github.com/repos/apache/tomee/pulls/123/comments","review_comment_url":"https://api.github.com/repos/apache/tomee/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/tomee/issues/123/comments","statuses_url":"https://api.github.com/repos/apache/tomee/statuses/e75018b231942bec07c5a81fa513d476ab877877","head":{"label":"jeanouii:jlmonteiro-mp-jwt-playground","ref":"jlmonteiro-mp-jwt-playground","sha":"e75018b231942bec07c5a81fa513d476ab877877","user":{"login":"jeanouii","id":1233474,"avatar_url":"https://avatars3.githubusercontent.com/u/1233474?v=4","gravatar_id":"","url":"https://api.github.com/users/jeanouii","html_url":"https://github.com/jeanouii","followers_url":"https://api.github.com/users/jeanouii/followers","following_url":"https://api.github.com/users/jeanouii/following{/other_user}","gists_url":"https://api.github.com/users/jeanouii/gists{/gist_id}","starred_url":"https://api.github.com/users/jeanouii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeanouii/subscriptions","organizations_url":"https://api.github.com/users/jeanouii/orgs","repos_url":"https://api.github.com/users/jeanouii/repos","events_url":"https://api.github.com/users/jeanouii/events{/privacy}","received_events_url":"https://api.github.com/users/jeanouii/received_events","type":"User","site_admin":false},"repo":{"id":45262441,"name":"tomee","full_name":"jeanouii/tomee","owner":{"login":"jeanouii","id":1233474,"avatar_url":"https://avatars3.githubusercontent.com/u/1233474?v=4","gravatar_id":"","url":"https://api.github.com/users/jeanouii","html_url":"https://github.com/jeanouii","followers_url":"https://api.github.com/users/jeanouii/followers","following_url":"https://api.github.com/users/jeanouii/following{/other_user}","gists_url":"https://api.github.com/users/jeanouii/gists{/gist_id}","starred_url":"https://api.github.com/users/jeanouii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeanouii/subscriptions","organizations_url":"https://api.github.com/users/jeanouii/orgs","repos_url":"https://api.github.com/users/jeanouii/repos","events_url":"https://api.github.com/users/jeanouii/events{/privacy}","received_events_url":"https://api.github.com/users/jeanouii/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeanouii/tomee","description":"Mirror of Apache Tomee","fork":true,"url":"https://api.github.com/repos/jeanouii/tomee","forks_url":"https://api.github.com/repos/jeanouii/tomee/forks","keys_url":"https://api.github.com/repos/jeanouii/tomee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeanouii/tomee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeanouii/tomee/teams","hooks_url":"https://api.github.com/repos/jeanouii/tomee/hooks","issue_events_url":"https://api.github.com/repos/jeanouii/tomee/issues/events{/number}","events_url":"https://api.github.com/repos/jeanouii/tomee/events","assignees_url":"https://api.github.com/repos/jeanouii/tomee/assignees{/user}","branches_url":"https://api.github.com/repos/jeanouii/tomee/branches{/branch}","tags_url":"https://api.github.com/repos/jeanouii/tomee/tags","blobs_url":"https://api.github.com/repos/jeanouii/tomee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeanouii/tomee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeanouii/tomee/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeanouii/tomee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeanouii/tomee/statuses/{sha}","languages_url":"https://api.github.com/repos/jeanouii/tomee/languages","stargazers_url":"https://api.github.com/repos/jeanouii/tomee/stargazers","contributors_url":"https://api.github.com/repos/jeanouii/tomee/contributors","subscribers_url":"https://api.github.com/repos/jeanouii/tomee/subscribers","subscription_url":"https://api.github.com/repos/jeanouii/tomee/subscription","commits_url":"https://api.github.com/repos/jeanouii/tomee/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeanouii/tomee/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeanouii/tomee/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeanouii/tomee/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeanouii/tomee/contents/{+path}","compare_url":"https://api.github.com/repos/jeanouii/tomee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeanouii/tomee/merges","archive_url":"https://api.github.com/repos/jeanouii/tomee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeanouii/tomee/downloads","issues_url":"https://api.github.com/repos/jeanouii/tomee/issues{/number}","pulls_url":"https://api.github.com/repos/jeanouii/tomee/pulls{/number}","milestones_url":"https://api.github.com/repos/jeanouii/tomee/milestones{/number}","notifications_url":"https://api.github.com/repos/jeanouii/tomee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeanouii/tomee/labels{/name}","releases_url":"https://api.github.com/repos/jeanouii/tomee/releases{/id}","deployments_url":"https://api.github.com/repos/jeanouii/tomee/deployments","created_at":"2015-10-30T16:18:50Z","updated_at":"2018-02-05T13:20:10Z","pushed_at":"2018-03-06T09:16:58Z","git_url":"git://github.com/jeanouii/tomee.git","ssh_url":"git@github.com:jeanouii/tomee.git","clone_url":"https://github.com/jeanouii/tomee.git","svn_url":"https://github.com/jeanouii/tomee","homepage":null,"size":58482,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":null,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"3332c7e8b74d8798c57c61b7425f2458288ff784","user":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":7748336,"name":"tomee","full_name":"apache/tomee","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars0.githubusercontent.com/u/47359?v=4","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/tomee","description":"Mirror of Apache Tomee","fork":false,"url":"https://api.github.com/repos/apache/tomee","forks_url":"https://api.github.com/repos/apache/tomee/forks","keys_url":"https://api.github.com/repos/apache/tomee/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/tomee/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/tomee/teams","hooks_url":"https://api.github.com/repos/apache/tomee/hooks","issue_events_url":"https://api.github.com/repos/apache/tomee/issues/events{/number}","events_url":"https://api.github.com/repos/apache/tomee/events","assignees_url":"https://api.github.com/repos/apache/tomee/assignees{/user}","branches_url":"https://api.github.com/repos/apache/tomee/branches{/branch}","tags_url":"https://api.github.com/repos/apache/tomee/tags","blobs_url":"https://api.github.com/repos/apache/tomee/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/tomee/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/tomee/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/tomee/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/tomee/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/tomee/languages","stargazers_url":"https://api.github.com/repos/apache/tomee/stargazers","contributors_url":"https://api.github.com/repos/apache/tomee/contributors","subscribers_url":"https://api.github.com/repos/apache/tomee/subscribers","subscription_url":"https://api.github.com/repos/apache/tomee/subscription","commits_url":"https://api.github.com/repos/apache/tomee/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/tomee/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/tomee/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/tomee/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/tomee/contents/{+path}","compare_url":"https://api.github.com/repos/apache/tomee/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/tomee/merges","archive_url":"https://api.github.com/repos/apache/tomee/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/tomee/downloads","issues_url":"https://api.github.com/repos/apache/tomee/issues{/number}","pulls_url":"https://api.github.com/repos/apache/tomee/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/tomee/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/tomee/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/tomee/labels{/name}","releases_url":"https://api.github.com/repos/apache/tomee/releases{/id}","deployments_url":"https://api.github.com/repos/apache/tomee/deployments","created_at":"2013-01-22T08:00:16Z","updated_at":"2018-02-26T07:37:38Z","pushed_at":"2018-03-06T09:23:35Z","git_url":"git://github.com/apache/tomee.git","ssh_url":"git@github.com:apache/tomee.git","clone_url":"https://github.com/apache/tomee.git","svn_url":"https://github.com/apache/tomee","homepage":null,"size":60561,"stargazers_count":205,"watchers_count":205,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":474,"mirror_url":null,"archived":false,"open_issues_count":21,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":474,"open_issues":21,"watchers":205,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/tomee/pulls/123"},"html":{"href":"https://github.com/apache/tomee/pull/123"},"issue":{"href":"https://api.github.com/repos/apache/tomee/issues/123"},"comments":{"href":"https://api.github.com/repos/apache/tomee/issues/123/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/tomee/pulls/123/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/tomee/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/tomee/pulls/123/commits"},"statuses":{"href":"https://api.github.com/repos/apache/tomee/statuses/e75018b231942bec07c5a81fa513d476ab877877"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"AndyGee"}}