ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [43/46] ambari git commit: AMBARI-21307 Added unit tests, fixed logging, typos and code issues
Date Thu, 19 Oct 2017 12:45:17 GMT
AMBARI-21307 Added unit tests, fixed logging, typos and code issues


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

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: e3676a77996c5f4c93d130e2984d78b6e383f091
Parents: 468fdc3
Author: lpuskas <lpuskas@apache.org>
Authored: Tue Oct 17 11:33:52 2017 +0200
Committer: lpuskas <lpuskas@apache.org>
Committed: Thu Oct 19 14:42:03 2017 +0200

----------------------------------------------------------------------
 .../DefaultLdapAttributeDetectionService.java   | 58 +++++++++++---------
 .../ads/DefaultLdapConnectionConfigService.java |  5 +-
 .../ads/detectors/AttributeDetectorFactory.java | 26 +++++++++
 .../ads/detectors/ChainedAttributeDetector.java |  7 +++
 .../ads/detectors/GroupMemberAttrDetector.java  |  6 +-
 .../ads/detectors/GroupNameAttrDetector.java    |  4 +-
 .../ads/detectors/GroupObjectClassDetector.java |  4 +-
 .../OccurrenceAndWeightBasedDetector.java       | 42 ++++++++++++--
 .../detectors/UserGroupMemberAttrDetector.java  |  4 +-
 .../ads/detectors/UserNameAttrDetector.java     |  6 +-
 .../ads/detectors/UserObjectClassDetector.java  |  6 +-
 .../server/ldap/LdapModuleFunctionalTest.java   | 10 +---
 12 files changed, 122 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/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 ea6e278..25abce7 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
@@ -37,10 +37,18 @@ import org.apache.directory.ldap.client.template.LdapConnectionTemplate;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Service implementation that performs user and group attribute detection based on a sample
set of entries returned by
+ * an ldap search operation. A accuracy of detected values may depend on the size of the
sample result set
+ */
 @Singleton
 public class DefaultLdapAttributeDetectionService implements LdapAttributeDetectionService
{
 
-  private static final Logger LOGGER = LoggerFactory.getLogger(DefaultLdapAttributeDetectionService.class);
+  private static final Logger LOG = LoggerFactory.getLogger(DefaultLdapAttributeDetectionService.class);
+
+  /**
+   * The maximum size of the entry set the detection is performed on
+   */
   private static final int SAMPLE_RESULT_SIZE = 50;
 
   @Inject
@@ -49,46 +57,46 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
   @Inject
   private LdapConnectionTemplateFactory ldapConnectionTemplateFactory;
 
-
   @Inject
   public DefaultLdapAttributeDetectionService() {
   }
 
