{"action":"created","comment":{"url":"https://api.github.com/repos/Teradata/presto/pulls/comments/83933920","pull_request_review_id":4742760,"id":83933920,"diff_hunk":"@@ -0,0 +1,136 @@\n+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * 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 com.facebook.presto.jdbc;\n+\n+import com.google.common.base.Joiner;\n+import com.google.common.collect.ImmutableMap;\n+import com.google.common.collect.ImmutableSet;\n+\n+import java.sql.SQLException;\n+import java.util.Map;\n+import java.util.Optional;\n+import java.util.Properties;\n+import java.util.Set;\n+\n+import static java.lang.String.format;\n+\n+public class ConnectionProperties\n+{\n+    public static final ConnectionProperty USER = new User();\n+    public static final ConnectionProperty PASSWORD = new Password();\n+    public static final ConnectionProperty SSL = new Ssl();\n+    public static final ConnectionProperty SSL_TRUST_STORE_PATH = new SslTrustStorePath();\n+    public static final ConnectionProperty SSL_TRUST_STORE_PASSWORD = new SslTrustStorePassword();\n+\n+    public static final Set<ConnectionProperty> allOf = ImmutableSet.of(\n+            USER,\n+            PASSWORD,\n+            SSL,\n+            SSL_TRUST_STORE_PATH,\n+            SSL_TRUST_STORE_PASSWORD);\n+\n+    private static final Map<String, ConnectionProperty> keyLookup;\n+\n+    static {\n+        ImmutableMap.Builder<String, ConnectionProperty> builder = ImmutableMap.builder();\n+        for (ConnectionProperty property : allOf) {\n+            builder.put(property.getKey(), property);\n+        }\n+        keyLookup = builder.build();\n+    }\n+\n+    private ConnectionProperties()\n+    {\n+    }\n+\n+    public static ConnectionProperty forKey(String propertiesKey)\n+    {\n+        return keyLookup.get(propertiesKey);\n+    }\n+\n+    public static Map<String, String> getDefaults()\n+    {\n+        ImmutableMap.Builder<String, String> result = ImmutableMap.builder();\n+        for (ConnectionProperty property : allOf) {\n+            Optional<String> value = property.getDefault();\n+            if (value.isPresent()) {\n+                result.put(property.getKey(), value.get());\n+            }\n+        }\n+        return result.build();\n+    }\n+\n+    private static class User\n+            extends BaseConnectionProperty<String>\n+    {\n+        private User()\n+        {\n+            super(\"user\", required, stringConverter);\n+        }\n+    }\n+\n+    private static class Password\n+            extends BaseConnectionProperty<String>\n+    {\n+        private Password()\n+        {\n+            super(\"password\", notRequired, stringConverter);\n+        }\n+    }\n+\n+    private static final Integer SSL_DISABLED = 0;\n+    private static final Integer SSL_ENABLED = 1;\n+    private static class Ssl\n+            extends BaseConnectionProperty<Integer>\n+    {\n+        private static final ImmutableSet<Integer> allowed = ImmutableSet.of(SSL_DISABLED, SSL_ENABLED);\n+\n+        private Ssl()\n+        {\n+            super(\"SSL\", Optional.of(SSL_DISABLED.toString()), notRequired, integerConverter);\n+        }\n+\n+        @Override\n+        public void validate(Properties properties)\n+                throws SQLException\n+        {\n+            Optional<Integer> flag = getValue(properties);\n+            if (!flag.isPresent()) {\n+                return;\n+            }\n+\n+            if (!allowed.contains(flag.get())) {\n+                throw new SQLException(format(\"The value of %s must be one of %s\", getKey(), Joiner.on(\", \").join(allowed)));\n+            }\n+        }\n+    }\n+\n+    public static class SslTrustStorePath\n+            extends BaseConnectionProperty<String>\n+    {\n+        private SslTrustStorePath()\n+        {\n+            super(\"SSLTrustStorePath\", dependsKeyValue(new Ssl(), SSL_ENABLED.toString()), stringConverter);\n+        }\n+    }\n+\n+    public static class SslTrustStorePassword\n+            extends BaseConnectionProperty<String>\n+    {\n+        private SslTrustStorePassword()\n+        {\n+            super(\"SSLTrustStorePassword\", dependsKeyValue(new Ssl(), SSL_ENABLED.toString()), stringConverter);","path":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/ConnectionProperties.java","position":133,"original_position":133,"commit_id":"1c18ff48c1fcabf204f3d8d7e296825fb1ec43a0","original_commit_id":"1c18ff48c1fcabf204f3d8d7e296825fb1ec43a0","user":{"login":"arhimondr","id":5570988,"avatar_url":"https://avatars.githubusercontent.com/u/5570988?v=3","gravatar_id":"","url":"https://api.github.com/users/arhimondr","html_url":"https://github.com/arhimondr","followers_url":"https://api.github.com/users/arhimondr/followers","following_url":"https://api.github.com/users/arhimondr/following{/other_user}","gists_url":"https://api.github.com/users/arhimondr/gists{/gist_id}","starred_url":"https://api.github.com/users/arhimondr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arhimondr/subscriptions","organizations_url":"https://api.github.com/users/arhimondr/orgs","repos_url":"https://api.github.com/users/arhimondr/repos","events_url":"https://api.github.com/users/arhimondr/events{/privacy}","received_events_url":"https://api.github.com/users/arhimondr/received_events","type":"User","site_admin":false},"body":"ditto","created_at":"2016-10-18T19:39:30Z","updated_at":"2016-10-18T19:58:55Z","html_url":"https://github.com/Teradata/presto/pull/391#discussion_r83933920","pull_request_url":"https://api.github.com/repos/Teradata/presto/pulls/391","_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments/83933920"},"html":{"href":"https://github.com/Teradata/presto/pull/391#discussion_r83933920"},"pull_request":{"href":"https://api.github.com/repos/Teradata/presto/pulls/391"}}},"pull_request":{"url":"https://api.github.com/repos/Teradata/presto/pulls/391","id":89834031,"html_url":"https://github.com/Teradata/presto/pull/391","diff_url":"https://github.com/Teradata/presto/pull/391.diff","patch_url":"https://github.com/Teradata/presto/pull/391.patch","issue_url":"https://api.github.com/repos/Teradata/presto/issues/391","number":391,"state":"open","locked":false,"title":"Add support for SSL/TLS in JDBC driver","user":{"login":"ebd2","id":12751788,"avatar_url":"https://avatars.githubusercontent.com/u/12751788?v=3","gravatar_id":"","url":"https://api.github.com/users/ebd2","html_url":"https://github.com/ebd2","followers_url":"https://api.github.com/users/ebd2/followers","following_url":"https://api.github.com/users/ebd2/following{/other_user}","gists_url":"https://api.github.com/users/ebd2/gists{/gist_id}","starred_url":"https://api.github.com/users/ebd2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebd2/subscriptions","organizations_url":"https://api.github.com/users/ebd2/orgs","repos_url":"https://api.github.com/users/ebd2/repos","events_url":"https://api.github.com/users/ebd2/events{/privacy}","received_events_url":"https://api.github.com/users/ebd2/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-18T15:01:36Z","updated_at":"2016-10-18T19:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e11fe193696ec6930f3b1ee143db0bfa95ae39f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Teradata/presto/pulls/391/commits","review_comments_url":"https://api.github.com/repos/Teradata/presto/pulls/391/comments","review_comment_url":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Teradata/presto/issues/391/comments","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/1c18ff48c1fcabf204f3d8d7e296825fb1ec43a0","head":{"label":"Teradata:jdbc-tls","ref":"jdbc-tls","sha":"1c18ff48c1fcabf204f3d8d7e296825fb1ec43a0","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-10-07T04:15:04Z","pushed_at":"2016-10-18T18:15:11Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":166058,"stargazers_count":58,"watchers_count":58,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":58,"default_branch":"master"}},"base":{"label":"Teradata:httpclient","ref":"httpclient","sha":"ca96291a5f72c83ea50299f964a19f4117cc8c4a","user":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"repo":{"id":36903368,"name":"presto","full_name":"Teradata/presto","owner":{"login":"Teradata","id":1615979,"avatar_url":"https://avatars.githubusercontent.com/u/1615979?v=3","gravatar_id":"","url":"https://api.github.com/users/Teradata","html_url":"https://github.com/Teradata","followers_url":"https://api.github.com/users/Teradata/followers","following_url":"https://api.github.com/users/Teradata/following{/other_user}","gists_url":"https://api.github.com/users/Teradata/gists{/gist_id}","starred_url":"https://api.github.com/users/Teradata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Teradata/subscriptions","organizations_url":"https://api.github.com/users/Teradata/orgs","repos_url":"https://api.github.com/users/Teradata/repos","events_url":"https://api.github.com/users/Teradata/events{/privacy}","received_events_url":"https://api.github.com/users/Teradata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Teradata/presto","description":"Teradata Distribution of Presto -- A Distributed SQL Query Engine for Big Data","fork":true,"url":"https://api.github.com/repos/Teradata/presto","forks_url":"https://api.github.com/repos/Teradata/presto/forks","keys_url":"https://api.github.com/repos/Teradata/presto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Teradata/presto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Teradata/presto/teams","hooks_url":"https://api.github.com/repos/Teradata/presto/hooks","issue_events_url":"https://api.github.com/repos/Teradata/presto/issues/events{/number}","events_url":"https://api.github.com/repos/Teradata/presto/events","assignees_url":"https://api.github.com/repos/Teradata/presto/assignees{/user}","branches_url":"https://api.github.com/repos/Teradata/presto/branches{/branch}","tags_url":"https://api.github.com/repos/Teradata/presto/tags","blobs_url":"https://api.github.com/repos/Teradata/presto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Teradata/presto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Teradata/presto/git/refs{/sha}","trees_url":"https://api.github.com/repos/Teradata/presto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Teradata/presto/statuses/{sha}","languages_url":"https://api.github.com/repos/Teradata/presto/languages","stargazers_url":"https://api.github.com/repos/Teradata/presto/stargazers","contributors_url":"https://api.github.com/repos/Teradata/presto/contributors","subscribers_url":"https://api.github.com/repos/Teradata/presto/subscribers","subscription_url":"https://api.github.com/repos/Teradata/presto/subscription","commits_url":"https://api.github.com/repos/Teradata/presto/commits{/sha}","git_commits_url":"https://api.github.com/repos/Teradata/presto/git/commits{/sha}","comments_url":"https://api.github.com/repos/Teradata/presto/comments{/number}","issue_comment_url":"https://api.github.com/repos/Teradata/presto/issues/comments{/number}","contents_url":"https://api.github.com/repos/Teradata/presto/contents/{+path}","compare_url":"https://api.github.com/repos/Teradata/presto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Teradata/presto/merges","archive_url":"https://api.github.com/repos/Teradata/presto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Teradata/presto/downloads","issues_url":"https://api.github.com/repos/Teradata/presto/issues{/number}","pulls_url":"https://api.github.com/repos/Teradata/presto/pulls{/number}","milestones_url":"https://api.github.com/repos/Teradata/presto/milestones{/number}","notifications_url":"https://api.github.com/repos/Teradata/presto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Teradata/presto/labels{/name}","releases_url":"https://api.github.com/repos/Teradata/presto/releases{/id}","deployments_url":"https://api.github.com/repos/Teradata/presto/deployments","created_at":"2015-06-05T00:38:37Z","updated_at":"2016-10-07T04:15:04Z","pushed_at":"2016-10-18T18:15:11Z","git_url":"git://github.com/Teradata/presto.git","ssh_url":"git@github.com:Teradata/presto.git","clone_url":"https://github.com/Teradata/presto.git","svn_url":"https://github.com/Teradata/presto","homepage":"http://www.teradata.com/presto","size":166058,"stargazers_count":58,"watchers_count":58,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":20,"forks":12,"open_issues":20,"watchers":58,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Teradata/presto/pulls/391"},"html":{"href":"https://github.com/Teradata/presto/pull/391"},"issue":{"href":"https://api.github.com/repos/Teradata/presto/issues/391"},"comments":{"href":"https://api.github.com/repos/Teradata/presto/issues/391/comments"},"review_comments":{"href":"https://api.github.com/repos/Teradata/presto/pulls/391/comments"},"review_comment":{"href":"https://api.github.com/repos/Teradata/presto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Teradata/presto/pulls/391/commits"},"statuses":{"href":"https://api.github.com/repos/Teradata/presto/statuses/1c18ff48c1fcabf204f3d8d7e296825fb1ec43a0"}}}}
{"actor":{"display_login":"arhimondr"}}