{"action":"created","comment":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/172595222","pull_request_review_id":101638806,"id":172595222,"diff_hunk":"@@ -0,0 +1,369 @@\n+/**\n+ * Copyright (c) 2014,2018 Contributors to the Eclipse Foundation\n+ *\n+ * See the NOTICE file(s) distributed with this work for additional\n+ * information regarding copyright ownership.\n+ *\n+ * This program and the accompanying materials are made available under the\n+ * terms of the Eclipse Public License 2.0 which is available at\n+ * http://www.eclipse.org/legal/epl-2.0\n+ *\n+ * SPDX-License-Identifier: EPL-2.0\n+ */\n+package org.eclipse.smarthome.auth.oauth2client.internal;\n+\n+import static org.eclipse.smarthome.core.auth.client.oauth2.Keyword.*;\n+\n+import java.net.URI;\n+import java.net.URISyntaxException;\n+import java.nio.charset.StandardCharsets;\n+import java.security.AccessController;\n+import java.security.KeyManagementException;\n+import java.security.KeyStore;\n+import java.security.NoSuchAlgorithmException;\n+import java.security.PrivilegedActionException;\n+import java.security.PrivilegedExceptionAction;\n+import java.security.SecureRandom;\n+import java.security.cert.CRL;\n+import java.util.Base64;\n+import java.util.Collection;\n+import java.util.concurrent.ExecutorService;\n+import java.util.concurrent.Executors;\n+\n+import javax.net.ssl.SSLContext;\n+import javax.net.ssl.TrustManager;\n+\n+import org.eclipse.jdt.annotation.NonNull;\n+import org.eclipse.jdt.annotation.Nullable;\n+import org.eclipse.jetty.client.HttpClient;\n+import org.eclipse.jetty.client.api.ContentResponse;\n+import org.eclipse.jetty.client.api.Request;\n+import org.eclipse.jetty.client.util.FormContentProvider;\n+import org.eclipse.jetty.http.HttpHeader;\n+import org.eclipse.jetty.http.HttpMethod;\n+import org.eclipse.jetty.http.HttpStatus;\n+import org.eclipse.jetty.util.Fields;\n+import org.eclipse.jetty.util.ssl.SslContextFactory;\n+import org.eclipse.smarthome.core.auth.client.oauth2.OAuthError;\n+import org.eclipse.smarthome.core.auth.client.oauth2.OAuthException;\n+import org.eclipse.smarthome.core.auth.client.oauth2.OAuthToken;\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import com.google.gson.FieldNamingPolicy;\n+import com.google.gson.Gson;\n+import com.google.gson.GsonBuilder;\n+\n+/**\n+ * Implementation of the OAuthConnector. It directly deals with the underlying http connections (using Jetty)\n+ *\n+ * @author m.bock - Initial contribution\n+ * @author Gary Tse - adaptation\n+ *\n+ */\n+public class OAuthConnector {\n+\n+    private static final int ADDRESS_RESOLUTION_TIMEOUT_MILLIS = 3000; // 3 seconds\n+    private static final int CONNECT_TIMEOUT_MILLIS = 5000; // 5 seconds\n+    private static final int IDLE_TIMEOUT_MILLIS = 10000; // 10 seconds\n+    private static final int MAX_CONNS_PER_DESITINATION = 1;\n+\n+    /**\n+     * The custom trust managers will be used during SSLContext.init( KeyManager[], TrustManager[], SecureRandom );\n+     * It will be applied when it is not null.  When null, the JVM default is used.\n+     */\n+    private TrustManager[] customTrustManagers;\n+\n+    private final Logger logger = LoggerFactory.getLogger(OAuthConnector.class);\n+    private final Gson gson;\n+    // private SslService sslService;","path":"bundles/auth/org.eclipse.smarthome.auth.oauth2client/src/main/java/org/eclipse/smarthome/auth/oauth2client/internal/OAuthConnector.java","position":79,"original_position":79,"commit_id":"62d3a834ecc70c5d812ac222afa610776eea18a6","original_commit_id":"62d3a834ecc70c5d812ac222afa610776eea18a6","user":{"login":"amitjoy","id":13380182,"avatar_url":"https://avatars0.githubusercontent.com/u/13380182?v=4","gravatar_id":"","url":"https://api.github.com/users/amitjoy","html_url":"https://github.com/amitjoy","followers_url":"https://api.github.com/users/amitjoy/followers","following_url":"https://api.github.com/users/amitjoy/following{/other_user}","gists_url":"https://api.github.com/users/amitjoy/gists{/gist_id}","starred_url":"https://api.github.com/users/amitjoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitjoy/subscriptions","organizations_url":"https://api.github.com/users/amitjoy/orgs","repos_url":"https://api.github.com/users/amitjoy/repos","events_url":"https://api.github.com/users/amitjoy/events{/privacy}","received_events_url":"https://api.github.com/users/amitjoy/received_events","type":"User","site_admin":false},"body":"can be removed","created_at":"2018-03-06T17:24:36Z","updated_at":"2018-03-06T17:24:36Z","html_url":"https://github.com/eclipse/smarthome/pull/5142#discussion_r172595222","pull_request_url":"https://api.github.com/repos/eclipse/smarthome/pulls/5142","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments/172595222"},"html":{"href":"https://github.com/eclipse/smarthome/pull/5142#discussion_r172595222"},"pull_request":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/5142"}}},"pull_request":{"url":"https://api.github.com/repos/eclipse/smarthome/pulls/5142","id":171115874,"html_url":"https://github.com/eclipse/smarthome/pull/5142","diff_url":"https://github.com/eclipse/smarthome/pull/5142.diff","patch_url":"https://github.com/eclipse/smarthome/pull/5142.patch","issue_url":"https://api.github.com/repos/eclipse/smarthome/issues/5142","number":5142,"state":"open","locked":false,"title":"OAuth2 client initial contribution","user":{"login":"garytse","id":951766,"avatar_url":"https://avatars3.githubusercontent.com/u/951766?v=4","gravatar_id":"","url":"https://api.github.com/users/garytse","html_url":"https://github.com/garytse","followers_url":"https://api.github.com/users/garytse/followers","following_url":"https://api.github.com/users/garytse/following{/other_user}","gists_url":"https://api.github.com/users/garytse/gists{/gist_id}","starred_url":"https://api.github.com/users/garytse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garytse/subscriptions","organizations_url":"https://api.github.com/users/garytse/orgs","repos_url":"https://api.github.com/users/garytse/repos","events_url":"https://api.github.com/users/garytse/events{/privacy}","received_events_url":"https://api.github.com/users/garytse/received_events","type":"User","site_admin":false},"body":"Support getting access token by username password, by authorization code.\r\nSupport refresh token\r\nSupport caching\r\nNo 3rd party library needed\r\nAccounts migration support to be added *EDIT: added now*","created_at":"2018-02-23T21:03:37Z","updated_at":"2018-03-06T17:24:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"77f022fad04b7edee5950aa8e2f3d27dadd19622","assignee":null,"assignees":[],"requested_reviewers":[{"login":"kaikreuzer","id":3244965,"avatar_url":"https://avatars3.githubusercontent.com/u/3244965?v=4","gravatar_id":"","url":"https://api.github.com/users/kaikreuzer","html_url":"https://github.com/kaikreuzer","followers_url":"https://api.github.com/users/kaikreuzer/followers","following_url":"https://api.github.com/users/kaikreuzer/following{/other_user}","gists_url":"https://api.github.com/users/kaikreuzer/gists{/gist_id}","starred_url":"https://api.github.com/users/kaikreuzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaikreuzer/subscriptions","organizations_url":"https://api.github.com/users/kaikreuzer/orgs","repos_url":"https://api.github.com/users/kaikreuzer/repos","events_url":"https://api.github.com/users/kaikreuzer/events{/privacy}","received_events_url":"https://api.github.com/users/kaikreuzer/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eclipse/smarthome/pulls/5142/commits","review_comments_url":"https://api.github.com/repos/eclipse/smarthome/pulls/5142/comments","review_comment_url":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eclipse/smarthome/issues/5142/comments","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/62d3a834ecc70c5d812ac222afa610776eea18a6","head":{"label":"garytse:feature/oauth2","ref":"feature/oauth2","sha":"62d3a834ecc70c5d812ac222afa610776eea18a6","user":{"login":"garytse","id":951766,"avatar_url":"https://avatars3.githubusercontent.com/u/951766?v=4","gravatar_id":"","url":"https://api.github.com/users/garytse","html_url":"https://github.com/garytse","followers_url":"https://api.github.com/users/garytse/followers","following_url":"https://api.github.com/users/garytse/following{/other_user}","gists_url":"https://api.github.com/users/garytse/gists{/gist_id}","starred_url":"https://api.github.com/users/garytse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garytse/subscriptions","organizations_url":"https://api.github.com/users/garytse/orgs","repos_url":"https://api.github.com/users/garytse/repos","events_url":"https://api.github.com/users/garytse/events{/privacy}","received_events_url":"https://api.github.com/users/garytse/received_events","type":"User","site_admin":false},"repo":{"id":101309908,"name":"smarthome","full_name":"garytse/smarthome","owner":{"login":"garytse","id":951766,"avatar_url":"https://avatars3.githubusercontent.com/u/951766?v=4","gravatar_id":"","url":"https://api.github.com/users/garytse","html_url":"https://github.com/garytse","followers_url":"https://api.github.com/users/garytse/followers","following_url":"https://api.github.com/users/garytse/following{/other_user}","gists_url":"https://api.github.com/users/garytse/gists{/gist_id}","starred_url":"https://api.github.com/users/garytse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garytse/subscriptions","organizations_url":"https://api.github.com/users/garytse/orgs","repos_url":"https://api.github.com/users/garytse/repos","events_url":"https://api.github.com/users/garytse/events{/privacy}","received_events_url":"https://api.github.com/users/garytse/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/garytse/smarthome","description":"Eclipse SmartHome project","fork":true,"url":"https://api.github.com/repos/garytse/smarthome","forks_url":"https://api.github.com/repos/garytse/smarthome/forks","keys_url":"https://api.github.com/repos/garytse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/garytse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/garytse/smarthome/teams","hooks_url":"https://api.github.com/repos/garytse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/garytse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/garytse/smarthome/events","assignees_url":"https://api.github.com/repos/garytse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/garytse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/garytse/smarthome/tags","blobs_url":"https://api.github.com/repos/garytse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/garytse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/garytse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/garytse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/garytse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/garytse/smarthome/languages","stargazers_url":"https://api.github.com/repos/garytse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/garytse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/garytse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/garytse/smarthome/subscription","commits_url":"https://api.github.com/repos/garytse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/garytse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/garytse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/garytse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/garytse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/garytse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/garytse/smarthome/merges","archive_url":"https://api.github.com/repos/garytse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/garytse/smarthome/downloads","issues_url":"https://api.github.com/repos/garytse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/garytse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/garytse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/garytse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/garytse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/garytse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/garytse/smarthome/deployments","created_at":"2017-08-24T15:23:49Z","updated_at":"2017-08-24T15:23:58Z","pushed_at":"2018-03-05T21:23:16Z","git_url":"git://github.com/garytse/smarthome.git","ssh_url":"git@github.com:garytse/smarthome.git","clone_url":"https://github.com/garytse/smarthome.git","svn_url":"https://github.com/garytse/smarthome","homepage":null,"size":50261,"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":0,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"eclipse:master","ref":"master","sha":"89af3025393fd4bc965832c220dfd908d1e95ec9","user":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"repo":{"id":15778981,"name":"smarthome","full_name":"eclipse/smarthome","owner":{"login":"eclipse","id":56974,"avatar_url":"https://avatars1.githubusercontent.com/u/56974?v=4","gravatar_id":"","url":"https://api.github.com/users/eclipse","html_url":"https://github.com/eclipse","followers_url":"https://api.github.com/users/eclipse/followers","following_url":"https://api.github.com/users/eclipse/following{/other_user}","gists_url":"https://api.github.com/users/eclipse/gists{/gist_id}","starred_url":"https://api.github.com/users/eclipse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eclipse/subscriptions","organizations_url":"https://api.github.com/users/eclipse/orgs","repos_url":"https://api.github.com/users/eclipse/repos","events_url":"https://api.github.com/users/eclipse/events{/privacy}","received_events_url":"https://api.github.com/users/eclipse/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eclipse/smarthome","description":"Eclipse SmartHome™ project","fork":false,"url":"https://api.github.com/repos/eclipse/smarthome","forks_url":"https://api.github.com/repos/eclipse/smarthome/forks","keys_url":"https://api.github.com/repos/eclipse/smarthome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eclipse/smarthome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eclipse/smarthome/teams","hooks_url":"https://api.github.com/repos/eclipse/smarthome/hooks","issue_events_url":"https://api.github.com/repos/eclipse/smarthome/issues/events{/number}","events_url":"https://api.github.com/repos/eclipse/smarthome/events","assignees_url":"https://api.github.com/repos/eclipse/smarthome/assignees{/user}","branches_url":"https://api.github.com/repos/eclipse/smarthome/branches{/branch}","tags_url":"https://api.github.com/repos/eclipse/smarthome/tags","blobs_url":"https://api.github.com/repos/eclipse/smarthome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eclipse/smarthome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eclipse/smarthome/git/refs{/sha}","trees_url":"https://api.github.com/repos/eclipse/smarthome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eclipse/smarthome/statuses/{sha}","languages_url":"https://api.github.com/repos/eclipse/smarthome/languages","stargazers_url":"https://api.github.com/repos/eclipse/smarthome/stargazers","contributors_url":"https://api.github.com/repos/eclipse/smarthome/contributors","subscribers_url":"https://api.github.com/repos/eclipse/smarthome/subscribers","subscription_url":"https://api.github.com/repos/eclipse/smarthome/subscription","commits_url":"https://api.github.com/repos/eclipse/smarthome/commits{/sha}","git_commits_url":"https://api.github.com/repos/eclipse/smarthome/git/commits{/sha}","comments_url":"https://api.github.com/repos/eclipse/smarthome/comments{/number}","issue_comment_url":"https://api.github.com/repos/eclipse/smarthome/issues/comments{/number}","contents_url":"https://api.github.com/repos/eclipse/smarthome/contents/{+path}","compare_url":"https://api.github.com/repos/eclipse/smarthome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eclipse/smarthome/merges","archive_url":"https://api.github.com/repos/eclipse/smarthome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eclipse/smarthome/downloads","issues_url":"https://api.github.com/repos/eclipse/smarthome/issues{/number}","pulls_url":"https://api.github.com/repos/eclipse/smarthome/pulls{/number}","milestones_url":"https://api.github.com/repos/eclipse/smarthome/milestones{/number}","notifications_url":"https://api.github.com/repos/eclipse/smarthome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eclipse/smarthome/labels{/name}","releases_url":"https://api.github.com/repos/eclipse/smarthome/releases{/id}","deployments_url":"https://api.github.com/repos/eclipse/smarthome/deployments","created_at":"2014-01-09T20:47:19Z","updated_at":"2018-03-06T08:05:43Z","pushed_at":"2018-03-06T16:53:07Z","git_url":"git://github.com/eclipse/smarthome.git","ssh_url":"git@github.com:eclipse/smarthome.git","clone_url":"https://github.com/eclipse/smarthome.git","svn_url":"https://github.com/eclipse/smarthome","homepage":"https://www.eclipse.org/smarthome/","size":49850,"stargazers_count":655,"watchers_count":655,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":637,"mirror_url":null,"archived":false,"open_issues_count":417,"license":{"key":"epl-2.0","name":"Eclipse Public License 2.0","spdx_id":"EPL-2.0","url":"https://api.github.com/licenses/epl-2.0"},"forks":637,"open_issues":417,"watchers":655,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/5142"},"html":{"href":"https://github.com/eclipse/smarthome/pull/5142"},"issue":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/5142"},"comments":{"href":"https://api.github.com/repos/eclipse/smarthome/issues/5142/comments"},"review_comments":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/5142/comments"},"review_comment":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eclipse/smarthome/pulls/5142/commits"},"statuses":{"href":"https://api.github.com/repos/eclipse/smarthome/statuses/62d3a834ecc70c5d812ac222afa610776eea18a6"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"amitjoy"}}