   @Override
   public AmbariLdapConfiguration detectLdapUserAttributes(AmbariLdapConfiguration ambariLdapConfiguration)
throws AmbariLdapException {
-    LOGGER.info("Detecting LDAP user attributes ...");
-    LdapConnectionTemplate ldapConnectionTemplate = ldapConnectionTemplateFactory.create(ambariLdapConfiguration);
-    AttributeDetector<Entry> userAttributDetector = attributeDetectorFactory.userAttributDetector();
+    LOG.info("Detecting LDAP user attributes ...");
 
     // perform a search using the user search base
     if (Strings.isEmpty(ambariLdapConfiguration.userSearchBase())) {
-      LOGGER.warn("No user search base provided");
+      LOG.warn("No user search base provided");
       return ambariLdapConfiguration;
     }
 
     try {
 
+      LdapConnectionTemplate ldapConnectionTemplate = ldapConnectionTemplateFactory.create(ambariLdapConfiguration);
+      AttributeDetector<Entry> userAttributeDetector = attributeDetectorFactory.userAttributDetector();
+
       SearchRequest searchRequest = assembleUserSearchRequest(ldapConnectionTemplate, ambariLdapConfiguration);
 
       // do the search
       List<Entry> entries = ldapConnectionTemplate.search(searchRequest, getEntryMapper());
 
       for (Entry entry : entries) {
-        LOGGER.info("Processing sample entry with dn: [{}]", entry.getDn());
-        userAttributDetector.collect(entry);
+        LOG.info("Collecting user attribute information from the sample entry with dn: [{}]",
entry.getDn());
+        userAttributeDetector.collect(entry);
       }
 
       // select attributes based on the collected information
-      Map<String, String> detectedUserAttributes = userAttributDetector.detect();
+      Map<String, String> detectedUserAttributes = userAttributeDetector.detect();
 
       // setting the attributes into the configuration
       setDetectedAttributes(ambariLdapConfiguration, detectedUserAttributes);
 
-      LOGGER.info("Decorated ambari ldap config : [{}]", ambariLdapConfiguration);
+      LOG.info("Decorated ambari ldap config : [{}]", ambariLdapConfiguration);
 
     } catch (Exception e) {
 
-      LOGGER.error("Ldap operation failed", e);
+      LOG.error("Ldap operation failed while detecting user attributes", e);
       throw new AmbariLdapException(e);
 
     }
@@ -99,19 +107,19 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
 
   @Override
   public AmbariLdapConfiguration detectLdapGroupAttributes(AmbariLdapConfiguration ambariLdapConfiguration)
throws AmbariLdapException {
-    LOGGER.info("Detecting LDAP group attributes ...");
+    LOG.info("Detecting LDAP group attributes ...");
 
     // perform a search using the user search base
     if (Strings.isEmpty(ambariLdapConfiguration.groupSearchBase())) {
-      LOGGER.warn("No group search base provided");
+      LOG.warn("No group search base provided");
       return ambariLdapConfiguration;
     }
 
-    LdapConnectionTemplate ldapConnectionTemplate = ldapConnectionTemplateFactory.create(ambariLdapConfiguration);
-    AttributeDetector<Entry> groupAttributDetector = attributeDetectorFactory.groupAttributDetector();
-
     try {
 
+      LdapConnectionTemplate ldapConnectionTemplate = ldapConnectionTemplateFactory.create(ambariLdapConfiguration);
+      AttributeDetector<Entry> groupAttributeDetector = attributeDetectorFactory.groupAttributDetector();
+
       SearchRequest searchRequest = assembleGroupSearchRequest(ldapConnectionTemplate, ambariLdapConfiguration);
 
       // do the search
@@ -119,22 +127,22 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
 
       for (Entry groupEntry : groupEntries) {
 
-        LOGGER.info("Processing sample entry with dn: [{}]", groupEntry.getDn());
-        groupAttributDetector.collect(groupEntry);
+        LOG.info("Collecting group attribute information from the sample entry with dn: [{}]",
groupEntry.getDn());
+        groupAttributeDetector.collect(groupEntry);
 
       }
 
       // select attributes based on the collected information
-      Map<String, String> detectedGroupAttributes = groupAttributDetector.detect();
+      Map<String, String> detectedGroupAttributes = groupAttributeDetector.detect();
 
       // setting the attributes into the configuration
       setDetectedAttributes(ambariLdapConfiguration, detectedGroupAttributes);
 
-      LOGGER.info("Decorated ambari ldap config : [{}]", ambariLdapConfiguration);
+      LOG.info("Decorated ambari ldap config : [{}]", ambariLdapConfiguration);
 
     } catch (Exception e) {
 
-      LOGGER.error("Ldap operation failed", e);
+      LOG.error("Ldap operation failed while detecting group attributes", e);
       throw new AmbariLdapException(e);
 
     }
@@ -143,8 +151,9 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
   }
 
   private void setDetectedAttributes(AmbariLdapConfiguration ambariLdapConfiguration, Map<String,
String> detectedAttributes) {
+
     for (Map.Entry<String, String> detecteMapEntry : detectedAttributes.entrySet())
{
-      LOGGER.info("Setting detected configuration value: [{}] - > [{}]", detecteMapEntry.getKey(),
detecteMapEntry.getValue());
+      LOG.info("Setting detected configuration value: [{}] - > [{}]", detecteMapEntry.getKey(),
detecteMapEntry.getValue());
       ambariLdapConfiguration.setValueFor(AmbariLdapConfigKeys.fromKeyStr(detecteMapEntry.getKey()),
detecteMapEntry.getValue());
     }
 
@@ -160,7 +169,7 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
       return req;
 
     } catch (Exception e) {
-      LOGGER.error("Could not assemble ldap search request", e);
+      LOG.error("Could not assemble ldap search request", e);
       throw new AmbariLdapException(e);
     }
   }
@@ -175,12 +184,11 @@ public class DefaultLdapAttributeDetectionService implements LdapAttributeDetect
       return req;
 
     } catch (Exception e) {
-      LOGGER.error("Could not assemble ldap search request", e);
+      LOG.error("Could not assemble ldap search request", e);
       throw new AmbariLdapException(e);
     }
   }
 
