{"action":"created","comment":{"url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/comments/229664602","pull_request_review_id":170214528,"id":229664602,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTY2NDYwMg==","diff_hunk":"@@ -0,0 +1,158 @@\n+/*\n+ * Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.\n+ *\n+ * WSO2 Inc. licenses this file to you under the Apache License,\n+ * Version 2.0 (the \"License\"); you may not use this file except\n+ * 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,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ *\n+ */\n+package io.ballerina.messaging.broker.auth.ldap;\n+\n+import io.ballerina.messaging.broker.auth.AuthException;\n+import io.ballerina.messaging.broker.auth.BrokerAuthConfiguration;\n+\n+import org.slf4j.Logger;\n+import org.slf4j.LoggerFactory;\n+\n+import java.io.FileInputStream;\n+import java.io.IOException;\n+import java.nio.file.Paths;\n+import java.security.KeyManagementException;\n+import java.security.KeyStore;\n+import java.security.KeyStoreException;\n+import java.security.NoSuchAlgorithmException;\n+import java.security.cert.CertificateException;\n+import java.util.Hashtable;\n+import javax.naming.Context;\n+import javax.naming.NamingEnumeration;\n+import javax.naming.NamingException;\n+import javax.naming.directory.DirContext;\n+import javax.naming.directory.InitialDirContext;\n+import javax.naming.directory.SearchControls;\n+import javax.naming.directory.SearchResult;\n+import javax.net.ssl.SSLContext;\n+import javax.net.ssl.TrustManagerFactory;\n+\n+/**\n+ * Handles Ldap queries.\n+ */\n+public class LdapAuthHandler {\n+\n+    private static final Logger LOGGER = LoggerFactory.getLogger(LdapAuthHandler.class);\n+    private BrokerAuthConfiguration.LdapConfiguration ldapConfiguration;\n+\n+    public LdapAuthHandler(BrokerAuthConfiguration.LdapConfiguration ldapConfiguration) throws AuthException {\n+\n+        this.ldapConfiguration = ldapConfiguration;\n+\n+        if (ldapConfiguration.getSsl().isEnabled()) {\n+\n+            String trustStoreLocation = Paths.get(ldapConfiguration.getSsl().getTrustStore().getLocation())\n+                    .toAbsolutePath().toString();\n+            try (FileInputStream fin = new FileInputStream(trustStoreLocation)) {","path":"modules/broker-auth/src/main/java/io/ballerina/messaging/broker/auth/ldap/LdapAuthHandler.java","position":62,"original_position":62,"commit_id":"e98a53983025a9f6ac6b6912fd4c9a4a5fba655c","original_commit_id":"e98a53983025a9f6ac6b6912fd4c9a4a5fba655c","user":{"login":"ThishaniLucas","id":8208020,"node_id":"MDQ6VXNlcjgyMDgwMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/8208020?v=4","gravatar_id":"","url":"https://api.github.com/users/ThishaniLucas","html_url":"https://github.com/ThishaniLucas","followers_url":"https://api.github.com/users/ThishaniLucas/followers","following_url":"https://api.github.com/users/ThishaniLucas/following{/other_user}","gists_url":"https://api.github.com/users/ThishaniLucas/gists{/gist_id}","starred_url":"https://api.github.com/users/ThishaniLucas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThishaniLucas/subscriptions","organizations_url":"https://api.github.com/users/ThishaniLucas/orgs","repos_url":"https://api.github.com/users/ThishaniLucas/repos","events_url":"https://api.github.com/users/ThishaniLucas/events{/privacy}","received_events_url":"https://api.github.com/users/ThishaniLucas/received_events","type":"User","site_admin":false},"body":"We need to close the input stream.","created_at":"2018-10-31T12:00:32Z","updated_at":"2018-10-31T12:00:32Z","html_url":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546#discussion_r229664602","pull_request_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/comments/229664602"},"html":{"href":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546#discussion_r229664602"},"pull_request":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546"}}},"pull_request":{"url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546","id":227250719,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MjUwNzE5","html_url":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546","diff_url":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546.diff","patch_url":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546.patch","issue_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/546","number":546,"state":"open","locked":false,"title":"Implement ldap authentication","user":{"login":"tharinduwijewardane","id":1345465,"node_id":"MDQ6VXNlcjEzNDU0NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/1345465?v=4","gravatar_id":"","url":"https://api.github.com/users/tharinduwijewardane","html_url":"https://github.com/tharinduwijewardane","followers_url":"https://api.github.com/users/tharinduwijewardane/followers","following_url":"https://api.github.com/users/tharinduwijewardane/following{/other_user}","gists_url":"https://api.github.com/users/tharinduwijewardane/gists{/gist_id}","starred_url":"https://api.github.com/users/tharinduwijewardane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tharinduwijewardane/subscriptions","organizations_url":"https://api.github.com/users/tharinduwijewardane/orgs","repos_url":"https://api.github.com/users/tharinduwijewardane/repos","events_url":"https://api.github.com/users/tharinduwijewardane/events{/privacy}","received_events_url":"https://api.github.com/users/tharinduwijewardane/received_events","type":"User","site_admin":false},"body":"This update provides the ability to use a Ldap server for authentication.\r\nConfigurations are provided through the broker.yaml file.\r\n\r\nTodo:\r\nTest cases and documentation of configuration details\r\n\r\nIssue:\r\n[Implement user authentication using an LDAP server](https://github.com/ballerina-platform/ballerina-message-broker/issues/505)\r\n","created_at":"2018-10-31T11:31:59Z","updated_at":"2018-10-31T12:00:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f964bda71971488238c6c54a998459585242794","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546/commits","review_comments_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546/comments","review_comment_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/546/comments","statuses_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/statuses/e98a53983025a9f6ac6b6912fd4c9a4a5fba655c","head":{"label":"tharinduwijewardane:ldap-auth_impl","ref":"ldap-auth_impl","sha":"e98a53983025a9f6ac6b6912fd4c9a4a5fba655c","user":{"login":"tharinduwijewardane","id":1345465,"node_id":"MDQ6VXNlcjEzNDU0NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/1345465?v=4","gravatar_id":"","url":"https://api.github.com/users/tharinduwijewardane","html_url":"https://github.com/tharinduwijewardane","followers_url":"https://api.github.com/users/tharinduwijewardane/followers","following_url":"https://api.github.com/users/tharinduwijewardane/following{/other_user}","gists_url":"https://api.github.com/users/tharinduwijewardane/gists{/gist_id}","starred_url":"https://api.github.com/users/tharinduwijewardane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tharinduwijewardane/subscriptions","organizations_url":"https://api.github.com/users/tharinduwijewardane/orgs","repos_url":"https://api.github.com/users/tharinduwijewardane/repos","events_url":"https://api.github.com/users/tharinduwijewardane/events{/privacy}","received_events_url":"https://api.github.com/users/tharinduwijewardane/received_events","type":"User","site_admin":false},"repo":{"id":154644241,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQ2NDQyNDE=","name":"ballerina-message-broker","full_name":"tharinduwijewardane/ballerina-message-broker","private":false,"owner":{"login":"tharinduwijewardane","id":1345465,"node_id":"MDQ6VXNlcjEzNDU0NjU=","avatar_url":"https://avatars2.githubusercontent.com/u/1345465?v=4","gravatar_id":"","url":"https://api.github.com/users/tharinduwijewardane","html_url":"https://github.com/tharinduwijewardane","followers_url":"https://api.github.com/users/tharinduwijewardane/followers","following_url":"https://api.github.com/users/tharinduwijewardane/following{/other_user}","gists_url":"https://api.github.com/users/tharinduwijewardane/gists{/gist_id}","starred_url":"https://api.github.com/users/tharinduwijewardane/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tharinduwijewardane/subscriptions","organizations_url":"https://api.github.com/users/tharinduwijewardane/orgs","repos_url":"https://api.github.com/users/tharinduwijewardane/repos","events_url":"https://api.github.com/users/tharinduwijewardane/events{/privacy}","received_events_url":"https://api.github.com/users/tharinduwijewardane/received_events","type":"User","site_admin":false},"html_url":"https://github.com/tharinduwijewardane/ballerina-message-broker","description":"Ballerina Message Broker is a lightweight, easy-to-use, 100% open source message-brokering server.","fork":true,"url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker","forks_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/forks","keys_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/teams","hooks_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/hooks","issue_events_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/issues/events{/number}","events_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/events","assignees_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/assignees{/user}","branches_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/branches{/branch}","tags_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/tags","blobs_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/languages","stargazers_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/stargazers","contributors_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/contributors","subscribers_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/subscribers","subscription_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/subscription","commits_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/contents/{+path}","compare_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/merges","archive_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/downloads","issues_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/issues{/number}","pulls_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/labels{/name}","releases_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/releases{/id}","deployments_url":"https://api.github.com/repos/tharinduwijewardane/ballerina-message-broker/deployments","created_at":"2018-10-25T09:25:54Z","updated_at":"2018-10-25T09:25:58Z","pushed_at":"2018-10-31T11:15:16Z","git_url":"git://github.com/tharinduwijewardane/ballerina-message-broker.git","ssh_url":"git@github.com:tharinduwijewardane/ballerina-message-broker.git","clone_url":"https://github.com/tharinduwijewardane/ballerina-message-broker.git","svn_url":"https://github.com/tharinduwijewardane/ballerina-message-broker","homepage":"","size":4110,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ballerina-platform:ldap-auth","ref":"ldap-auth","sha":"1a03d8077f4fdb82d908010eb9ef2cf8f03d5f37","user":{"login":"ballerina-platform","id":34733518,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NzMzNTE4","avatar_url":"https://avatars2.githubusercontent.com/u/34733518?v=4","gravatar_id":"","url":"https://api.github.com/users/ballerina-platform","html_url":"https://github.com/ballerina-platform","followers_url":"https://api.github.com/users/ballerina-platform/followers","following_url":"https://api.github.com/users/ballerina-platform/following{/other_user}","gists_url":"https://api.github.com/users/ballerina-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/ballerina-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ballerina-platform/subscriptions","organizations_url":"https://api.github.com/users/ballerina-platform/orgs","repos_url":"https://api.github.com/users/ballerina-platform/repos","events_url":"https://api.github.com/users/ballerina-platform/events{/privacy}","received_events_url":"https://api.github.com/users/ballerina-platform/received_events","type":"Organization","site_admin":false},"repo":{"id":111517878,"node_id":"MDEwOlJlcG9zaXRvcnkxMTE1MTc4Nzg=","name":"ballerina-message-broker","full_name":"ballerina-platform/ballerina-message-broker","private":false,"owner":{"login":"ballerina-platform","id":34733518,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM0NzMzNTE4","avatar_url":"https://avatars2.githubusercontent.com/u/34733518?v=4","gravatar_id":"","url":"https://api.github.com/users/ballerina-platform","html_url":"https://github.com/ballerina-platform","followers_url":"https://api.github.com/users/ballerina-platform/followers","following_url":"https://api.github.com/users/ballerina-platform/following{/other_user}","gists_url":"https://api.github.com/users/ballerina-platform/gists{/gist_id}","starred_url":"https://api.github.com/users/ballerina-platform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ballerina-platform/subscriptions","organizations_url":"https://api.github.com/users/ballerina-platform/orgs","repos_url":"https://api.github.com/users/ballerina-platform/repos","events_url":"https://api.github.com/users/ballerina-platform/events{/privacy}","received_events_url":"https://api.github.com/users/ballerina-platform/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ballerina-platform/ballerina-message-broker","description":"Ballerina Message Broker is a lightweight, easy-to-use, 100% open source message-brokering server.","fork":false,"url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker","forks_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/forks","keys_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/teams","hooks_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/hooks","issue_events_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/events{/number}","events_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/events","assignees_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/assignees{/user}","branches_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/branches{/branch}","tags_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/tags","blobs_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/git/refs{/sha}","trees_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/statuses/{sha}","languages_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/languages","stargazers_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/stargazers","contributors_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/contributors","subscribers_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/subscribers","subscription_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/subscription","commits_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/commits{/sha}","git_commits_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/git/commits{/sha}","comments_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/comments{/number}","issue_comment_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/comments{/number}","contents_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/contents/{+path}","compare_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/merges","archive_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/downloads","issues_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues{/number}","pulls_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls{/number}","milestones_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/milestones{/number}","notifications_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/labels{/name}","releases_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/releases{/id}","deployments_url":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/deployments","created_at":"2017-11-21T08:02:59Z","updated_at":"2018-10-30T03:18:54Z","pushed_at":"2018-10-31T11:50:24Z","git_url":"git://github.com/ballerina-platform/ballerina-message-broker.git","ssh_url":"git@github.com:ballerina-platform/ballerina-message-broker.git","clone_url":"https://github.com/ballerina-platform/ballerina-message-broker.git","svn_url":"https://github.com/ballerina-platform/ballerina-message-broker","homepage":"","size":4102,"stargazers_count":11,"watchers_count":11,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":28,"open_issues":109,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546"},"html":{"href":"https://github.com/ballerina-platform/ballerina-message-broker/pull/546"},"issue":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/546"},"comments":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/issues/546/comments"},"review_comments":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546/comments"},"review_comment":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/pulls/546/commits"},"statuses":{"href":"https://api.github.com/repos/ballerina-platform/ballerina-message-broker/statuses/e98a53983025a9f6ac6b6912fd4c9a4a5fba655c"}},"author_association":"NONE"}}
{"actor":{"display_login":"ThishaniLucas"}}