{"action":"created","comment":{"url":"https://api.github.com/repos/dotCMS/core/pulls/comments/193177461","pull_request_review_id":126098738,"id":193177461,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5MzE3NzQ2MQ==","diff_hunk":"@@ -43,115 +39,84 @@ public static JsonWebTokenUtils getInstance() {\n     private JsonWebTokenUtils() {\n         // singleton\n         this(JsonWebTokenFactory.getInstance().getJsonWebTokenService(),\n-                MarshalFactory.getInstance().getMarshalUtils(),\n-                CompanyLocalManagerFactory.getManager(),\n-                EncryptorFactory.getInstance().getEncryptor(),\n                 new LazyUserAPIWrapper());\n     }\n \n     @VisibleForTesting\n     protected JsonWebTokenUtils(final  JsonWebTokenService jsonWebTokenService,\n-                             final  MarshalUtils marshalUtils,\n-                             final  CompanyLocalManager companyLocalManager,\n-                             final  Encryptor encryptor,\n                              final  UserAPI userAPI) {\n \n         this.jsonWebTokenService = jsonWebTokenService;\n-        this.marshalUtils        = marshalUtils;\n-        this.companyLocalManager = companyLocalManager;\n-        this.encryptor           = encryptor;\n         this.userAPI             = userAPI;\n     }\n \n     private final JsonWebTokenService jsonWebTokenService;\n-\n-    private final  MarshalUtils marshalUtils;\n-\n-    private final  CompanyLocalManager companyLocalManager;\n-\n-    private final  Encryptor encryptor;\n-\n     private final UserAPI userAPI;\n \n-\n-    /**\n-     * Check if the Json Web token is valid.\n-     * @param jwtBean {@link JWTBean}\n-     * @return boolean true if it is valid\n-     */\n-    public static boolean isJsonWebTokenValid (final JWTBean jwtBean) {\n-\n-        return jwtBean.getTtlMillis() - System.currentTimeMillis() > 0;\n-    } // isJsonWebTokenValid.\n-\n     /**\n      * Gets from the json web access token, the subject.\n+     *\n      * @param jwtAccessToken String\n-     * @return String returns the User, if the user does not exists or is invalid will return null;\n+     * @return String returns the subject, if the subjet does not exists or is a invalid token will\n+     * return null\n      */\n-    public DotCMSSubjectBean getSubject(final String jwtAccessToken) {\n+    public String getSubject(final String jwtAccessToken) {\n \n-        JWTBean jwtBean = null;\n-        DotCMSSubjectBean subject = null;\n+        JWTBean jwtBean;\n+        String subject = null;\n \n         try {\n \n             jwtBean = this.jsonWebTokenService.parseToken(jwtAccessToken);\n-\n-            if (null != jwtBean && isJsonWebTokenValid(jwtBean)) {\n-\n-                subject =\n-                        this.marshalUtils.unmarshal(jwtBean.getSubject(), DotCMSSubjectBean.class);\n-\n+            if (null != jwtBean) {\n+                subject = jwtBean.getSubject();\n             }\n         } catch (Exception e) {\n-\n             Logger.error(JsonWebTokenUtils.class, e.getMessage(), e);\n             subject = null;\n         }\n \n         return subject;\n-    } // getUserId\n+    }\n \n     /**\n      * Gets from the json web access token, the user.\n+     *\n      * @param jwtAccessToken String\n      * @return String returns the User, if the user does not exists or is invalid will return null;\n      */\n     public User getUser(final String jwtAccessToken) {\n \n         User userToReturn = null;\n-        String userId = null;\n-        IsValidResult isValidResult = null;\n+        IsValidResult isValidResult;\n \n         try {\n \n-            final DotCMSSubjectBean subject =\n-                    this.getSubject(jwtAccessToken);\n+            //Parse the token\n+            JWTBean jwtBean = this.jsonWebTokenService.parseToken(jwtAccessToken);\n+            if (null != jwtBean) {\n \n-            if (null != subject) {\n-\n-                userId = this.encryptor.decrypt(\n-                        this.companyLocalManager.getCompany(subject.getCompanyId()).getKeyObj(),\n-                        subject.getUserId());\n-\n-                isValidResult = this.isValidUser(userId, subject);\n+                //Read the user id\n+                String subject = jwtBean.getSubject();","path":"dotCMS/src/main/java/com/dotcms/auth/providers/jwt/JsonWebTokenUtils.java","position":149,"original_position":149,"commit_id":"a5c2ee7eb10fa8e672a17914865267eb32ba8de4","original_commit_id":"a5c2ee7eb10fa8e672a17914865267eb32ba8de4","user":{"login":"codacy-bot","id":19940114,"node_id":"MDQ6VXNlcjE5OTQwMTE0","avatar_url":"https://avatars1.githubusercontent.com/u/19940114?v=4","gravatar_id":"","url":"https://api.github.com/users/codacy-bot","html_url":"https://github.com/codacy-bot","followers_url":"https://api.github.com/users/codacy-bot/followers","following_url":"https://api.github.com/users/codacy-bot/following{/other_user}","gists_url":"https://api.github.com/users/codacy-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/codacy-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codacy-bot/subscriptions","organizations_url":"https://api.github.com/users/codacy-bot/orgs","repos_url":"https://api.github.com/users/codacy-bot/repos","events_url":"https://api.github.com/users/codacy-bot/events{/privacy}","received_events_url":"https://api.github.com/users/codacy-bot/received_events","type":"User","site_admin":false},"body":"![Codacy](https://app.codacy.com/assets/images/favicon.png) Issue found: [Local variable 'subject' could be declared final](https://app.codacy.com/app/dotCMS/core/pullRequest?prid=1721338)","created_at":"2018-06-05T18:34:27Z","updated_at":"2018-06-05T18:34:27Z","html_url":"https://github.com/dotCMS/core/pull/14535#discussion_r193177461","pull_request_url":"https://api.github.com/repos/dotCMS/core/pulls/14535","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/dotCMS/core/pulls/comments/193177461"},"html":{"href":"https://github.com/dotCMS/core/pull/14535#discussion_r193177461"},"pull_request":{"href":"https://api.github.com/repos/dotCMS/core/pulls/14535"}}},"pull_request":{"url":"https://api.github.com/repos/dotCMS/core/pulls/14535","id":191881535,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkxODgxNTM1","html_url":"https://github.com/dotCMS/core/pull/14535","diff_url":"https://github.com/dotCMS/core/pull/14535.diff","patch_url":"https://github.com/dotCMS/core/pull/14535.patch","issue_url":"https://api.github.com/repos/dotCMS/core/issues/14535","number":14535,"state":"open","locked":false,"title":"Issue 13451 13453 jwt","user":{"login":"jgambarios","id":923947,"node_id":"MDQ6VXNlcjkyMzk0Nw==","avatar_url":"https://avatars1.githubusercontent.com/u/923947?v=4","gravatar_id":"","url":"https://api.github.com/users/jgambarios","html_url":"https://github.com/jgambarios","followers_url":"https://api.github.com/users/jgambarios/followers","following_url":"https://api.github.com/users/jgambarios/following{/other_user}","gists_url":"https://api.github.com/users/jgambarios/gists{/gist_id}","starred_url":"https://api.github.com/users/jgambarios/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgambarios/subscriptions","organizations_url":"https://api.github.com/users/jgambarios/orgs","repos_url":"https://api.github.com/users/jgambarios/repos","events_url":"https://api.github.com/users/jgambarios/events{/privacy}","received_events_url":"https://api.github.com/users/jgambarios/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-05-31T21:41:15Z","updated_at":"2018-06-05T18:34:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"369212e478b3c12676ee12d07bca5b4b840ed9f9","assignee":null,"assignees":[],"requested_reviewers":[{"login":"wezell","id":934364,"node_id":"MDQ6VXNlcjkzNDM2NA==","avatar_url":"https://avatars2.githubusercontent.com/u/934364?v=4","gravatar_id":"","url":"https://api.github.com/users/wezell","html_url":"https://github.com/wezell","followers_url":"https://api.github.com/users/wezell/followers","following_url":"https://api.github.com/users/wezell/following{/other_user}","gists_url":"https://api.github.com/users/wezell/gists{/gist_id}","starred_url":"https://api.github.com/users/wezell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wezell/subscriptions","organizations_url":"https://api.github.com/users/wezell/orgs","repos_url":"https://api.github.com/users/wezell/repos","events_url":"https://api.github.com/users/wezell/events{/privacy}","received_events_url":"https://api.github.com/users/wezell/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotCMS/core/pulls/14535/commits","review_comments_url":"https://api.github.com/repos/dotCMS/core/pulls/14535/comments","review_comment_url":"https://api.github.com/repos/dotCMS/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotCMS/core/issues/14535/comments","statuses_url":"https://api.github.com/repos/dotCMS/core/statuses/a5c2ee7eb10fa8e672a17914865267eb32ba8de4","head":{"label":"dotCMS:issue-13451-13453-JWT","ref":"issue-13451-13453-JWT","sha":"a5c2ee7eb10fa8e672a17914865267eb32ba8de4","user":{"login":"dotCMS","id":1005263,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDUyNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1005263?v=4","gravatar_id":"","url":"https://api.github.com/users/dotCMS","html_url":"https://github.com/dotCMS","followers_url":"https://api.github.com/users/dotCMS/followers","following_url":"https://api.github.com/users/dotCMS/following{/other_user}","gists_url":"https://api.github.com/users/dotCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/dotCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotCMS/subscriptions","organizations_url":"https://api.github.com/users/dotCMS/orgs","repos_url":"https://api.github.com/users/dotCMS/repos","events_url":"https://api.github.com/users/dotCMS/events{/privacy}","received_events_url":"https://api.github.com/users/dotCMS/received_events","type":"Organization","site_admin":false},"repo":{"id":3729629,"node_id":"MDEwOlJlcG9zaXRvcnkzNzI5NjI5","name":"core","full_name":"dotCMS/core","owner":{"login":"dotCMS","id":1005263,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDUyNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1005263?v=4","gravatar_id":"","url":"https://api.github.com/users/dotCMS","html_url":"https://github.com/dotCMS","followers_url":"https://api.github.com/users/dotCMS/followers","following_url":"https://api.github.com/users/dotCMS/following{/other_user}","gists_url":"https://api.github.com/users/dotCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/dotCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotCMS/subscriptions","organizations_url":"https://api.github.com/users/dotCMS/orgs","repos_url":"https://api.github.com/users/dotCMS/repos","events_url":"https://api.github.com/users/dotCMS/events{/privacy}","received_events_url":"https://api.github.com/users/dotCMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotCMS/core","description":"Source Code for dotCMS Java Enterprise Content Management System","fork":false,"url":"https://api.github.com/repos/dotCMS/core","forks_url":"https://api.github.com/repos/dotCMS/core/forks","keys_url":"https://api.github.com/repos/dotCMS/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotCMS/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotCMS/core/teams","hooks_url":"https://api.github.com/repos/dotCMS/core/hooks","issue_events_url":"https://api.github.com/repos/dotCMS/core/issues/events{/number}","events_url":"https://api.github.com/repos/dotCMS/core/events","assignees_url":"https://api.github.com/repos/dotCMS/core/assignees{/user}","branches_url":"https://api.github.com/repos/dotCMS/core/branches{/branch}","tags_url":"https://api.github.com/repos/dotCMS/core/tags","blobs_url":"https://api.github.com/repos/dotCMS/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotCMS/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotCMS/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotCMS/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotCMS/core/statuses/{sha}","languages_url":"https://api.github.com/repos/dotCMS/core/languages","stargazers_url":"https://api.github.com/repos/dotCMS/core/stargazers","contributors_url":"https://api.github.com/repos/dotCMS/core/contributors","subscribers_url":"https://api.github.com/repos/dotCMS/core/subscribers","subscription_url":"https://api.github.com/repos/dotCMS/core/subscription","commits_url":"https://api.github.com/repos/dotCMS/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotCMS/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotCMS/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotCMS/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotCMS/core/contents/{+path}","compare_url":"https://api.github.com/repos/dotCMS/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotCMS/core/merges","archive_url":"https://api.github.com/repos/dotCMS/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotCMS/core/downloads","issues_url":"https://api.github.com/repos/dotCMS/core/issues{/number}","pulls_url":"https://api.github.com/repos/dotCMS/core/pulls{/number}","milestones_url":"https://api.github.com/repos/dotCMS/core/milestones{/number}","notifications_url":"https://api.github.com/repos/dotCMS/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotCMS/core/labels{/name}","releases_url":"https://api.github.com/repos/dotCMS/core/releases{/id}","deployments_url":"https://api.github.com/repos/dotCMS/core/deployments","created_at":"2012-03-15T15:24:14Z","updated_at":"2018-06-05T14:25:51Z","pushed_at":"2018-06-05T18:21:49Z","git_url":"git://github.com/dotCMS/core.git","ssh_url":"git@github.com:dotCMS/core.git","clone_url":"https://github.com/dotCMS/core.git","svn_url":"https://github.com/dotCMS/core","homepage":"http://dotcms.com","size":330489,"stargazers_count":373,"watchers_count":373,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":313,"mirror_url":null,"archived":false,"open_issues_count":1902,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":313,"open_issues":1902,"watchers":373,"default_branch":"master"}},"base":{"label":"dotCMS:master","ref":"master","sha":"613716713431f36819bc0738b3c41c5bbf04882c","user":{"login":"dotCMS","id":1005263,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDUyNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1005263?v=4","gravatar_id":"","url":"https://api.github.com/users/dotCMS","html_url":"https://github.com/dotCMS","followers_url":"https://api.github.com/users/dotCMS/followers","following_url":"https://api.github.com/users/dotCMS/following{/other_user}","gists_url":"https://api.github.com/users/dotCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/dotCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotCMS/subscriptions","organizations_url":"https://api.github.com/users/dotCMS/orgs","repos_url":"https://api.github.com/users/dotCMS/repos","events_url":"https://api.github.com/users/dotCMS/events{/privacy}","received_events_url":"https://api.github.com/users/dotCMS/received_events","type":"Organization","site_admin":false},"repo":{"id":3729629,"node_id":"MDEwOlJlcG9zaXRvcnkzNzI5NjI5","name":"core","full_name":"dotCMS/core","owner":{"login":"dotCMS","id":1005263,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMDUyNjM=","avatar_url":"https://avatars3.githubusercontent.com/u/1005263?v=4","gravatar_id":"","url":"https://api.github.com/users/dotCMS","html_url":"https://github.com/dotCMS","followers_url":"https://api.github.com/users/dotCMS/followers","following_url":"https://api.github.com/users/dotCMS/following{/other_user}","gists_url":"https://api.github.com/users/dotCMS/gists{/gist_id}","starred_url":"https://api.github.com/users/dotCMS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotCMS/subscriptions","organizations_url":"https://api.github.com/users/dotCMS/orgs","repos_url":"https://api.github.com/users/dotCMS/repos","events_url":"https://api.github.com/users/dotCMS/events{/privacy}","received_events_url":"https://api.github.com/users/dotCMS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotCMS/core","description":"Source Code for dotCMS Java Enterprise Content Management System","fork":false,"url":"https://api.github.com/repos/dotCMS/core","forks_url":"https://api.github.com/repos/dotCMS/core/forks","keys_url":"https://api.github.com/repos/dotCMS/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotCMS/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotCMS/core/teams","hooks_url":"https://api.github.com/repos/dotCMS/core/hooks","issue_events_url":"https://api.github.com/repos/dotCMS/core/issues/events{/number}","events_url":"https://api.github.com/repos/dotCMS/core/events","assignees_url":"https://api.github.com/repos/dotCMS/core/assignees{/user}","branches_url":"https://api.github.com/repos/dotCMS/core/branches{/branch}","tags_url":"https://api.github.com/repos/dotCMS/core/tags","blobs_url":"https://api.github.com/repos/dotCMS/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotCMS/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotCMS/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotCMS/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotCMS/core/statuses/{sha}","languages_url":"https://api.github.com/repos/dotCMS/core/languages","stargazers_url":"https://api.github.com/repos/dotCMS/core/stargazers","contributors_url":"https://api.github.com/repos/dotCMS/core/contributors","subscribers_url":"https://api.github.com/repos/dotCMS/core/subscribers","subscription_url":"https://api.github.com/repos/dotCMS/core/subscription","commits_url":"https://api.github.com/repos/dotCMS/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotCMS/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotCMS/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotCMS/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotCMS/core/contents/{+path}","compare_url":"https://api.github.com/repos/dotCMS/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotCMS/core/merges","archive_url":"https://api.github.com/repos/dotCMS/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotCMS/core/downloads","issues_url":"https://api.github.com/repos/dotCMS/core/issues{/number}","pulls_url":"https://api.github.com/repos/dotCMS/core/pulls{/number}","milestones_url":"https://api.github.com/repos/dotCMS/core/milestones{/number}","notifications_url":"https://api.github.com/repos/dotCMS/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotCMS/core/labels{/name}","releases_url":"https://api.github.com/repos/dotCMS/core/releases{/id}","deployments_url":"https://api.github.com/repos/dotCMS/core/deployments","created_at":"2012-03-15T15:24:14Z","updated_at":"2018-06-05T14:25:51Z","pushed_at":"2018-06-05T18:21:49Z","git_url":"git://github.com/dotCMS/core.git","ssh_url":"git@github.com:dotCMS/core.git","clone_url":"https://github.com/dotCMS/core.git","svn_url":"https://github.com/dotCMS/core","homepage":"http://dotcms.com","size":330489,"stargazers_count":373,"watchers_count":373,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":313,"mirror_url":null,"archived":false,"open_issues_count":1902,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":313,"open_issues":1902,"watchers":373,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotCMS/core/pulls/14535"},"html":{"href":"https://github.com/dotCMS/core/pull/14535"},"issue":{"href":"https://api.github.com/repos/dotCMS/core/issues/14535"},"comments":{"href":"https://api.github.com/repos/dotCMS/core/issues/14535/comments"},"review_comments":{"href":"https://api.github.com/repos/dotCMS/core/pulls/14535/comments"},"review_comment":{"href":"https://api.github.com/repos/dotCMS/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotCMS/core/pulls/14535/commits"},"statuses":{"href":"https://api.github.com/repos/dotCMS/core/statuses/a5c2ee7eb10fa8e672a17914865267eb32ba8de4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"codacy-bot"}}