-
   public EntryMapper<Entry> getEntryMapper() {
     return new EntryMapper<Entry>() {
       @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConnectionConfigService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConnectionConfigService.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConnectionConfigService.java
index 9bc2daf..9afcf51 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConnectionConfigService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/DefaultLdapConnectionConfigService.java
@@ -53,20 +53,17 @@ public class DefaultLdapConnectionConfigService implements LdapConnectionConfigS
     config.setCredentials(ambariLdapConfiguration.bindPassword());
     config.setUseSsl(ambariLdapConfiguration.useSSL());
 
-    // todo implement proper validation logic here: identify optional/mandatory settings
-    // todo suggest proper naming
     if ("custom".equals(ambariLdapConfiguration.trustStore())) {
       LOG.info("Using custom trust manager configuration");
       config.setTrustManagers(trustManagers(ambariLdapConfiguration));
     }
 
-
     return config;
   }
 
 
   /**
-   * Configure the trustmanagers to use the custom keystore.
+   * Configure the trust managers to use the custom keystore.
    *
    * @param ambariLdapConfiguration congiguration instance holding current values
    * @return the array of trust managers

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/AttributeDetectorFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/AttributeDetectorFactory.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/AttributeDetectorFactory.java
index 08e3625..8155461 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/AttributeDetectorFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/AttributeDetectorFactory.java
@@ -21,30 +21,56 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 
 import org.apache.ambari.server.ldap.service.AttributeDetector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+/**
+ * Factory for attribute detector chains.
+ */
 @Singleton
 public class AttributeDetectorFactory {
 
+  private static final Logger LOG = LoggerFactory.getLogger(AttributeDetectorFactory.class);
   private static final String USER_ATTRIBUTES_DETECTORS = "UserAttributesDetectors";
   private static final String GROUP_ATTRIBUTES_DETECTORS = "GroupAttributesDetectors";
 
 
+  /**
+   * The set of user attribute detectors, configured by GUICE (check the relevant guice module
implementation)
+   */
   @Inject
   @Named(USER_ATTRIBUTES_DETECTORS)
   private Set<AttributeDetector> userAttributeDetectors;
 
+  /**
+   * The set of group attribute detectors, configured by GUICE (check the relevant guice
module implementation)
+   */
   @Inject
   @Named(GROUP_ATTRIBUTES_DETECTORS)
   Set<AttributeDetector> groupAttributeDetectors;
 
+  @Inject
   public AttributeDetectorFactory() {
   }
 
+  /**
+   * Creates a chained attribute detector instance with user attribute detectors
+   *
+   * @return the constructed ChainedAttributeDetector instance
+   */
   public ChainedAttributeDetector userAttributDetector() {
+    LOG.info("Creating instance with user attribute detectors: [{}]", userAttributDetector());
     return new ChainedAttributeDetector(userAttributeDetectors);
   }
 
+  /**
+   * Creates a chained attribute detector instance with user attribute detectors
+   *
+   * @return the constructed ChainedAttributeDetector instance
+   */
+
   public ChainedAttributeDetector groupAttributDetector() {
+    LOG.info("Creating instance with group attribute detectors: [{}]", groupAttributDetector());
     return new ChainedAttributeDetector(groupAttributeDetectors);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/ChainedAttributeDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/ChainedAttributeDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/ChainedAttributeDetector.java
index ad70d0b..1fb7a4c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/ChainedAttributeDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/ChainedAttributeDetector.java
@@ -27,11 +27,18 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 
+/**
+ * Attribute detector implementation that performs the attribute detection on a configured
set of attribute detectors.
+ * (it implements the composite design pattern)
+ */
 @Singleton
 public class ChainedAttributeDetector implements AttributeDetector<Entry> {
 
   private static final Logger LOG = LoggerFactory.getLogger(ChainedAttributeDetector.class);
 
+  /**
+   * The set of detectors this instance delegates to
+   */
   private Set<AttributeDetector> detectors;
 
   @Inject

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetector.java
index 72e753b..ffe4027 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupMemberAttrDetector.java
@@ -54,12 +54,12 @@ public class GroupMemberAttrDetector extends OccurrenceAndWeightBasedDetector
{
   }
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    return entry.containsAttribute(value);
+  protected boolean applies(Entry entry, String attribute) {
+    return entry.containsAttribute(attribute);
   }
 
   @Override
   public String detectedProperty() {
-    return AmbariLdapConfigKeys.USER_GROUP_MEMBER_ATTRIBUTE.key();
+    return AmbariLdapConfigKeys.GROUP_MEMBER_ATTRIBUTE.key();
   }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupNameAttrDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupNameAttrDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupNameAttrDetector.java
index ca54dad..0315ef2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupNameAttrDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupNameAttrDetector.java
@@ -59,8 +59,8 @@ public class GroupNameAttrDetector extends OccurrenceAndWeightBasedDetector
{
 
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    return entry.containsAttribute(value);
+  protected boolean applies(Entry entry, String attribute) {
+    return entry.containsAttribute(attribute);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupObjectClassDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupObjectClassDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupObjectClassDetector.java
index 8f342f1..b681134 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupObjectClassDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/GroupObjectClassDetector.java
@@ -62,8 +62,8 @@ public class GroupObjectClassDetector extends OccurrenceAndWeightBasedDetector
{
   }
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    return entry.hasObjectClass(value);
+  protected boolean applies(Entry entry, String attribute) {
+    return entry.hasObjectClass(attribute);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java
index cb78d25..6ce7ca6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/OccurrenceAndWeightBasedDetector.java
@@ -23,15 +23,27 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Maps;
 
+/**
+ * Attribute detector implementation that detects attributes considering their count of occurrence
in a sample set of entries.
+ * When multiple values are checked these values can be assigned a weight, that represents
it's importance.
+ */
 public abstract class OccurrenceAndWeightBasedDetector implements AttributeDetector<Entry>
{
 
   private static final Logger LOGGER = LoggerFactory.getLogger(OccurrenceAndWeightBasedDetector.class);
 
-  private Map<String, Integer> occurranceMap = Maps.newHashMap();
+  /**
+   * A map in which the keys are the attributes that are checked in an entry and the values
are the number the key occurs
+   * in the sample entry set.
+   */
+  private Map<String, Integer> occurrenceMap = Maps.newHashMap();
+
+  /**
+   * A map in which the keys are the attributes that are checked in an entry and the values
are the weight of the attribute.
+   */
   private Map<String, Integer> weightsMap = Maps.newHashMap();
 
   protected Map<String, Integer> occurrenceMap() {
-    return occurranceMap;
+    return occurrenceMap;
   }
 
   protected Map<String, Integer> weightsMap() {
@@ -39,10 +51,27 @@ public abstract class OccurrenceAndWeightBasedDetector implements AttributeDetec
   }
 
 
-  protected abstract boolean applies(Entry entry, String value);
-
+  /**
+   * Checks whether the provided atribute is present in the entry.s
+   *
+   * @param entry     the entry being procesed
+   * @param attribute the attribute being detected
+   * @return true if the attribute is present, false otherwise
+   */
+  protected abstract boolean applies(Entry entry, String attribute);
+
+  /**
+   * The configuration key being detected.
+   *
+   * @return the key as a string
+   */
   public abstract String detectedProperty();
 
+  /**
+   * Calculates the attribute value based on the two maps.
+   *
+   * @return a map with a single element, the key is the configuration key, the value is
the detected attribute value
+   */
   @Override
   public Map<String, String> detect() {
     LOGGER.info("Calculating the most probable attribute/value ...");
@@ -82,6 +111,11 @@ public abstract class OccurrenceAndWeightBasedDetector implements AttributeDetec
   }
 
 
+  /**
+   * Collects the information about the attribute to be detected from the provided entry.
+   *
+   * @param entry a result entry returned by a search operation
+   */
   @Override
   public void collect(Entry entry) {
     LOGGER.info("Collecting ldap attributes/values form entry with dn: [{}]", entry.getDn());

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserGroupMemberAttrDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserGroupMemberAttrDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserGroupMemberAttrDetector.java
index 63ad8ba..b34a2b2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserGroupMemberAttrDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserGroupMemberAttrDetector.java
@@ -53,8 +53,8 @@ public class UserGroupMemberAttrDetector extends OccurrenceAndWeightBasedDetecto
   }
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    return entry.containsAttribute(value);
+  protected boolean applies(Entry entry, String attribute) {
+    return entry.containsAttribute(attribute);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserNameAttrDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserNameAttrDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserNameAttrDetector.java
index 8f46d72..dec4459 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserNameAttrDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserNameAttrDetector.java
@@ -58,9 +58,9 @@ public class UserNameAttrDetector extends OccurrenceAndWeightBasedDetector
{
   }
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    LOGGER.info("Checking for attribute  [{}] in entry [{}]", value, entry.getDn());
-    return entry.containsAttribute(value);
+  protected boolean applies(Entry entry, String attribute) {
+    LOGGER.info("Checking for attribute  [{}] in entry [{}]", attribute, entry.getDn());
+    return entry.containsAttribute(attribute);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserObjectClassDetector.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserObjectClassDetector.java
b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserObjectClassDetector.java
index 902dff9..53aad8b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserObjectClassDetector.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/ads/detectors/UserObjectClassDetector.java
@@ -57,9 +57,9 @@ public class UserObjectClassDetector extends OccurrenceAndWeightBasedDetector
{
   }
 
   @Override
-  protected boolean applies(Entry entry, String value) {
-    LOGGER.info("Checking for object class [{}] in entry [{}]", value, entry.getDn());
-    return entry.hasObjectClass(value);
+  protected boolean applies(Entry entry, String attribute) {
+    LOGGER.info("Checking for object class [{}] in entry [{}]", attribute, entry.getDn());
+    return entry.hasObjectClass(attribute);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/e3676a77/ambari-server/src/test/java/org/apache/ambari/server/ldap/LdapModuleFunctionalTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/ldap/LdapModuleFunctionalTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/ldap/LdapModuleFunctionalTest.java
index e77f816..875ce97 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/ldap/LdapModuleFunctionalTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/ldap/LdapModuleFunctionalTest.java
@@ -15,12 +15,10 @@
 package org.apache.ambari.server.ldap;
 
 import java.util.Map;
-import java.util.Set;
 
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfigKeys;
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfiguration;
 import org.apache.ambari.server.ldap.domain.TestAmbariLdapConfigurationFactory;
-import org.apache.ambari.server.ldap.service.AttributeDetector;
 import org.apache.ambari.server.ldap.service.LdapConfigurationService;
 import org.apache.ambari.server.ldap.service.LdapFacade;
 import org.apache.ambari.server.ldap.service.ads.LdapConnectionTemplateFactory;
@@ -39,7 +37,6 @@ import org.junit.Ignore;
 import org.junit.Test;
 
 import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -180,14 +177,11 @@ public class LdapModuleFunctionalTest {
   public void testShouldDetectorsBeBound() throws Exception {
     // GIVEN
 
-    Set<AttributeDetector> adSet = Sets.newHashSet();
-//    ChainedAttributeDetector ad = injector.getInstance(ChainedAttributeDetector.class);
-
-    AttributeDetectorFactory f = injector.getInstance(AttributeDetectorFactory.class);
     // WHEN
-    Assert.assertNotNull(f);
+    AttributeDetectorFactory f = injector.getInstance(AttributeDetectorFactory.class);
 
     // THEN
+    Assert.assertNotNull(f);
 
   }
 }
\ No newline at end of file


Mime
View raw message