AMBARI-21307 organized code, fixed build failures

Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/307f6259
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/307f6259
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/307f6259

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 307f6259f63069a47017f7c3959925776fc8ee1a
Parents: 086826e
Author: lpuskas <lpus...@apache.org>
Authored: Thu Sep 14 17:58:59 2017 +0200
Committer: lpuskas <lpus...@apache.org>
Committed: Thu Oct 12 19:25:51 2017 +0200

----------------------------------------------------------------------
 .../ldap/domain/AmbariLdapConfigKeys.java       | 72 ++++++++++++++++++++
 .../ldap/domain/AmbariLdapConfiguration.java    |  3 -
 .../ldap/domain/LdapConfigurationFactory.java   |  2 +-
 .../ldap/service/AmbariLdapConfigKeys.java      | 72 --------------------
 .../DefaultLdapAttributeDetectionService.java   |  2 +-
 .../domain/AmbariLdapConfigurationTest.java     | 19 ++++++
 .../TestAmbariLdapConfigurationFactory.java     | 29 ++++++++
 ...efaultLdapAttributeDetectionServiceTest.java |  9 ++-
 .../DefaultLdapConfigurationServiceTest.java    | 19 +++++-
 9 files changed, 144 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigKeys.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigKeys.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigKeys.java
new file mode 100644
index 0000000..b7b41a3
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigKeys.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.ldap.domain;
+
+/**
+ * Constants representing supported LDAP related property names
+ * // todo extend this with validation information, description, defaults maybe
+ */
+public enum AmbariLdapConfigKeys {
+
+  LDAP_ENABLED("ambari.ldap.authentication.enabled"),
+  SERVER_HOST("ambari.ldap.connectivity.server.host"),
+  SERVER_PORT("ambari.ldap.connectivity.server.port"),
+  USE_SSL("ambari.ldap.connectivity.use_ssl"),
+
+  TRUST_STORE("ambari.ldap.connectivity.trust_store"),
+  TRUST_STORE_TYPE("ambari.ldap.connectivity.trust_store.type"),
+  TRUST_STORE_PATH("ambari.ldap.connectivity.trust_store.path"),
+  TRUST_STORE_PASSWORD("ambari.ldap.connectivity.trust_store.password"),
+  ANONYMOUS_BIND("ambari.ldap.connectivity.anonymous_bind"),
+
+  BIND_DN("ambari.ldap.connectivity.bind_dn"),
+  BIND_PASSWORD("ambari.ldap.connectivity.bind_password"),
+
+  ATTR_DETECTION("ambari.ldap.attributes.detection"), // manual | auto
+
+  DN_ATTRIBUTE("ambari.ldap.attributes.dn_attr"),
+
+  USER_OBJECT_CLASS("ambari.ldap.attributes.user.object_class"),
+  USER_NAME_ATTRIBUTE("ambari.ldap.attributes.user.name_attr"),
+  USER_GROUP_MEMBER_ATTRIBUTE("ambari.ldap.attributes.user.group_member_attr"),
+  USER_SEARCH_BASE("ambari.ldap.attributes.user.search_base"),
+
+  GROUP_OBJECT_CLASS("ambari.ldap.attributes.group.object_class"),
+  GROUP_NAME_ATTRIBUTE("ambari.ldap.attributes.group.name_attr"),
+  GROUP_MEMBER_ATTRIBUTE("ambari.ldap.attributes.group.member_attr"),
+  GROUP_SEARCH_BASE("ambari.ldap.attributes.group.search_base"),
+
+  USER_SEARCH_FILTER("ambari.ldap.advanced.user_search_filter"),
+  
USER_MEMBER_REPLACE_PATTERN("ambari.ldap.advanced.user_member_replace_pattern"),
+  USER_MEMBER_FILTER("ambari.ldap.advanced.user_member_filter"),
+
+  GROUP_SEARCH_FILTER("ambari.ldap.advanced.group_search_filter"),
+  
GROUP_MEMBER_REPLACE_PATTERN("ambari.ldap.advanced.group_member_replace_pattern"),
+  GROUP_MEMBER_FILTER("ambari.ldap.advanced.group_member_filter"),
+
+  FORCE_LOWERCASE_USERNAMES("ambari.ldap.advanced.force_lowercase_usernames"),
+  REFERRAL_HANDLING("ambari.ldap.advanced.referrals"), // folow
+  PAGINATION_ENABLED("ambari.ldap.advanced.pagination_enabled"); // true | 
false
+
+  private String propertyName;
+
+  AmbariLdapConfigKeys(String propName) {
+    this.propertyName = propName;
+  }
+
+  public String key() {
+    return this.propertyName;
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
index 072393a..d071ebe 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
@@ -18,9 +18,7 @@ package org.apache.ambari.server.ldap.domain;
 import java.util.Map;
 
 import javax.inject.Inject;
-import javax.inject.Singleton;
 
-import org.apache.ambari.server.ldap.service.AmbariLdapConfigKeys;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -29,7 +27,6 @@ import com.google.inject.assistedinject.Assisted;
 /**
  * This class is an immutable representation of all the LDAP related 
configurationMap entries.
  */
-@Singleton
 public class AmbariLdapConfiguration {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(AmbariLdapConfiguration.class);

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/LdapConfigurationFactory.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/LdapConfigurationFactory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/LdapConfigurationFactory.java
index f9a74da..bf8f825 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/LdapConfigurationFactory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/LdapConfigurationFactory.java
@@ -18,7 +18,7 @@ import java.util.Map;
 
 /**
  * Factory interface for AmbariLdapConfiguration instances.
- * It's registered as a factory in the GUICE context ( so no implementations 
required)
+ * It's registered as a factory in the GUICE context (so no implementations 
required)
  *
  * To be extended with other factory methods upon needs.
  */

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigKeys.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigKeys.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigKeys.java
deleted file mode 100644
index 9cf4e56..0000000
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigKeys.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ambari.server.ldap.service;
-
-/**
- * Constants representing supported LDAP related property names
- * // todo extend this with validation information, description, defaults maybe
- */
-public enum AmbariLdapConfigKeys {
-
-  LDAP_ENABLED("ambari.ldap.authentication.enabled"),
-  SERVER_HOST("ambari.ldap.connectivity.server.host"),
-  SERVER_PORT("ambari.ldap.connectivity.server.port"),
-  USE_SSL("ambari.ldap.connectivity.use_ssl"),
-
-  TRUST_STORE("ambari.ldap.connectivity.trust_store"),
-  TRUST_STORE_TYPE("ambari.ldap.connectivity.trust_store.type"),
-  TRUST_STORE_PATH("ambari.ldap.connectivity.trust_store.path"),
-  TRUST_STORE_PASSWORD("ambari.ldap.connectivity.trust_store.password"),
-  ANONYMOUS_BIND("ambari.ldap.connectivity.anonymous_bind"),
-
-  BIND_DN("ambari.ldap.connectivity.bind_dn"),
-  BIND_PASSWORD("ambari.ldap.connectivity.bind_password"),
-
-  ATTR_DETECTION("ambari.ldap.attributes.detection"), // manual | auto
-
-  DN_ATTRIBUTE("ambari.ldap.attributes.dn_attr"),
-
-  USER_OBJECT_CLASS("ambari.ldap.attributes.user.object_class"),
-  USER_NAME_ATTRIBUTE("ambari.ldap.attributes.user.name_attr"),
-  USER_GROUP_MEMBER_ATTRIBUTE("ambari.ldap.attributes.user.group_member_attr"),
-  USER_SEARCH_BASE("ambari.ldap.attributes.user.search_base"),
-
-  GROUP_OBJECT_CLASS("ambari.ldap.attributes.group.object_class"),
-  GROUP_NAME_ATTRIBUTE("ambari.ldap.attributes.group.name_attr"),
-  GROUP_MEMBER_ATTRIBUTE("ambari.ldap.attributes.group.member_attr"),
-  GROUP_SEARCH_BASE("ambari.ldap.attributes.group.search_base"),
-
-  USER_SEARCH_FILTER("ambari.ldap.advanced.user_search_filter"),
-  
USER_MEMBER_REPLACE_PATTERN("ambari.ldap.advanced.user_member_replace_pattern"),
-  USER_MEMBER_FILTER("ambari.ldap.advanced.user_member_filter"),
-
-  GROUP_SEARCH_FILTER("ambari.ldap.advanced.group_search_filter"),
-  
GROUP_MEMBER_REPLACE_PATTERN("ambari.ldap.advanced.group_member_replace_pattern"),
-  GROUP_MEMBER_FILTER("ambari.ldap.advanced.group_member_filter"),
-
-  FORCE_LOWERCASE_USERNAMES("ambari.ldap.advanced.force_lowercase_usernames"),
-  REFERRAL_HANDLING("ambari.ldap.advanced.referrals"), // folow
-  PAGINATION_ENABLED("ambari.ldap.advanced.pagination_enabled"); // true | 
false
-
-  private String propertyName;
-
-  AmbariLdapConfigKeys(String propName) {
-    this.propertyName = propName;
-  }
-
-  public String key() {
-    return this.propertyName;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionService.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionService.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionService.java
index ed24015..cddb952 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionService.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionService.java
@@ -17,8 +17,8 @@ package org.apache.ambari.server.ldap.service.ads;
 import javax.inject.Inject;
 import javax.inject.Singleton;
 
+import org.apache.ambari.server.ldap.domain.AmbariLdapConfigKeys;
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfiguration;
-import org.apache.ambari.server.ldap.service.AmbariLdapConfigKeys;
 import org.apache.ambari.server.ldap.service.AmbariLdapException;
 import org.apache.ambari.server.ldap.service.LdapAttributeDetectionService;
 import 
org.apache.ambari.server.ldap.service.ads.detectors.GroupMemberAttrDetector;

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationTest.java
new file mode 100644
index 0000000..0d02a0e
--- /dev/null
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationTest.java
@@ -0,0 +1,19 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.ldap.domain;
+
+public class AmbariLdapConfigurationTest {
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/TestAmbariLdapConfigurationFactory.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/TestAmbariLdapConfigurationFactory.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/TestAmbariLdapConfigurationFactory.java
new file mode 100644
index 0000000..ec86568
--- /dev/null
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/domain/TestAmbariLdapConfigurationFactory.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.ldap.domain;
+
+
+import java.util.Map;
+
+/**
+ * Implementation used for testing purposes only!
+ */
+public class TestAmbariLdapConfigurationFactory implements 
LdapConfigurationFactory {
+
+  @Override
+  public AmbariLdapConfiguration createLdapConfiguration(Map<String, Object> 
configuration) {
+    return new AmbariLdapConfiguration(configuration);
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionServiceTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionServiceTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionServiceTest.java
index 2920588..878d1f0 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionServiceTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapAttributeDetectionServiceTest.java
@@ -17,8 +17,9 @@ package org.apache.ambari.server.ldap.service.ads;
 
 import java.util.Map;
 
+import org.apache.ambari.server.ldap.domain.AmbariLdapConfigKeys;
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfiguration;
-import org.apache.ambari.server.ldap.service.AmbariLdapConfigKeys;
+import org.apache.ambari.server.ldap.domain.TestAmbariLdapConfigurationFactory;
 import org.apache.ambari.server.ldap.service.LdapConnectionService;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
 import org.apache.directory.ldap.client.api.LdapConnection;
@@ -43,6 +44,8 @@ public class DefaultLdapAttributeDetectionServiceTest {
   public EasyMockRule mocks = new EasyMockRule(this);
 
   private AmbariLdapConfiguration testLdapConfiguration;
+  private TestAmbariLdapConfigurationFactory ldapConfigurationFactory = new 
TestAmbariLdapConfigurationFactory();
+
   private LdapConnection connection;
 
   @TestSubject
@@ -53,7 +56,7 @@ public class DefaultLdapAttributeDetectionServiceTest {
 
     Map<String, Object> initialProps = Maps.newHashMap();
     initialProps.put(AmbariLdapConfigKeys.BIND_DN.key(), "");
-    testLdapConfiguration = new AmbariLdapConfiguration(initialProps);
+    testLdapConfiguration = 
ldapConfigurationFactory.createLdapConfiguration(initialProps);
   }
 
   @Test
@@ -74,7 +77,7 @@ public class DefaultLdapAttributeDetectionServiceTest {
   @Test
   public void functionalTest() throws Exception {
     // GIVEN
-    AmbariLdapConfiguration ambariLdapConfiguration = new 
AmbariLdapConfiguration(getTestPropertiesMap());
+    AmbariLdapConfiguration ambariLdapConfiguration = 
ldapConfigurationFactory.createLdapConfiguration(getTestPropertiesMap());
     LdapConnectionService connectionService = new 
DefaultLdapConnectionService();
     LdapConnection ldapConnection = 
connectionService.createLdapConnection(ambariLdapConfiguration);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/307f6259/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConfigurationServiceTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConfigurationServiceTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConfigurationServiceTest.java
index 449d003..2844054 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConfigurationServiceTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConfigurationServiceTest.java
@@ -18,8 +18,9 @@ import static org.junit.Assert.assertNotNull;
 
 import java.util.Map;
 
+import org.apache.ambari.server.ldap.domain.AmbariLdapConfigKeys;
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfiguration;
-import org.apache.ambari.server.ldap.service.AmbariLdapConfigKeys;
+import org.apache.ambari.server.ldap.domain.TestAmbariLdapConfigurationFactory;
 import org.apache.ambari.server.ldap.service.LdapConfigurationService;
 import org.apache.ambari.server.ldap.service.LdapConnectionService;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -40,6 +41,8 @@ public class DefaultLdapConfigurationServiceTest {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(DefaultLdapConfigurationService.class);
   private static final String TEST_USER = "einstein";
 
+  private TestAmbariLdapConfigurationFactory ldapConfigurationFactory = new 
TestAmbariLdapConfigurationFactory();
+
   LdapConfigurationService ldapConfigurationService = new 
DefaultLdapConfigurationService();
 
 
@@ -85,7 +88,7 @@ public class DefaultLdapConfigurationServiceTest {
     ldapPropsMap.put(AmbariLdapConfigKeys.USER_SEARCH_BASE.key(), 
"dc=example,dc=com");
 
 
-    AmbariLdapConfiguration ambariLdapConfiguration = new 
AmbariLdapConfiguration(ldapPropsMap);
+    AmbariLdapConfiguration ambariLdapConfiguration = 
ldapConfigurationFactory.createLdapConfiguration(ldapPropsMap);
     LdapConnectionService connectionService = new 
DefaultLdapConnectionService();
     LdapConnection ldapConnection = 
connectionService.createLdapConnection(ambariLdapConfiguration);
 
@@ -107,10 +110,20 @@ public class DefaultLdapConfigurationServiceTest {
     ldapPropsMap.put(AmbariLdapConfigKeys.USER_SEARCH_BASE.key(), 
"dc=example,dc=com");
 
 
-    AmbariLdapConfiguration ambariLdapConfiguration = new 
AmbariLdapConfiguration(ldapPropsMap);
+    AmbariLdapConfiguration ambariLdapConfiguration = 
ldapConfigurationFactory.createLdapConfiguration(ldapPropsMap);
     LdapConnectionService connectionService = new 
DefaultLdapConnectionService();
     LdapConnection ldapConnection = 
connectionService.createLdapConnection(ambariLdapConfiguration);
 
     ldapConfigurationService.checkGroupAttributes(ldapConnection, 
"uid=einstein,dc=example,dc=com", ambariLdapConfiguration);
   }
+
+  @Test
+  public void testListSupportedProperties(){
+    StringBuilder sb = new StringBuilder().append(System.lineSeparator());
+    for (AmbariLdapConfigKeys configKey : AmbariLdapConfigKeys.values()) {
+      sb.append(configKey.key()).append(System.lineSeparator());
+    }
+    LOGGER.info(sb.toString());
+
+  }
 }
\ No newline at end of file

Reply via email to