This is an automated email from the ASF dual-hosted git repository.

rlevas pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new fbc59ed  [AMBARI-23354] Enable or disable SSO for servces upon setting 
sso-configuration values
fbc59ed is described below

commit fbc59ede2538f66f55d9d6914d51a84635ba7ac2
Author: Robert Levas <[email protected]>
AuthorDate: Sun Mar 25 19:11:47 2018 -0400

    [AMBARI-23354] Enable or disable SSO for servces upon setting 
sso-configuration values
---
 .../stackadvisor/commands/StackAdvisorCommand.java |  22 +-
 .../AmbariServerConfigurationKey.java              |   2 +-
 .../internal/AmbariServerConfigurationHandler.java | 123 +++++-----
 .../AmbariServerLDAPConfigurationHandler.java      |  48 ++--
 .../AmbariServerSSOConfigurationHandler.java       | 249 +++++++++++++++++++++
 .../RootServiceComponentConfigurationHandler.java  |  11 +-
 ...erviceComponentConfigurationHandlerFactory.java |  16 +-
 ...viceComponentConfigurationResourceProvider.java |  10 +-
 .../apache/ambari/server/state/ServiceImpl.java    |   6 +-
 .../commands/StackAdvisorCommandTest.java          |  12 +-
 .../AmbariServerConfigurationHandlerTest.java      | 197 ++++++++++++++--
 .../AmbariServerSSOConfigurationHandlerTest.java   | 226 +++++++++++++++++++
 ...ComponentConfigurationResourceProviderTest.java |  47 +++-
 13 files changed, 809 insertions(+), 160 deletions(-)

diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
index 48d2144..56ddcef 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommand.java
@@ -41,7 +41,6 @@ import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.api.services.BaseService;
 import org.apache.ambari.server.api.services.LocalUriInfo;
 import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
 import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorResponse;
@@ -49,7 +48,6 @@ import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRunner;
 import org.apache.ambari.server.controller.RootComponent;
 import org.apache.ambari.server.controller.RootService;
 import 
org.apache.ambari.server.controller.internal.AmbariServerConfigurationHandler;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.state.ServiceInfo;
 import org.apache.ambari.server.utils.DateUtils;
@@ -189,13 +187,8 @@ public abstract class StackAdvisorCommand<T extends 
StackAdvisorResponse> extend
    *
    * @param root The JSON document that will become service.json when passed 
to the stack advisor engine
    */
-  void populateAmbariConfiguration(ObjectNode root) throws 
NoSuchResourceException {
-    Map<String, RootServiceComponentConfiguration> config = 
ambariServerConfigurationHandler.getConfigurations(null);
-    Map<String, Map<String,String>> result = new HashMap<>();
-    for (String category : config.keySet()) {
-      result.put(category, config.get(category).getProperties());
-    }
-    root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, 
mapper.valueToTree(result));
+  void populateAmbariConfiguration(ObjectNode root) {
+    root.put(AMBARI_SERVER_CONFIGURATIONS_PROPERTY, 
mapper.valueToTree(ambariServerConfigurationHandler.getConfigurations()));
   }
 
   protected void populateAmbariServerInfo(ObjectNode root) {
@@ -210,7 +203,7 @@ public abstract class StackAdvisorCommand<T extends 
StackAdvisorResponse> extend
   private void populateConfigurations(ObjectNode root,
                                       StackAdvisorRequest request) {
     Map<String, Map<String, Map<String, String>>> configurations =
-      request.getConfigurations();
+        request.getConfigurations();
     ObjectNode configurationsNode = root.putObject(CONFIGURATIONS_PROPERTY);
     for (String siteName : configurations.keySet()) {
       ObjectNode siteNode = configurationsNode.putObject(siteName);
@@ -238,7 +231,7 @@ public abstract class StackAdvisorCommand<T extends 
StackAdvisorResponse> extend
   private void populateConfigGroups(ObjectNode root,
                                     StackAdvisorRequest request) {
     if (request.getConfigGroups() != null &&
-      !request.getConfigGroups().isEmpty()) {
+        !request.getConfigGroups().isEmpty()) {
       JsonNode configGroups = mapper.valueToTree(request.getConfigGroups());
       root.put(CONFIG_GROUPS_PROPERTY, configGroups);
     }
@@ -299,8 +292,7 @@ public abstract class StackAdvisorCommand<T extends 
StackAdvisorResponse> extend
           serviceVersion.put("advisor_name", serviceInfo.getAdvisorName());
           serviceVersion.put("advisor_path", 
serviceInfo.getAdvisorFile().getAbsolutePath());
         }
-      }
-      catch (Exception e) {
+      } catch (Exception e) {
         LOG.error("Error adding service advisor information to services.json", 
e);
       }
     }
@@ -376,11 +368,11 @@ public abstract class StackAdvisorCommand<T extends 
StackAdvisorResponse> extend
       }
     });
 
