{"action":"created","comment":{"url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/comments/93010395","pull_request_review_id":13530206,"id":93010395,"diff_hunk":"@@ -84,20 +88,96 @@ private void init(JsonObject json) {\n       json.put(\"expires_at\", System.currentTimeMillis() + 1000 * expiresIn);\n     }\n \n-    this.token = json;\n+    token = json;\n+    content = null;\n \n     // try to parse the access_token\n     if (provider.getConfig().isJwtToken() && json.containsKey(\"access_token\")) {\n       content = provider.decode(json.getString(\"access_token\"));\n     }\n+\n+    // the permission cache needs to be clear\n+    clearCache();\n+    // rebuild cache\n+    if (token.containsKey(\"scope\")) {\n+      Collections.addAll(cachedPermissions, token.getString(\"scope\", \"\").split(Pattern.quote(provider.getScopeSeparator())));\n+    }\n+\n+    // validate expiration\n+    if (token.containsKey(\"exp\")) {\n+      Long exp;\n+      try {\n+        exp = token.getLong(\"exp\");\n+      } catch (ClassCastException e) {\n+        // for some reason someone decided to send a number as a String...\n+        exp = Long.valueOf(token.getString(\"exp\"));\n+      }\n+      token.put(\"expires_at\", 1000 * exp);\n+    }\n+\n+    // move JWT fields into \"content\"\n+    moveProperty(\"exp\");\n+    moveProperty(\"iat\");\n+    moveProperty(\"nbf\");\n+    moveProperty(\"sub\");\n+    moveProperty(\"aud\");\n+    moveProperty(\"iss\");\n+    moveProperty(\"jti\");\n+    // known implementation fields\n+    moveProperty(\"permissions\");\n+    moveProperty(\"resource_access\");\n+    moveProperty(\"realm_access\");\n+  }\n+\n+  private void moveProperty(String name) {\n+    if (token.containsKey(name)) {\n+      if (content == null) {\n+        content = new JsonObject();\n+      }\n+      content.put(name, token.remove(name));\n+    }\n   }\n \n   /**\n    * Check if the access token is expired or not.\n    */\n   @Override\n   public boolean expired() {\n-    return token.containsKey(\"expires_at\") && token.getLong(\"expires_at\", 0L) < System.currentTimeMillis();\n+\n+    // All dates in JWT are of type NumericDate\n+    // a NumericDate is: numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until\n+    // the specified UTC date/time, ignoring leap seconds\n+    final long now = System.currentTimeMillis() / 1000;\n+\n+    if (token.containsKey(\"expires_at\") && token.getLong(\"expires_at\", 0L) < System.currentTimeMillis()) {\n+      return true;\n+    }\n+\n+    if (content != null) {\n+      if (content.containsKey(\"exp\")) {\n+        if (now >= content.getLong(\"exp\")) {\n+          return true;\n+        }\n+      }\n+\n+      if (content.containsKey(\"iat\")) {\n+        Long iat = content.getLong(\"iat\");\n+        // issue at must be in the past\n+        if (iat > now) {","path":"vertx-auth-oauth2/src/main/java/io/vertx/ext/auth/oauth2/impl/AccessTokenImpl.java","position":92,"original_position":92,"commit_id":"ebeb04bc41472cff8d281dee2838109f774c3818","original_commit_id":"ebeb04bc41472cff8d281dee2838109f774c3818","user":{"login":"pmlopes","id":849467,"avatar_url":"https://avatars.githubusercontent.com/u/849467?v=3","gravatar_id":"","url":"https://api.github.com/users/pmlopes","html_url":"https://github.com/pmlopes","followers_url":"https://api.github.com/users/pmlopes/followers","following_url":"https://api.github.com/users/pmlopes/following{/other_user}","gists_url":"https://api.github.com/users/pmlopes/gists{/gist_id}","starred_url":"https://api.github.com/users/pmlopes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmlopes/subscriptions","organizations_url":"https://api.github.com/users/pmlopes/orgs","repos_url":"https://api.github.com/users/pmlopes/repos","events_url":"https://api.github.com/users/pmlopes/events{/privacy}","received_events_url":"https://api.github.com/users/pmlopes/received_events","type":"User","site_admin":false},"body":"clock synch'ing issues/replay attacks...","created_at":"2016-12-19T11:03:52Z","updated_at":"2016-12-19T11:03:53Z","html_url":"https://github.com/vert-x3/vertx-auth/pull/110#discussion_r93010395","pull_request_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110","_links":{"self":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/comments/93010395"},"html":{"href":"https://github.com/vert-x3/vertx-auth/pull/110#discussion_r93010395"},"pull_request":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110"}}},"pull_request":{"url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110","id":98321371,"html_url":"https://github.com/vert-x3/vertx-auth/pull/110","diff_url":"https://github.com/vert-x3/vertx-auth/pull/110.diff","patch_url":"https://github.com/vert-x3/vertx-auth/pull/110.patch","issue_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/110","number":110,"state":"open","locked":false,"title":"implemented RFC7662 token introspection","user":{"login":"pmlopes","id":849467,"avatar_url":"https://avatars.githubusercontent.com/u/849467?v=3","gravatar_id":"","url":"https://api.github.com/users/pmlopes","html_url":"https://github.com/pmlopes","followers_url":"https://api.github.com/users/pmlopes/followers","following_url":"https://api.github.com/users/pmlopes/following{/other_user}","gists_url":"https://api.github.com/users/pmlopes/gists{/gist_id}","starred_url":"https://api.github.com/users/pmlopes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pmlopes/subscriptions","organizations_url":"https://api.github.com/users/pmlopes/orgs","repos_url":"https://api.github.com/users/pmlopes/repos","events_url":"https://api.github.com/users/pmlopes/events{/privacy}","received_events_url":"https://api.github.com/users/pmlopes/received_events","type":"User","site_admin":false},"body":"Fixes #109\r\n\r\nImplements a way to introspect tokens, both the official RFC and the non official Google Way","created_at":"2016-12-16T11:43:51Z","updated_at":"2016-12-19T11:03:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8be8086b9c516863db7b212c9641ceaccf84d2a1","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110/commits","review_comments_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110/comments","review_comment_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/110/comments","statuses_url":"https://api.github.com/repos/vert-x3/vertx-auth/statuses/ebeb04bc41472cff8d281dee2838109f774c3818","head":{"label":"vert-x3:issues/rfc7662","ref":"issues/rfc7662","sha":"ebeb04bc41472cff8d281dee2838109f774c3818","user":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"repo":{"id":27583882,"name":"vertx-auth","full_name":"vert-x3/vertx-auth","owner":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vert-x3/vertx-auth","description":null,"fork":false,"url":"https://api.github.com/repos/vert-x3/vertx-auth","forks_url":"https://api.github.com/repos/vert-x3/vertx-auth/forks","keys_url":"https://api.github.com/repos/vert-x3/vertx-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vert-x3/vertx-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vert-x3/vertx-auth/teams","hooks_url":"https://api.github.com/repos/vert-x3/vertx-auth/hooks","issue_events_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/events{/number}","events_url":"https://api.github.com/repos/vert-x3/vertx-auth/events","assignees_url":"https://api.github.com/repos/vert-x3/vertx-auth/assignees{/user}","branches_url":"https://api.github.com/repos/vert-x3/vertx-auth/branches{/branch}","tags_url":"https://api.github.com/repos/vert-x3/vertx-auth/tags","blobs_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vert-x3/vertx-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/vert-x3/vertx-auth/languages","stargazers_url":"https://api.github.com/repos/vert-x3/vertx-auth/stargazers","contributors_url":"https://api.github.com/repos/vert-x3/vertx-auth/contributors","subscribers_url":"https://api.github.com/repos/vert-x3/vertx-auth/subscribers","subscription_url":"https://api.github.com/repos/vert-x3/vertx-auth/subscription","commits_url":"https://api.github.com/repos/vert-x3/vertx-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/vert-x3/vertx-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/vert-x3/vertx-auth/contents/{+path}","compare_url":"https://api.github.com/repos/vert-x3/vertx-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vert-x3/vertx-auth/merges","archive_url":"https://api.github.com/repos/vert-x3/vertx-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vert-x3/vertx-auth/downloads","issues_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues{/number}","pulls_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/vert-x3/vertx-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/vert-x3/vertx-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vert-x3/vertx-auth/labels{/name}","releases_url":"https://api.github.com/repos/vert-x3/vertx-auth/releases{/id}","deployments_url":"https://api.github.com/repos/vert-x3/vertx-auth/deployments","created_at":"2014-12-05T09:18:37Z","updated_at":"2016-12-16T16:43:23Z","pushed_at":"2016-12-18T14:59:52Z","git_url":"git://github.com/vert-x3/vertx-auth.git","ssh_url":"git@github.com:vert-x3/vertx-auth.git","clone_url":"https://github.com/vert-x3/vertx-auth.git","svn_url":"https://github.com/vert-x3/vertx-auth","homepage":null,"size":1242,"stargazers_count":30,"watchers_count":30,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":10,"forks":41,"open_issues":10,"watchers":30,"default_branch":"master"}},"base":{"label":"vert-x3:master","ref":"master","sha":"23b5a243eeb6e95683f627983974d68646ff25e4","user":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"repo":{"id":27583882,"name":"vertx-auth","full_name":"vert-x3/vertx-auth","owner":{"login":"vert-x3","id":8124623,"avatar_url":"https://avatars.githubusercontent.com/u/8124623?v=3","gravatar_id":"","url":"https://api.github.com/users/vert-x3","html_url":"https://github.com/vert-x3","followers_url":"https://api.github.com/users/vert-x3/followers","following_url":"https://api.github.com/users/vert-x3/following{/other_user}","gists_url":"https://api.github.com/users/vert-x3/gists{/gist_id}","starred_url":"https://api.github.com/users/vert-x3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vert-x3/subscriptions","organizations_url":"https://api.github.com/users/vert-x3/orgs","repos_url":"https://api.github.com/users/vert-x3/repos","events_url":"https://api.github.com/users/vert-x3/events{/privacy}","received_events_url":"https://api.github.com/users/vert-x3/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vert-x3/vertx-auth","description":null,"fork":false,"url":"https://api.github.com/repos/vert-x3/vertx-auth","forks_url":"https://api.github.com/repos/vert-x3/vertx-auth/forks","keys_url":"https://api.github.com/repos/vert-x3/vertx-auth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vert-x3/vertx-auth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vert-x3/vertx-auth/teams","hooks_url":"https://api.github.com/repos/vert-x3/vertx-auth/hooks","issue_events_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/events{/number}","events_url":"https://api.github.com/repos/vert-x3/vertx-auth/events","assignees_url":"https://api.github.com/repos/vert-x3/vertx-auth/assignees{/user}","branches_url":"https://api.github.com/repos/vert-x3/vertx-auth/branches{/branch}","tags_url":"https://api.github.com/repos/vert-x3/vertx-auth/tags","blobs_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/refs{/sha}","trees_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vert-x3/vertx-auth/statuses/{sha}","languages_url":"https://api.github.com/repos/vert-x3/vertx-auth/languages","stargazers_url":"https://api.github.com/repos/vert-x3/vertx-auth/stargazers","contributors_url":"https://api.github.com/repos/vert-x3/vertx-auth/contributors","subscribers_url":"https://api.github.com/repos/vert-x3/vertx-auth/subscribers","subscription_url":"https://api.github.com/repos/vert-x3/vertx-auth/subscription","commits_url":"https://api.github.com/repos/vert-x3/vertx-auth/commits{/sha}","git_commits_url":"https://api.github.com/repos/vert-x3/vertx-auth/git/commits{/sha}","comments_url":"https://api.github.com/repos/vert-x3/vertx-auth/comments{/number}","issue_comment_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues/comments{/number}","contents_url":"https://api.github.com/repos/vert-x3/vertx-auth/contents/{+path}","compare_url":"https://api.github.com/repos/vert-x3/vertx-auth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vert-x3/vertx-auth/merges","archive_url":"https://api.github.com/repos/vert-x3/vertx-auth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vert-x3/vertx-auth/downloads","issues_url":"https://api.github.com/repos/vert-x3/vertx-auth/issues{/number}","pulls_url":"https://api.github.com/repos/vert-x3/vertx-auth/pulls{/number}","milestones_url":"https://api.github.com/repos/vert-x3/vertx-auth/milestones{/number}","notifications_url":"https://api.github.com/repos/vert-x3/vertx-auth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vert-x3/vertx-auth/labels{/name}","releases_url":"https://api.github.com/repos/vert-x3/vertx-auth/releases{/id}","deployments_url":"https://api.github.com/repos/vert-x3/vertx-auth/deployments","created_at":"2014-12-05T09:18:37Z","updated_at":"2016-12-16T16:43:23Z","pushed_at":"2016-12-18T14:59:52Z","git_url":"git://github.com/vert-x3/vertx-auth.git","ssh_url":"git@github.com:vert-x3/vertx-auth.git","clone_url":"https://github.com/vert-x3/vertx-auth.git","svn_url":"https://github.com/vert-x3/vertx-auth","homepage":null,"size":1242,"stargazers_count":30,"watchers_count":30,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":41,"mirror_url":null,"open_issues_count":10,"forks":41,"open_issues":10,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110"},"html":{"href":"https://github.com/vert-x3/vertx-auth/pull/110"},"issue":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/issues/110"},"comments":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/issues/110/comments"},"review_comments":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110/comments"},"review_comment":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/pulls/110/commits"},"statuses":{"href":"https://api.github.com/repos/vert-x3/vertx-auth/statuses/ebeb04bc41472cff8d281dee2838109f774c3818"}}}}
{"actor":{"display_login":"pmlopes"}}