From commits-return-15626-archive-asf-public=cust-asf.ponee.io@pulsar.apache.org Thu Oct 4 18:59:15 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id D3780180658 for ; Thu, 4 Oct 2018 18:59:14 +0200 (CEST) Received: (qmail 75961 invoked by uid 500); 4 Oct 2018 16:59:14 -0000 Mailing-List: contact commits-help@pulsar.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pulsar.apache.org Delivered-To: mailing list commits@pulsar.apache.org Received: (qmail 75952 invoked by uid 99); 4 Oct 2018 16:59:13 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2018 16:59:13 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 4503F85B57; Thu, 4 Oct 2018 16:59:13 +0000 (UTC) Date: Thu, 04 Oct 2018 16:59:12 +0000 To: "commits@pulsar.apache.org" Subject: [pulsar] branch master updated: Add System Property Option for Athenz (#2707) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <153867235282.4409.7079840825104340689@gitbox.apache.org> From: mmerli@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: pulsar X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 24749e16bdb1e3a4f9891713834c2be0792f786f X-Git-Newrev: bb945d388ebf04fee3583680e5ee86988b131e26 X-Git-Rev: bb945d388ebf04fee3583680e5ee86988b131e26 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mmerli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar.git The following commit(s) were added to refs/heads/master by this push: new bb945d3 Add System Property Option for Athenz (#2707) bb945d3 is described below commit bb945d388ebf04fee3583680e5ee86988b131e26 Author: Yuta Mochizuki <41100271+yumochiz@users.noreply.github.com> AuthorDate: Fri Oct 5 01:59:08 2018 +0900 Add System Property Option for Athenz (#2707) --- .../authentication/AuthenticationProviderAthenz.java | 12 ++++++++++-- .../authentication/AuthenticationProviderAthenzTest.java | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java index 3a00c20..c2cf45d 100644 --- a/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java +++ b/pulsar-broker-auth-athenz/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenz.java @@ -25,6 +25,7 @@ import java.security.PublicKey; import javax.naming.AuthenticationException; +import org.apache.commons.lang3.StringUtils; import org.apache.pulsar.broker.authentication.AuthenticationDataSource; import org.apache.pulsar.broker.authentication.AuthenticationProvider; import org.slf4j.Logger; @@ -39,14 +40,21 @@ public class AuthenticationProviderAthenz implements AuthenticationProvider { private static final String DOMAIN_NAME_LIST = "athenzDomainNames"; + private static final String SYS_PROP_DOMAIN_NAME_LIST = "pulsar.athenz.domain.names"; + private List domainNameList = null; @Override public void initialize(ServiceConfiguration config) throws IOException { - if (config.getProperty(DOMAIN_NAME_LIST) == null) { + String domainNames; + if (config.getProperty(DOMAIN_NAME_LIST) != null) { + domainNames = (String) config.getProperty(DOMAIN_NAME_LIST); + } else if (!StringUtils.isEmpty(System.getProperty(SYS_PROP_DOMAIN_NAME_LIST))) { + domainNames = System.getProperty(SYS_PROP_DOMAIN_NAME_LIST); + } else { throw new IOException("No athenz domain name specified"); } - String domainNames = (String) config.getProperty(DOMAIN_NAME_LIST); + domainNameList = Lists.newArrayList(domainNames.split(",")); log.info("Supported domain names for athenz: {}", domainNameList); } diff --git a/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java b/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java index 75934b1..1946a01 100644 --- a/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java +++ b/pulsar-broker-auth-athenz/src/test/java/org/apache/pulsar/broker/authentication/AuthenticationProviderAthenzTest.java @@ -20,6 +20,7 @@ package org.apache.pulsar.broker.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; + import org.testng.annotations.Test; import org.testng.annotations.BeforeClass; @@ -64,6 +65,20 @@ public class AuthenticationProviderAthenzTest { } @Test + public void testInitilizeFromSystemPropeties() { + System.setProperty("pulsar.athenz.domain.names", "test_provider"); + ServiceConfiguration emptyConf = new ServiceConfiguration(); + Properties emptyProp = new Properties(); + emptyConf.setProperties(emptyProp); + AuthenticationProviderAthenz sysPropProvider = new AuthenticationProviderAthenz(); + try { + sysPropProvider.initialize(emptyConf); + } catch (Exception e) { + fail("Fail to Read pulsar.athenz.domain.names from System Properties"); + } + } + + @Test public void testAuthenticateSignedToken() throws Exception { List roles = new ArrayList() {