-    if(oldDirectories.length > 0) {
+    if (oldDirectories.length > 0) {
       LOG.info(String.format("Deleting old directories %s from %s", 
StringUtils.join(oldDirectories, ", "), recommendationsDir));
     }
 
-    for(String oldDirectory:oldDirectories) {
+    for (String oldDirectory : oldDirectories) {
       FileUtils.deleteQuietly(new File(recommendationsDir, oldDirectory));
     }
   }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/AmbariServerConfigurationKey.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/AmbariServerConfigurationKey.java
index 97f01bd..c585a69 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/configuration/AmbariServerConfigurationKey.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/configuration/AmbariServerConfigurationKey.java
@@ -78,7 +78,7 @@ public enum AmbariServerConfigurationKey {
    * SSO Configuration Keys
    * ******************************************************** */
   SSO_MANAGE_SERVICES(AmbariServerConfigurationCategory.SSO_CONFIGURATION, 
"ambari.sso.manage_services", PLAINTEXT, "false", "A Boolean value indicating 
whether Ambari is to manage the SSO configuration for services or not."),
-  SSO_ENABED_SERVICES(AmbariServerConfigurationCategory.SSO_CONFIGURATION, 
"ambari.sso.enabled_services", PLAINTEXT, null, "A comma-delimited list of 
services that are expected to be configured for SSO.  A \"*\" indicates all 
services.");
+  SSO_ENABLED_SERVICES(AmbariServerConfigurationCategory.SSO_CONFIGURATION, 
"ambari.sso.enabled_services", PLAINTEXT, null, "A comma-delimited list of 
services that are expected to be configured for SSO.  A \"*\" indicates all 
services.");
 
   private final AmbariServerConfigurationCategory configurationCategory;
   private final String propertyName;
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandler.java
index e84a72e..e8b68ee 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandler.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandler.java
@@ -18,25 +18,17 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory.SSO_CONFIGURATION;
-import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_ENABED_SERVICES;
-
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.Charset;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
 
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.StaticallyInject;
 import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
 import org.apache.ambari.server.configuration.Configuration;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
@@ -49,29 +41,31 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.inject.Inject;
+import com.google.inject.Singleton;
 
 
 /**
  * AmbariServerConfigurationHandler handles Ambari server specific 
configuration properties.
  */
-@StaticallyInject
+@Singleton
 public class AmbariServerConfigurationHandler extends 
RootServiceComponentConfigurationHandler {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(AmbariServerConfigurationHandler.class);
 
-  @Inject
-  static AmbariConfigurationDAO ambariConfigurationDAO;
+  private final AmbariConfigurationDAO ambariConfigurationDAO;
+  private final AmbariEventPublisher publisher;
+  private final Configuration ambariConfiguration;
 
-  @Inject
-  private static AmbariEventPublisher publisher;
+  private CredentialProvider credentialProvider;
 
   @Inject
-  private static Configuration ambariConfiguration;
-
-  private CredentialProvider credentialProvider;
+  AmbariServerConfigurationHandler(AmbariConfigurationDAO 
ambariConfigurationDAO, AmbariEventPublisher publisher, Configuration 
ambariConfiguration) {
+    this.ambariConfigurationDAO = ambariConfigurationDAO;
+    this.publisher = publisher;
+    this.ambariConfiguration = ambariConfiguration;
+  }
 
   @Override
-  public Map<String, RootServiceComponentConfiguration> 
getConfigurations(String categoryName)
-      throws NoSuchResourceException {
+  public Map<String, RootServiceComponentConfiguration> 
getComponentConfigurations(String categoryName) {
     Map<String, RootServiceComponentConfiguration> configurations = null;
 
     List<AmbariConfigurationEntity> entities = (categoryName == null)
@@ -99,30 +93,26 @@ public class AmbariServerConfigurationHandler extends 
RootServiceComponentConfig
   }
 
   @Override
-  public void removeConfiguration(String categoryName) throws 
NoSuchResourceException {
+  public void removeComponentConfiguration(String categoryName) {
     if (null == categoryName) {
       LOGGER.debug("No resource id provided in the request");
     } else {
       LOGGER.debug("Deleting Ambari configuration with id: {}", categoryName);
-      try {
-        if (ambariConfigurationDAO.removeByCategory(categoryName) > 0) {
-          publisher.publish(new AmbariConfigurationChangedEvent(categoryName));
-        }
-      } catch (IllegalStateException e) {
-        throw new NoSuchResourceException(e.getMessage());
+      if (ambariConfigurationDAO.removeByCategory(categoryName) > 0) {
+        publisher.publish(new AmbariConfigurationChangedEvent(categoryName));
       }
     }
   }
 
   @Override
-  public void updateCategory(String categoryName, Map<String, String> 
properties, boolean removePropertiesIfNotSpecified) throws AmbariException {
+  public void updateComponentCategory(String categoryName, Map<String, String> 
properties, boolean removePropertiesIfNotSpecified) throws AmbariException {
     boolean toBePublished = false;
     final Iterator<Map.Entry<String, String>> propertiesIterator = 
properties.entrySet().iterator();
     while (propertiesIterator.hasNext()) {
       Map.Entry<String, String> property = propertiesIterator.next();
       if (AmbariServerConfigurationUtils.isPassword(categoryName, 
property.getKey())) {
-        final String passwordFileOrCredentailStoreAlias = 
fetchPasswordFileNameOrCredentialStoreAlias(categoryName, property.getKey());
-        if (StringUtils.isNotBlank(passwordFileOrCredentailStoreAlias)) { //if 
blank -> this is the first time setup; we simply need to store the alias/file 
name
+        final String passwordFileOrCredentialStoreAlias = 
fetchPasswordFileNameOrCredentialStoreAlias(categoryName, property.getKey());
+        if (StringUtils.isNotBlank(passwordFileOrCredentialStoreAlias)) { //if 
blank -> this is the first time setup; we simply need to store the alias/file 
name
           if (updatePasswordIfNeeded(categoryName, property.getKey(), 
property.getValue())) {
             toBePublished = true;
           }
@@ -141,6 +131,48 @@ public class AmbariServerConfigurationHandler extends 
RootServiceComponentConfig
     }
   }
 
+  @Override
+  public OperationResult performOperation(String categoryName, Map<String, 
String> properties,
+                                          boolean mergeExistingProperties, 
String operation,
+                                          Map<String, Object> 
operationParameters) throws SystemException {
+    throw new SystemException(String.format("The requested operation is not 
supported for this category: %s", categoryName));
+  }
+
+  public Map<String, Map<String, String>> getConfigurations() {
+    Map<String, Map<String, String>> configurations = new HashMap<>();
+    List<AmbariConfigurationEntity> entities = 
ambariConfigurationDAO.findAll();
+
+    if (entities != null) {
+      for (AmbariConfigurationEntity entity : entities) {
+        String category = entity.getCategoryName();
+        Map<String, String> configuration = 
configurations.computeIfAbsent(category, k -> new HashMap<>());
+        configuration.put(entity.getPropertyName(), entity.getPropertyValue());
+      }
+    }
+
+    return configurations;
+  }
+
+  /**
+   * Get the properties associated with a configuration category
+   *
+   * @param categoryName the name of the requested category
+   * @return a map of property names to values; or null if the data does not 
exist
+   */
+  public Map<String, String> getConfigurationProperties(String categoryName) {
+    Map<String, String> properties = null;
+
+    List<AmbariConfigurationEntity> entities = 
ambariConfigurationDAO.findByCategory(categoryName);
+    if (entities != null) {
+      properties = new HashMap<>();
+      for (AmbariConfigurationEntity entity : entities) {
+        properties.put(entity.getPropertyName(), entity.getPropertyValue());
+      }
+    }
+
+    return properties;
+  }
+
   private boolean updatePasswordIfNeeded(String categoryName, String 
propertyName, String newPassword) throws AmbariException {
     if (newPassword != null) {
       final String passwordFileOrCredentailStoreAlias = 
fetchPasswordFileNameOrCredentialStoreAlias(categoryName, propertyName);
@@ -187,39 +219,4 @@ public class AmbariServerConfigurationHandler extends 
RootServiceComponentConfig
       throw new AmbariException("Error while updating password file [" + 
passwordFileName + "]", e);
     }
   }
-
-  @Override
-  public OperationResult performOperation(String categoryName, Map<String, 
String> properties,
-                                          boolean mergeExistingProperties, 
String operation,
-                                          Map<String, Object> 
operationParameters) throws SystemException {
-    throw new SystemException(String.format("The requested operation is not 
supported for this category: %s", categoryName));
-  }
-
-  public SsoEnabledServices getSsoEnabledSevices() {
-    return new SsoEnabledServices(
-      
ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName()).stream()
-      .filter(each -> 
SSO_ENABED_SERVICES.key().equalsIgnoreCase(each.getPropertyName()))
-      .findFirst()
-      .map(entity -> entity.getPropertyValue())
-      .orElse(""));
-  }
-
-  public static class SsoEnabledServices {
-    private final String commaSeparatedServices;
-
-    SsoEnabledServices(String commaSeparatedServices) {
-      this.commaSeparatedServices = commaSeparatedServices.trim();
-    }
-
-    public boolean contains(String serviceName) {
-      return "*".equals(commaSeparatedServices) || 
serviceList().contains(serviceName.toUpperCase());
-    }
-
-    private Set<String> serviceList() {
-      return Arrays.asList(commaSeparatedServices.split(",")).stream()
-        .map(String::trim)
-        .map(String::toUpperCase)
-        .collect(Collectors.toSet());
-    }
-  }
 }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerLDAPConfigurationHandler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerLDAPConfigurationHandler.java
index e615750..bfb2e75 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerLDAPConfigurationHandler.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerLDAPConfigurationHandler.java
@@ -23,30 +23,37 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.ambari.server.StaticallyInject;
-import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
 import 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.ldap.domain.AmbariLdapConfiguration;
 import org.apache.ambari.server.ldap.service.AmbariLdapException;
 import org.apache.ambari.server.ldap.service.LdapFacade;
+import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.inject.Inject;
+import com.google.inject.Singleton;
 
 /**
  * AmbariServerLDAPConfigurationHandler handles Ambari server LDAP-specific 
configuration properties.
  */
-@StaticallyInject
-class AmbariServerLDAPConfigurationHandler extends 
AmbariServerConfigurationHandler {
+@Singleton
+public class AmbariServerLDAPConfigurationHandler extends 
AmbariServerConfigurationHandler {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(AmbariServerLDAPConfigurationHandler.class);
 
+  private final LdapFacade ldapFacade;
+
   @Inject
-  private static LdapFacade ldapFacade;
-  
+  AmbariServerLDAPConfigurationHandler(LdapFacade ldapFacade, 
AmbariConfigurationDAO ambariConfigurationDAO,
+                                       AmbariEventPublisher publisher, 
Configuration ambariConfiguration) {
+    super(ambariConfigurationDAO, publisher, ambariConfiguration);
+    this.ldapFacade = ldapFacade;
+  }
+
   @Override
   public OperationResult performOperation(String categoryName, Map<String, 
String> properties,
                                           boolean mergeExistingProperties, 
String operation, Map<String, Object> operationParameters) throws 
SystemException {
@@ -55,9 +62,14 @@ class AmbariServerLDAPConfigurationHandler extends 
AmbariServerConfigurationHand
       throw new SystemException(String.format("Unexpected category name for 
Ambari server LDAP properties: %s", categoryName));
     }
 
-    OperationType operationType = OperationType.translate(operation);
-    if (operation == null) {
-      throw new SystemException("Unexpected operation for Ambari server LDAP 
properties");
+    OperationType operationType;
+    try {
+      operationType = OperationType.translate(operation);
+      if (operationType == null) {
+        throw new SystemException(String.format("The requested operation is 
not supported for this category: %s", categoryName));
+      }
+    } catch (IllegalArgumentException e) {
+      throw new SystemException(String.format("The requested operation is not 
supported for this category: %s", categoryName), e);
     }
 
     Map<String, String> ldapConfigurationProperties = new HashMap<>();
@@ -65,17 +77,9 @@ class AmbariServerLDAPConfigurationHandler extends 
AmbariServerConfigurationHand
     // If we need to merge with the properties of an existing 
ldap-configuration property set, attempt
     // to retrieve if. If one does not exist, that is ok.
     if (mergeExistingProperties) {
-      try {
-        Map<String, RootServiceComponentConfiguration> _configurations = 
getConfigurations(categoryName);
-        if (_configurations != null) {
-          RootServiceComponentConfiguration _ldapProperties = 
_configurations.get(categoryName);
-
-          if (_ldapProperties != null) {
-            
ldapConfigurationProperties.putAll(_ldapProperties.getProperties());
-          }
-        }
-      } catch (NoSuchResourceException e) {
-        // Ignore this. There is no existing ldap-configuration category and 
that is ok.
+      Map<String, String> _ldapProperties = 
getConfigurationProperties(categoryName);
+      if (_ldapProperties != null) {
+        ldapConfigurationProperties.putAll(_ldapProperties);
       }
     }
 
@@ -164,7 +168,7 @@ class AmbariServerLDAPConfigurationHandler extends 
AmbariServerConfigurationHand
         }
       }
 
-      throw new IllegalArgumentException(String.format("Invalid Ambari server 
configuration category name: %s", operation));
+      throw new IllegalArgumentException(String.format("Invalid operation for 
%s: %s", 
AmbariServerConfigurationCategory.LDAP_CONFIGURATION.getCategoryName(), 
operation));
     }
 
     public static String translate(OperationType operation) {
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandler.java
new file mode 100644
index 0000000..dece520
--- /dev/null
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandler.java
@@ -0,0 +1,249 @@
+/*
+ * 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.controller.internal;
+
+import static 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestType.SSO_CONFIGURATIONS;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory.SSO_CONFIGURATION;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_ENABLED_SERVICES;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_MANAGE_SERVICES;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.apache.ambari.server.AmbariException;
+import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
+import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorHelper;
+import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
+import 
org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * AmbariServerSSOConfigurationHandler is an {@link 
AmbariServerConfigurationHandler} implementation
+ * handing changes to the SSO configuration
+ */
+@Singleton
+public class AmbariServerSSOConfigurationHandler extends 
AmbariServerConfigurationHandler {
+  private static final Logger LOGGER = 
LoggerFactory.getLogger(AmbariServerSSOConfigurationHandler.class);
+
+  private final Clusters clusters;
+
+  private final ConfigHelper configHelper;
+
+  private final AmbariManagementController managementController;
+
+  private final StackAdvisorHelper stackAdvisorHelper;
+
+  @Inject
+  public AmbariServerSSOConfigurationHandler(Clusters clusters, ConfigHelper 
configHelper,
+                                             AmbariManagementController 
managementController,
+                                             StackAdvisorHelper 
stackAdvisorHelper,
+                                             AmbariConfigurationDAO 
ambariConfigurationDAO,
+                                             AmbariEventPublisher publisher,
+                                             Configuration 
ambariConfiguration) {
+    super(ambariConfigurationDAO, publisher, ambariConfiguration);
+    this.clusters = clusters;
+    this.configHelper = configHelper;
+    this.managementController = managementController;
+    this.stackAdvisorHelper = stackAdvisorHelper;
+  }
+
+  @Override
+  public void updateComponentCategory(String categoryName, Map<String, String> 
properties, boolean removePropertiesIfNotSpecified) throws AmbariException {
+    // Use the default implementation of #updateComponentCategory; however if 
Ambari is managing the SSO implementations
+    // always process them, even the of sso-configuration properties have not 
been changed since we do not
+    // know of the Ambari SSO data has changed in the ambari.properties file.  
For example the authentication.jwt.providerUrl
+    // or authentication.jwt.publicKey values.
+    super.updateComponentCategory(categoryName, properties, 
removePropertiesIfNotSpecified);
+
+    // Determine if Ambari is managing SSO configurations...
+    boolean manageSSOConfigurations;
+
+    Map<String, String> ssoProperties = 
getConfigurationProperties(SSO_CONFIGURATION.getCategoryName());
+    manageSSOConfigurations = (ssoProperties != null) && 
"true".equalsIgnoreCase(ssoProperties.get(SSO_MANAGE_SERVICES.key()));
+
+    if (manageSSOConfigurations) {
+      Map<String, Cluster> clusterMap = clusters.getClusters();
+
+      if (clusterMap != null) {
+        for (Cluster cluster : clusterMap.values()) {
+          try {
+            LOGGER.info(String.format("Managing the SSO configuration for the 
cluster named '%s'", cluster.getClusterName()));
+            processCluster(cluster);
+          } catch (AmbariException | StackAdvisorException e) {
+            LOGGER.warn(String.format("Failed to update the the SSO 
configuration for the cluster named '%s': ", cluster.getClusterName()), e);
+          }
+        }
+      }
+    }
+  }
+
+  /**
+   * Gets the set of services for which the user declared  Ambari to enable 
SSO integration.
+   * <p>
+   * If Ambari is not managing SSO integration configuration for services the 
set of names will be empry.
+   *
+   * @return a set of service names
+   */
+  public Set<String> getSSOEnabledServices() {
+    Map<String, String> ssoProperties = 
getConfigurationProperties(SSO_CONFIGURATION.getCategoryName());
+    boolean manageSSOConfigurations = (ssoProperties != null) && 
"true".equalsIgnoreCase(ssoProperties.get(SSO_MANAGE_SERVICES.key()));
+    String ssoEnabledServices = (manageSSOConfigurations) ? 
ssoProperties.get(SSO_ENABLED_SERVICES.key()) : null;
+
+    if (StringUtils.isEmpty(ssoEnabledServices)) {
+      return Collections.emptySet();
+    } else {
+      return Arrays.stream(ssoEnabledServices.split(","))
+          .map(String::trim)
+          .map(String::toUpperCase)
+          .collect(Collectors.toSet());
+    }
+  }
+
+  /**
+   * Build the stack advisor request, call the stack advisor, then 
automatically handle the recommendations.
+   * <p>
+   * Any recommendation coming back from the Stack/service advisor is expected 
to be only SSO-related
+   * configurations.
+   * <p>
+   * If there are no changes to the current configurations, no new 
configuration versions will be created.
+   *
+   * @param cluster the cluster to process
+   * @throws AmbariException
+   * @throws StackAdvisorException
+   */
+  private void processCluster(Cluster cluster) throws AmbariException, 
StackAdvisorException {
+    StackId stackVersion = cluster.getCurrentStackVersion();
+    List<String> hosts = 
cluster.getHosts().stream().map(Host::getHostName).collect(Collectors.toList());
+    Set<String> serviceNames = 
cluster.getServices().values().stream().map(Service::getName).collect(Collectors.toSet());
+
+    // Build the StackAdvisor request for SSO-related configurations.  it is 
expected that the stack
+    // advisor will abide by the configurations set in the Ambari 
sso-configurations to enable and
+    // disable SSO integration for the relevant services.
+    StackAdvisorRequest request = 
StackAdvisorRequest.StackAdvisorRequestBuilder.
+        forStack(stackVersion.getStackName(), stackVersion.getStackVersion())
+        .ofType(SSO_CONFIGURATIONS)
+        .forHosts(hosts)
+        .forServices(serviceNames)
+        .withComponentHostsMap(cluster.getServiceComponentHostMap(null, null))
+        .withConfigurations(calculateExistingConfigurations(cluster))
+        .build();
+
+    // Execute the stack advisor
+    RecommendationResponse response = stackAdvisorHelper.recommend(request);
+
+    // Process the recommendations and automatically apply them.  Ideally this 
is what the user wanted
+    RecommendationResponse.Recommendation recommendation = (response == null) 
? null : response.getRecommendations();
+    RecommendationResponse.Blueprint blueprint = (recommendation == null) ? 
null : recommendation.getBlueprint();
+    Map<String, RecommendationResponse.BlueprintConfigurations> configurations 
= (blueprint == null) ? null : blueprint.getConfigurations();
+
+    if (configurations != null) {
+      for (Map.Entry<String, RecommendationResponse.BlueprintConfigurations> 
configuration : configurations.entrySet()) {
+        processConfigurationType(cluster, configuration.getKey(), 
configuration.getValue());
+      }
+    }
+  }
+
+  /**
+   * Process the configuration to add, update, and remove properties as needed.
+   *
+   * @param cluster        the cluster
+   * @param configType     the configuration type
+   * @param configurations the recommended configuration values
+   * @throws AmbariException
+   */
+  private void processConfigurationType(Cluster cluster, String configType,
+                                        
RecommendationResponse.BlueprintConfigurations configurations)
+      throws AmbariException {
+
+    Map<String, String> updates = new HashMap<>();
+    Collection<String> removals = new HashSet<>();
+
+    // Gather the updates
+    Map<String, String> recommendedConfigProperties = 
configurations.getProperties();
+    if (recommendedConfigProperties != null) {
+      updates.putAll(recommendedConfigProperties);
+    }
+
+    // Determine if any properties need to be removed
+    Map<String, ValueAttributesInfo> recommendedConfigPropertyAttributes = 
configurations.getPropertyAttributes();
+    if (recommendedConfigPropertyAttributes != null) {
+      for (Map.Entry<String, ValueAttributesInfo> entry : 
recommendedConfigPropertyAttributes.entrySet()) {
+        ValueAttributesInfo info = entry.getValue();
+
+        if ((info != null) && "true".equalsIgnoreCase(info.getDelete())) {
+          updates.remove(entry.getKey());
+          removals.add(entry.getKey());
+        }
+      }
+    }
+
+    configHelper.updateConfigType(cluster, cluster.getCurrentStackVersion(), 
managementController,
+        configType, updates, removals,
+        "internal", "Ambari-managed single sign-on configurations");
+  }
+
+  /**
+   * Calculate the current configurations for all services
+   *
+   * @param cluster the cluster
+   * @return a map of services and their configurations
+   * @throws AmbariException
+   */
+  private Map<String, Map<String, Map<String, String>>> 
calculateExistingConfigurations(Cluster cluster) throws AmbariException {
+    Map<String, Map<String, String>> configurationTags = 
configHelper.getEffectiveDesiredTags(cluster, null);
+    Map<String, Map<String, String>> effectiveConfigs = 
configHelper.getEffectiveConfigProperties(cluster, configurationTags);
+
+    Map<String, Map<String, Map<String, String>>> requestConfigurations = new 
HashMap<>();
+    if (effectiveConfigs != null) {
+      for (Map.Entry<String, Map<String, String>> configuration : 
effectiveConfigs.entrySet()) {
+        Map<String, Map<String, String>> properties = new HashMap<>();
+        String configType = configuration.getKey();
+        Map<String, String> configurationProperties = configuration.getValue();
+
+        if (configurationProperties == null) {
+          configurationProperties = Collections.emptyMap();
+        }
+
+        properties.put("properties", configurationProperties);
+        requestConfigurations.put(configType, properties);
+      }
+    }
+
+    return requestConfigurations;
+  }
+}
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandler.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandler.java
index e9e4c9e..3dd4ff5 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandler.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandler.java
@@ -22,7 +22,6 @@ import java.util.Map;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.SystemException;
 
 /**
@@ -31,21 +30,19 @@ import 
org.apache.ambari.server.controller.spi.SystemException;
  */
 abstract class RootServiceComponentConfigurationHandler {
   /**
-   * Retrieve the request configurations.
+   * Retrieve the requested component configurations.
    *
    * @param categoryName the category name (or <code>null</code> for all)
    * @return a map of category names to properties (name/value pairs).
-   * @throws NoSuchResourceException if the requested data is not found
    */
-  public abstract Map<String, RootServiceComponentConfiguration> 
getConfigurations(String categoryName) throws NoSuchResourceException;
+  public abstract Map<String, RootServiceComponentConfiguration> 
getComponentConfigurations(String categoryName);
 
   /**
    * Delete the requested configuration.
    *
    * @param categoryName the category name
-   * @throws NoSuchResourceException if the requested category does not exist
    */
-  public abstract void removeConfiguration(String categoryName) throws 
NoSuchResourceException;
+  public abstract void removeComponentConfiguration(String categoryName);
 
   /**
    * Set or update a configuration category with the specified properties.
@@ -62,7 +59,7 @@ abstract class RootServiceComponentConfigurationHandler {
    *                                       <code>false</code> to update the 
set of existing properties with the specified set of properties, adding missing 
properties but not removing any properties
    * @throws AmbariException in case an error occurred while updating 
category's properties
    */
-  public abstract void updateCategory(String categoryName, Map<String, String> 
properties, boolean removePropertiesIfNotSpecified) throws AmbariException;
+  public abstract void updateComponentCategory(String categoryName, 
Map<String, String> properties, boolean removePropertiesIfNotSpecified) throws 
AmbariException;
 
   /**
    * Preform some operation on the set of data for a category.
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandlerFactory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandlerFactory.java
index ac28d9e..309785d 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandlerFactory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationHandlerFactory.java
@@ -22,6 +22,7 @@ import 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory;
 import org.apache.ambari.server.controller.RootComponent;
 import org.apache.ambari.server.controller.RootService;
 
+import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
 /**
@@ -31,6 +32,15 @@ import com.google.inject.Singleton;
 @Singleton
 public class RootServiceComponentConfigurationHandlerFactory {
 
+  @Inject
+  private AmbariServerConfigurationHandler defaultConfigurationHandler;
+
+  @Inject
+  private AmbariServerLDAPConfigurationHandler ldapConfigurationHandler;
+
+  @Inject
+  private AmbariServerSSOConfigurationHandler ssoConfigurationHandler;
+
   /**
    * Returns the internal configuration handler used to support various 
configuration storage facilities.
    *
@@ -43,9 +53,11 @@ public class RootServiceComponentConfigurationHandlerFactory 
{
     if (RootService.AMBARI.name().equals(serviceName)) {
       if (RootComponent.AMBARI_SERVER.name().equals(componentName)) {
         if 
(AmbariServerConfigurationCategory.LDAP_CONFIGURATION.getCategoryName().equals(categoryName))
 {
-          return new AmbariServerLDAPConfigurationHandler();
+          return ldapConfigurationHandler;
+        } else if 
(AmbariServerConfigurationCategory.SSO_CONFIGURATION.getCategoryName().equals(categoryName))
 {
+          return ssoConfigurationHandler;
         } else {
-          return new AmbariServerConfigurationHandler();
+          return defaultConfigurationHandler;
         }
       }
     }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
index c609f4b..11e9da8 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
@@ -173,7 +173,7 @@ public class 
RootServiceComponentConfigurationResourceProvider extends AbstractA
 
     RootServiceComponentConfigurationHandler handler = 
rootServiceComponentConfigurationHandlerFactory.getInstance(serviceName, 
componentName, categoryName);
     if (handler != null) {
-      handler.removeConfiguration(categoryName);
+      handler.removeComponentConfiguration(categoryName);
     } else {
       throw new SystemException(String.format("Configurations may not be 
updated for the %s component of the root service %s", componentName, 
serviceName));
     }
@@ -243,7 +243,7 @@ public class 
RootServiceComponentConfigurationResourceProvider extends AbstractA
         RootServiceComponentConfigurationHandler handler = 
rootServiceComponentConfigurationHandlerFactory.getInstance(requestDetails.serviceName,
 requestDetails.componentName, requestDetails.categoryName);
         if (handler != null) {
           try {
-            handler.updateCategory(requestDetails.categoryName, 
requestDetails.properties, removePropertiesIfNotSpecified);
+            handler.updateComponentCategory(requestDetails.categoryName, 
requestDetails.properties, removePropertiesIfNotSpecified);
           } catch (AmbariException | IllegalArgumentException e) {
             throw new SystemException(e.getMessage(), e.getCause());
           }
@@ -398,9 +398,11 @@ public class 
RootServiceComponentConfigurationResourceProvider extends AbstractA
     RootServiceComponentConfigurationHandler handler = 
rootServiceComponentConfigurationHandlerFactory.getInstance(serviceName, 
componentName, categoryName);
 
     if (handler != null) {
-      Map<String, RootServiceComponentConfiguration> configurations = 
handler.getConfigurations(categoryName);
+      Map<String, RootServiceComponentConfiguration> configurations = 
handler.getComponentConfigurations(categoryName);
 
-      if (configurations != null) {
+      if (configurations == null) {
+        throw new NoSuchResourceException(categoryName);
+      } else {
         for (Map.Entry<String, RootServiceComponentConfiguration> entry : 
configurations.entrySet()) {
           resources.add(toResource(serviceName, componentName, entry.getKey(), 
entry.getValue().getProperties(), entry.getValue().getPropertyTypes(), 
requestedIds));
         }
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index 03cc7c4..7c5744c 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -36,7 +36,7 @@ import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.ServiceResponse;
-import 
org.apache.ambari.server.controller.internal.AmbariServerConfigurationHandler;
+import 
org.apache.ambari.server.controller.internal.AmbariServerSSOConfigurationHandler;
 import 
org.apache.ambari.server.controller.internal.DeleteHostComponentStatusMetaData;
 import org.apache.ambari.server.events.MaintenanceModeEvent;
 import org.apache.ambari.server.events.ServiceInstalledEvent;
@@ -92,7 +92,7 @@ public class ServiceImpl implements Service {
   private ConfigHelper configHelper;
 
   @Inject
-  private AmbariServerConfigurationHandler ambariServerConfigurationHandler;
+  private AmbariServerSSOConfigurationHandler ambariServerConfigurationHandler;
 
   private final ClusterServiceDAO clusterServiceDAO;
   private final ServiceDesiredStateDAO serviceDesiredStateDAO;
@@ -692,7 +692,7 @@ public class ServiceImpl implements Service {
   }
 
   public boolean isSsoIntegrationDesired() {
-    return 
ambariServerConfigurationHandler.getSsoEnabledSevices().contains(serviceName);
+    return 
ambariServerConfigurationHandler.getSSOEnabledServices().contains(serviceName);
   }
 
   public boolean isSsoIntegrationEnabled() {
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
index 04ced0b..5d7339a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
@@ -48,7 +48,6 @@ import javax.ws.rs.core.UriInfo;
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.api.services.Request;
-import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
 import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
 import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
 import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest.StackAdvisorRequestBuilder;
@@ -287,11 +286,8 @@ public class StackAdvisorCommandTest {
 
   @Test
   public void testPopulateLdapConfig() throws Exception {
-    Map<String, RootServiceComponentConfiguration> storedConfig = new 
HashMap<String, RootServiceComponentConfiguration>() {{
-      put("ldap-configuration", new RootServiceComponentConfiguration(new 
HashMap<String, String>() {{
-        put("authentication.ldap.secondaryUrl", "localhost:333");
-      }}, null));
-    }};
+    Map<String, Map<String, String>> storedConfig = 
Collections.singletonMap("ldap-configuration",
+        Collections.singletonMap("authentication.ldap.secondaryUrl", 
"localhost:333"));
     TestStackAdvisorCommand command = new TestStackAdvisorCommand(
       temp.newFolder("recommendationDir"),
       "1w",
@@ -299,7 +295,7 @@ public class StackAdvisorCommandTest {
       0,
       mock(StackAdvisorRunner.class),
       mock(AmbariMetaInfo.class));
-    
when(ambariServerConfigurationHandler.getConfigurations(null)).thenReturn(storedConfig);
+    
when(ambariServerConfigurationHandler.getConfigurations()).thenReturn(storedConfig);
     JsonNode servicesRootNode = json("{}");
     command.populateAmbariConfiguration((ObjectNode)servicesRootNode);
     JsonNode expectedLdapConfig = 
json("{\"ambari-server-configuration\":{\"ldap-configuration\":{\"authentication.ldap.secondaryUrl\":\"localhost:333\"}}}");
@@ -315,7 +311,7 @@ public class StackAdvisorCommandTest {
       0,
       mock(StackAdvisorRunner.class),
       mock(AmbariMetaInfo.class));
-    
when(ambariServerConfigurationHandler.getConfigurations(null)).thenReturn(emptyMap());
+    
when(ambariServerConfigurationHandler.getConfigurations()).thenReturn(emptyMap());
     JsonNode servicesRootNode = json("{}");
     command.populateAmbariConfiguration((ObjectNode)servicesRootNode);
     JsonNode expectedLdapConfig = json("{\"ambari-server-configuration\":{}}");
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandlerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandlerTest.java
index 8c1130c..0a0d1a4 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandlerTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerConfigurationHandlerTest.java
@@ -20,48 +20,199 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import static java.util.Collections.singletonList;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory.LDAP_CONFIGURATION;
 import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory.SSO_CONFIGURATION;
-import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_ENABED_SERVICES;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.LDAP_ENABLED;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SERVER_HOST;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_ENABLED_SERVICES;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_MANAGE_SERVICES;
+import static org.easymock.EasyMock.anyObject;
 import static org.easymock.EasyMock.expect;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.easymock.EasyMock.expectLastCall;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.api.services.RootServiceComponentConfiguration;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
 import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
 import org.apache.ambari.server.orm.entities.AmbariConfigurationEntity;
 import org.easymock.EasyMockRunner;
 import org.easymock.EasyMockSupport;
-import org.easymock.Mock;
-import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import junit.framework.Assert;
+
 @RunWith(EasyMockRunner.class)
 public class AmbariServerConfigurationHandlerTest extends EasyMockSupport {
-  @Mock
-  private AmbariConfigurationDAO ambariConfigurationDAO;
-  private AmbariServerConfigurationHandler ambariServerConfigurationHandler;
-
-  @Before
-  public void setUp() throws Exception {
-    ambariServerConfigurationHandler = new AmbariServerConfigurationHandler();
-    AmbariServerConfigurationHandler.ambariConfigurationDAO = 
ambariConfigurationDAO;
+
+  @Test
+  public void getComponentConfigurations() {
+    List<AmbariConfigurationEntity> ssoEntities = new ArrayList<>();
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_MANAGE_SERVICES.key(), "true"));
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_ENABLED_SERVICES.key(), "AMBARI,SERVICE1"));
+
+    List<AmbariConfigurationEntity> allEntities = new ArrayList<>(ssoEntities);
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
LDAP_ENABLED.key(), "true"));
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
SERVER_HOST.key(), "host1"));
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    expect(ambariConfigurationDAO.findAll()).andReturn(allEntities).once();
+    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(ssoEntities).once();
+    expect(ambariConfigurationDAO.findByCategory("invalid 
category")).andReturn(null).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    Configuration configuration = createMock(Configuration.class);
+
+    replayAll();
+
+    AmbariServerConfigurationHandler handler = new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration);
+
+    Map<String, RootServiceComponentConfiguration> allConfigurations = 
handler.getComponentConfigurations(null);
+    Assert.assertEquals(2, allConfigurations.size());
+    
Assert.assertTrue(allConfigurations.containsKey(SSO_CONFIGURATION.getCategoryName()));
+    
Assert.assertTrue(allConfigurations.containsKey(LDAP_CONFIGURATION.getCategoryName()));
+
+    Map<String, RootServiceComponentConfiguration> ssoConfigurations = 
handler.getComponentConfigurations(SSO_CONFIGURATION.getCategoryName());
+    Assert.assertEquals(1, ssoConfigurations.size());
+    
Assert.assertTrue(ssoConfigurations.containsKey(SSO_CONFIGURATION.getCategoryName()));
+
+    Map<String, RootServiceComponentConfiguration> invalidConfigurations = 
handler.getComponentConfigurations("invalid category");
+    Assert.assertNull(invalidConfigurations);
+
+    verifyAll();
   }
 
   @Test
-  public void testCheckingIfSsoIsEnabledPerEachService() {
-    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(singletonList(ssoConfig("SERVICE1,
 SERVICE2"))).anyTimes();
+  public void removeComponentConfiguration() {
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.removeByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(1).once();
+    expect(ambariConfigurationDAO.removeByCategory("invalid 
category")).andReturn(0).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
+    expectLastCall().once();
+
+    Configuration configuration = createMock(Configuration.class);
+
     replayAll();
-    
assertTrue(ambariServerConfigurationHandler.getSsoEnabledSevices().contains("SERVICE1"));
-    
assertTrue(ambariServerConfigurationHandler.getSsoEnabledSevices().contains("SERVICE2"));
-    
assertFalse(ambariServerConfigurationHandler.getSsoEnabledSevices().contains("SERVICE3"));
+
+    AmbariServerConfigurationHandler handler = new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration);
+
+    handler.removeComponentConfiguration(SSO_CONFIGURATION.getCategoryName());
+    handler.removeComponentConfiguration("invalid category");
+
+    verifyAll();
   }
 
-  private AmbariConfigurationEntity ssoConfig(String services) {
+  @Test
+  public void updateComponentCategory() throws AmbariException {
+    Map<String, String> properties = new HashMap<>();
+    properties.put(SSO_ENABLED_SERVICES.key(), "SERVICE1");
+    properties.put(SSO_MANAGE_SERVICES.key(), "true");
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(),
 properties, true))
+        .andReturn(true).once();
+    
expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(),
 properties, false))
+        .andReturn(true).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
+    expectLastCall().times(2);
+
+    Configuration configuration = createMock(Configuration.class);
+
+    replayAll();
+
+    AmbariServerConfigurationHandler handler = new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration);
+
+    handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), 
properties, false);
+
+    handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), 
properties, true);
+
+    try {
+      handler.updateComponentCategory("invalid category", properties, true);
+      Assert.fail("Expecting IllegalArgumentException to be thrown");
+    } catch (IllegalArgumentException e) {
+      // This is expected
+    }
+
+    verifyAll();
+  }
+
+  @Test
+  public void getConfigurations() {
+    List<AmbariConfigurationEntity> ssoEntities = new ArrayList<>();
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_MANAGE_SERVICES.key(), "true"));
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_ENABLED_SERVICES.key(), "AMBARI,SERVICE1"));
+
+    List<AmbariConfigurationEntity> allEntities = new ArrayList<>(ssoEntities);
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
LDAP_ENABLED.key(), "true"));
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
SERVER_HOST.key(), "host1"));
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    expect(ambariConfigurationDAO.findAll()).andReturn(allEntities).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    Configuration configuration = createMock(Configuration.class);
+
+    replayAll();
+
+    AmbariServerConfigurationHandler handler = new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration);
+
+    Map<String, Map<String, String>> allConfigurations = 
handler.getConfigurations();
+    Assert.assertEquals(2, allConfigurations.size());
+    
Assert.assertTrue(allConfigurations.containsKey(SSO_CONFIGURATION.getCategoryName()));
+    
Assert.assertTrue(allConfigurations.containsKey(LDAP_CONFIGURATION.getCategoryName()));
+
+    verifyAll();
+  }
+
+  @Test
+  public void getConfigurationProperties() {
+    List<AmbariConfigurationEntity> ssoEntities = new ArrayList<>();
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_MANAGE_SERVICES.key(), "true"));
+    ssoEntities.add(createEntity(SSO_CONFIGURATION.getCategoryName(), 
SSO_ENABLED_SERVICES.key(), "AMBARI,SERVICE1"));
+
+    List<AmbariConfigurationEntity> allEntities = new ArrayList<>(ssoEntities);
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
LDAP_ENABLED.key(), "true"));
+    allEntities.add(createEntity(LDAP_CONFIGURATION.getCategoryName(), 
SERVER_HOST.key(), "host1"));
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(ssoEntities).once();
+    expect(ambariConfigurationDAO.findByCategory("invalid 
category")).andReturn(null).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    Configuration configuration = createMock(Configuration.class);
+
+    replayAll();
+
+    AmbariServerConfigurationHandler handler = new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration);
+
+    Map<String, String> ssoConfigurations = 
handler.getConfigurationProperties(SSO_CONFIGURATION.getCategoryName());
+    Assert.assertEquals(2, ssoConfigurations.size());
+    
Assert.assertTrue(ssoConfigurations.containsKey(SSO_ENABLED_SERVICES.key()));
+    
Assert.assertTrue(ssoConfigurations.containsKey(SSO_MANAGE_SERVICES.key()));
+
+    Map<String, String> invalidConfigurations = 
handler.getConfigurationProperties("invalid category");
+    Assert.assertNull(invalidConfigurations);
+
+    verifyAll();
+  }
+
+
+  private AmbariConfigurationEntity createEntity(String categoryName, String 
key, String value) {
     AmbariConfigurationEntity entity = new AmbariConfigurationEntity();
-    entity.setCategoryName(SSO_CONFIGURATION.getCategoryName());
-    entity.setPropertyName(SSO_ENABED_SERVICES.key());
-    entity.setPropertyValue(services);
+    entity.setCategoryName(categoryName);
+    entity.setPropertyName(key);
+    entity.setPropertyValue(value);
     return entity;
   }
 }
\ No newline at end of file
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandlerTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandlerTest.java
new file mode 100644
index 0000000..9c93cd3
--- /dev/null
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariServerSSOConfigurationHandlerTest.java
@@ -0,0 +1,226 @@
+/*
+ * 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.controller.internal;
+
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory.SSO_CONFIGURATION;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_ENABLED_SERVICES;
+import static 
org.apache.ambari.server.configuration.AmbariServerConfigurationKey.SSO_MANAGE_SERVICES;
+import static 
org.apache.ambari.server.events.AmbariEvent.AmbariEventType.AMBARI_CONFIGURATION_CHANGED;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.expectLastCall;
+import static org.easymock.EasyMock.newCapture;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ambari.server.AmbariException;
+import 
org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
+import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorHelper;
+import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
+import 
org.apache.ambari.server.api.services.stackadvisor.recommendations.RecommendationResponse;
+import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
+import org.apache.ambari.server.events.AmbariEvent;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
+import org.apache.ambari.server.orm.entities.AmbariConfigurationEntity;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ConfigHelper;
+import org.apache.ambari.server.state.Host;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.ValueAttributesInfo;
+import org.easymock.Capture;
+import org.easymock.EasyMockSupport;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class AmbariServerSSOConfigurationHandlerTest extends EasyMockSupport {
+
+  @Test
+  public void testUpdateCategoryAmbariNotManagingServices() throws 
AmbariException {
+    Map<String, String> ssoConfigurationProperties = new HashMap<>();
+    ssoConfigurationProperties.put(SSO_MANAGE_SERVICES.key(), "false");
+
+    AmbariConfigurationEntity entity = new AmbariConfigurationEntity();
+    entity.setCategoryName(SSO_CONFIGURATION.getCategoryName());
+    entity.setPropertyName(SSO_MANAGE_SERVICES.key());
+    entity.setPropertyValue("false");
+    List<AmbariConfigurationEntity> entities = 
Collections.singletonList(entity);
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(),
 Collections.singletonMap(SSO_MANAGE_SERVICES.key(), "false"), 
true)).andReturn(false).once();
+    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(entities).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    Configuration configuration = createMock(Configuration.class);
+    Clusters clusters = createMock(Clusters.class);
+    ConfigHelper configHelper = createMock(ConfigHelper.class);
+    AmbariManagementController managementController = 
createMock(AmbariManagementController.class);
+    StackAdvisorHelper stackAdvisorHelper = 
createMock(StackAdvisorHelper.class);
+
+    replayAll();
+
+    AmbariServerSSOConfigurationHandler handler = new 
AmbariServerSSOConfigurationHandler(clusters, configHelper, 
managementController, stackAdvisorHelper, ambariConfigurationDAO, publisher, 
configuration);
+    handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), 
ssoConfigurationProperties, true);
+
+    verifyAll();
+  }
+
+  @Test
+  public void testUpdateCategoryAmbariManagingServices() throws 
AmbariException, StackAdvisorException {
+    Map<String, String> ssoConfigurationProperties = new HashMap<>();
+    ssoConfigurationProperties.put(SSO_MANAGE_SERVICES.key(), "true");
+
+    AmbariConfigurationEntity entity = new AmbariConfigurationEntity();
+    entity.setCategoryName(SSO_CONFIGURATION.getCategoryName());
+    entity.setPropertyName(SSO_MANAGE_SERVICES.key());
+    entity.setPropertyValue("true");
+    List<AmbariConfigurationEntity> entities = 
Collections.singletonList(entity);
+
+    StackId stackId = new StackId("HDP-3.0");
+
+    Map<String, Set<String>> serviceComponentHostMap = 
Collections.singletonMap("ATLAS_COMPONENT", Collections.singleton("host1"));
+
+    Host host = createMock(Host.class);
+    expect(host.getHostName()).andReturn("host1").once();
+
+    Service service = createMock(Service.class);
+    expect(service.getName()).andReturn("SERVICE1").once();
+
+    Map<String, Map<String, String>> tags = Collections.emptyMap();
+    Map<String, Map<String, String>> existing_configurations = 
Collections.singletonMap("SERVICE1", 
Collections.singletonMap("service1-property1", "service1-value1"));
+
+    ValueAttributesInfo nonSSOProperty1Attributes = new ValueAttributesInfo();
+    nonSSOProperty1Attributes.setDelete("true");
+
+    RecommendationResponse.BlueprintConfigurations blueprintConfigurations = 
new RecommendationResponse.BlueprintConfigurations();
+    
blueprintConfigurations.setProperties(Collections.singletonMap("service1-sso-property1",
 "service1-sso-value1"));
+    
blueprintConfigurations.setPropertyAttributes(Collections.singletonMap("service1-nonsso-property1",
 nonSSOProperty1Attributes));
+
+    RecommendationResponse.Blueprint blueprint = new 
RecommendationResponse.Blueprint();
+    blueprint.setConfigurations(Collections.singletonMap("service-site", 
blueprintConfigurations));
+
+    RecommendationResponse.Recommendation recommendations = new 
RecommendationResponse.Recommendation();
+    recommendations.setBlueprint(blueprint);
+
+    RecommendationResponse recommendationResponse = new 
RecommendationResponse();
+    recommendationResponse.setRecommendations(recommendations);
+
+    Capture<AmbariEvent> capturedEvent = newCapture();
+    Capture<StackAdvisorRequest> capturedRequest = newCapture();
+    Capture<Map<String, String>> capturedUpdates = newCapture();
+    Capture<Collection<String>> capturedRemovals = newCapture();
+
+    Configuration configuration = createMock(Configuration.class);
+    AmbariManagementController managementController = 
createMock(AmbariManagementController.class);
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(),
 Collections.singletonMap(SSO_MANAGE_SERVICES.key(), "true"), 
true)).andReturn(true).once();
+    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(entities).once();
+
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    publisher.publish(capture(capturedEvent));
+    expectLastCall().once();
+
+    Cluster cluster = createMock(Cluster.class);
+    expect(cluster.getClusterName()).andReturn("c1").once();
+    expect(cluster.getCurrentStackVersion()).andReturn(stackId).anyTimes();
+    expect(cluster.getHosts()).andReturn(Collections.singleton(host)).once();
+    
expect(cluster.getServices()).andReturn(Collections.singletonMap("SERVICE1", 
service)).once();
+    expect(cluster.getServiceComponentHostMap(null, 
null)).andReturn(serviceComponentHostMap).once();
+
+    ConfigHelper configHelper = createMock(ConfigHelper.class);
+    expect(configHelper.getEffectiveDesiredTags(cluster, 
null)).andReturn(tags).once();
+    expect(configHelper.getEffectiveConfigProperties(cluster, 
tags)).andReturn(existing_configurations).once();
+    configHelper.updateConfigType(eq(cluster), eq(stackId), 
eq(managementController), eq("service-site"), capture(capturedUpdates), 
capture(capturedRemovals),
+        eq("internal"), eq("Ambari-managed single sign-on configurations"));
+    expectLastCall().once();
+
+    Clusters clusters = createMock(Clusters.class);
+    expect(clusters.getClusters()).andReturn(Collections.singletonMap("c1", 
cluster)).once();
+
+    StackAdvisorHelper stackAdvisorHelper = 
createMock(StackAdvisorHelper.class);
+    
expect(stackAdvisorHelper.recommend(capture(capturedRequest))).andReturn(recommendationResponse).once();
+
+    replayAll();
+
+    AmbariServerSSOConfigurationHandler handler = new 
AmbariServerSSOConfigurationHandler(clusters, configHelper, 
managementController, stackAdvisorHelper, ambariConfigurationDAO, publisher, 
configuration);
+    handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), 
ssoConfigurationProperties, true);
+
+    verifyAll();
+
+    Assert.assertTrue(capturedEvent.hasCaptured());
+    Assert.assertEquals(AMBARI_CONFIGURATION_CHANGED, 
capturedEvent.getValue().getType());
+    Assert.assertEquals(SSO_CONFIGURATION.getCategoryName(), 
((AmbariConfigurationChangedEvent) capturedEvent.getValue()).getCategoryName());
+
+    Assert.assertTrue(capturedUpdates.hasCaptured());
+    
Assert.assertTrue(capturedUpdates.getValue().containsKey("service1-sso-property1"));
+    Assert.assertEquals("service1-sso-value1", 
capturedUpdates.getValue().get("service1-sso-property1"));
+
+    Assert.assertTrue(capturedRemovals.hasCaptured());
+    
Assert.assertTrue(capturedRemovals.getValue().contains("service1-nonsso-property1"));
+
+    Assert.assertTrue(capturedRequest.hasCaptured());
+  }
+
+  @Test
+  public void testCheckingIfSSOIsEnabledPerEachService() {
+    Clusters clusters = createMock(Clusters.class);
+    ConfigHelper configHelper = createMock(ConfigHelper.class);
+    AmbariManagementController managementController = 
createMock(AmbariManagementController.class);
+    StackAdvisorHelper stackAdvisorHelper = 
createMock(StackAdvisorHelper.class);
+    AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class);
+    Configuration configuration = createMock(Configuration.class);
+
+    List<AmbariConfigurationEntity> entities = new ArrayList<>();
+    AmbariConfigurationEntity entity;
+
+    entity = new AmbariConfigurationEntity();
+    entity.setCategoryName(SSO_CONFIGURATION.getCategoryName());
+    entity.setPropertyName(SSO_MANAGE_SERVICES.key());
+    entity.setPropertyValue("true");
+    entities.add(entity);
+
+    entity = new AmbariConfigurationEntity();
+    entity.setCategoryName(SSO_CONFIGURATION.getCategoryName());
+    entity.setPropertyName(SSO_ENABLED_SERVICES.key());
+    entity.setPropertyValue("SERVICE1,SERVICE2");
+    entities.add(entity);
+
+    AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+    
expect(ambariConfigurationDAO.findByCategory(SSO_CONFIGURATION.getCategoryName())).andReturn(entities).anyTimes();
+
+    replayAll();
+
+    AmbariServerSSOConfigurationHandler handler = new 
AmbariServerSSOConfigurationHandler(clusters, configHelper, 
managementController, stackAdvisorHelper, ambariConfigurationDAO, publisher, 
configuration);
+
+    Assert.assertTrue(handler.getSSOEnabledServices().contains("SERVICE1"));
+    Assert.assertTrue(handler.getSSOEnabledServices().contains("SERVICE2"));
+    Assert.assertFalse(handler.getSSOEnabledServices().contains("SERVICE3"));
+
+    verifyAll();
+  }
+}
\ No newline at end of file
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProviderTest.java
index e3f9a7e..17ef6ca 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProviderTest.java
@@ -39,9 +39,11 @@ import java.util.TreeMap;
 import javax.persistence.EntityManager;
 
 import 
org.apache.ambari.server.api.services.RootServiceComponentConfigurationService;
+import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorHelper;
 import 
org.apache.ambari.server.configuration.AmbariServerConfigurationCategory;
 import org.apache.ambari.server.configuration.AmbariServerConfigurationKey;
 import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.RootComponent;
 import org.apache.ambari.server.controller.RootService;
 import org.apache.ambari.server.controller.predicate.AndPredicate;
@@ -53,11 +55,14 @@ import 
org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
 import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.ldap.service.LdapFacade;
 import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
 import org.apache.ambari.server.orm.entities.AmbariConfigurationEntity;
 import org.apache.ambari.server.security.TestAuthenticationFactory;
 import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.security.encryption.CredentialProvider;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ConfigHelper;
 import org.apache.ambari.server.state.stack.OsFamily;
 import org.apache.commons.io.FileUtils;
 import org.easymock.Capture;
@@ -93,6 +98,8 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
   private AmbariConfigurationDAO dao;
   private Configuration configuration;
   private AmbariEventPublisher publisher;
+  private AmbariServerLDAPConfigurationHandler 
ambariServerLDAPConfigurationHandler;
+  private AmbariServerSSOConfigurationHandler 
ambariServerSSOConfigurationHandler;
 
   @Before
   public void init() {
@@ -104,6 +111,8 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     configuration = injector.getInstance(Configuration.class);
     factory = 
injector.getInstance(RootServiceComponentConfigurationHandlerFactory.class);
     publisher = injector.getInstance(AmbariEventPublisher.class);
+    ambariServerLDAPConfigurationHandler = 
injector.getInstance(AmbariServerLDAPConfigurationHandler.class);
+    ambariServerSSOConfigurationHandler = 
injector.getInstance(AmbariServerSSOConfigurationHandler.class);
   }
 
   @After
@@ -171,7 +180,7 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
 
     Map<String, String> properties2 = new HashMap<>();
     if (opDirective == null) {
-      properties2.put(AmbariServerConfigurationKey.SSO_ENABED_SERVICES.key(), 
"true");
+      properties2.put(AmbariServerConfigurationKey.SSO_ENABLED_SERVICES.key(), 
"true");
       propertySets.add(toRequestProperties(SSO_CONFIG_CATEGORY, properties2));
     }
 
@@ -195,6 +204,9 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
       expect(dao.reconcileCategory(eq(SSO_CONFIG_CATEGORY), 
capture(capturedProperties2), eq(true)))
           .andReturn(true)
           .once();
+      expect(dao.findByCategory(eq(SSO_CONFIG_CATEGORY)))
+          .andReturn(Collections.emptyList())
+          .once();
 
 
       publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
@@ -202,11 +214,11 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     }
 
     expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), LDAP_CONFIG_CATEGORY))
-        .andReturn(new AmbariServerConfigurationHandler())
+        .andReturn(ambariServerLDAPConfigurationHandler)
         .once();
     if (opDirective == null) {
       expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), SSO_CONFIG_CATEGORY))
-          .andReturn(new AmbariServerConfigurationHandler())
+          .andReturn(ambariServerSSOConfigurationHandler)
           .once();
     }
 
@@ -272,7 +284,7 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     expectLastCall().once();
 
     expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), LDAP_CONFIG_CATEGORY))
-        .andReturn(new AmbariServerConfigurationHandler())
+        .andReturn(ambariServerLDAPConfigurationHandler)
         .once();
 
     replayAll();
@@ -319,7 +331,7 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     
expect(dao.findByCategory(LDAP_CONFIG_CATEGORY)).andReturn(createEntities(LDAP_CONFIG_CATEGORY,
 properties)).once();
 
     expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), LDAP_CONFIG_CATEGORY))
-        .andReturn(new AmbariServerLDAPConfigurationHandler())
+        .andReturn(ambariServerLDAPConfigurationHandler)
         .once();
 
     replayAll();
@@ -431,7 +443,7 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     }
 
     expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), LDAP_CONFIG_CATEGORY))
-        .andReturn(new AmbariServerConfigurationHandler())
+        .andReturn(ambariServerLDAPConfigurationHandler)
         .once();
 
     replayAll();
@@ -537,7 +549,7 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     expect(request.getProperties()).andReturn(propertySets).once();
     expect(request.getRequestInfoProperties()).andReturn(new HashMap<>());
     
expect(dao.findByCategory(LDAP_CONFIG_CATEGORY)).andReturn(createEntities(AmbariServerConfigurationCategory.LDAP_CONFIGURATION.getCategoryName(),
 expectedProperties)).times(2);
-    expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), LDAP_CONFIG_CATEGORY)).andReturn(new 
AmbariServerLDAPConfigurationHandler()).once();
+    expect(factory.getInstance(RootService.AMBARI.name(), 
RootComponent.AMBARI_SERVER.name(), 
LDAP_CONFIG_CATEGORY)).andReturn(ambariServerLDAPConfigurationHandler).once();
   }
 
   private Predicate createPredicate(String serviceName, String componentName, 
String categoryName) {
@@ -597,14 +609,25 @@ public class 
RootServiceComponentConfigurationResourceProviderTest extends EasyM
     return Guice.createInjector(new AbstractModule() {
       @Override
       protected void configure() {
+        AmbariEventPublisher publisher = 
createMock(AmbariEventPublisher.class);
+        AmbariConfigurationDAO ambariConfigurationDAO = 
createMock(AmbariConfigurationDAO.class);
+        Configuration configuration = createNiceMock(Configuration.class);
+        Clusters clusters = createNiceMock(Clusters.class);
+        ConfigHelper configHelper = createNiceMock(ConfigHelper.class);
+        AmbariManagementController managementController = 
createNiceMock(AmbariManagementController.class);
+        StackAdvisorHelper stackAdvisorHelper = 
createNiceMock(StackAdvisorHelper.class);
+        LdapFacade ldapFacade = createNiceMock(LdapFacade.class);
+
         bind(OsFamily.class).toInstance(createNiceMock(OsFamily.class));
-        
bind(Configuration.class).toInstance(createNiceMock(Configuration.class));
+        bind(Configuration.class).toInstance(configuration);
         
bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
-        
bind(AmbariConfigurationDAO.class).toInstance(createMock(AmbariConfigurationDAO.class));
-        
bind(AmbariEventPublisher.class).toInstance(createMock(AmbariEventPublisher.class));
-        
bind(RootServiceComponentConfigurationHandlerFactory.class).toInstance(createMock(RootServiceComponentConfigurationHandlerFactory.class));
+        bind(AmbariConfigurationDAO.class).toInstance(ambariConfigurationDAO);
+        bind(AmbariEventPublisher.class).toInstance(publisher);
 
-        
binder().requestStaticInjection(AmbariServerConfigurationHandler.class);
+        bind(AmbariServerConfigurationHandler.class).toInstance(new 
AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, 
configuration));
+        bind(AmbariServerSSOConfigurationHandler.class).toInstance(new 
AmbariServerSSOConfigurationHandler(clusters, configHelper, 
managementController, stackAdvisorHelper, ambariConfigurationDAO, publisher, 
configuration));
+        bind(AmbariServerLDAPConfigurationHandler.class).toInstance(new 
AmbariServerLDAPConfigurationHandler(ldapFacade, ambariConfigurationDAO, 
publisher, configuration));
+        
bind(RootServiceComponentConfigurationHandlerFactory.class).toInstance(createMock(RootServiceComponentConfigurationHandlerFactory.class));
       }
     });
   }

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to