Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 432ebb2b9 -> b2541ddb5


AMBARI-19427: Ambari-server - Annotate PASSWORD properties with an attribute to 
indicate that they are credential store aware properties


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

Branch: refs/heads/branch-2.5
Commit: b2541ddb5441938fe9e2ce766559c4a92fd2222b
Parents: 432ebb2
Author: Nahappan Somasundaram <[email protected]>
Authored: Mon Jan 9 10:35:55 2017 -0800
Committer: Nahappan Somasundaram <[email protected]>
Committed: Tue Jan 10 11:16:53 2017 -0800

----------------------------------------------------------------------
 .../AmbariManagementControllerImpl.java         |  3 +--
 .../ambari/server/state/ConfigHelper.java       |  9 +++++---
 .../server/state/ValueAttributesInfo.java       | 23 ++++++++++++++++++++
 3 files changed, 30 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b2541ddb/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index c67c603..a35d485 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -2225,8 +2225,7 @@ public class AmbariManagementControllerImpl implements 
AmbariManagementControlle
     Map<String, Map<String, String>> configCredentials;
     configCredentials = 
configCredentialsForService.get(clusterService.getName());
     if (configCredentials == null) {
-      configCredentials = configHelper.getPropertiesWithPropertyType(stackId, 
clusterService,
-              PropertyType.PASSWORD);
+      configCredentials = 
configHelper.getCredentialStoreEnabledProperties(stackId, clusterService);
       configCredentialsForService.put(clusterService.getName(), 
configCredentials);
     }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b2541ddb/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
index 5f8beaf..5ce2a90 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigHelper.java
@@ -490,22 +490,25 @@ public class ConfigHelper {
   }
 
   /**
-   * Gets a map of config types to password property names to password 
property value names.
+   * Gets a map of config types to password property names to password 
property value names,
+   * that are credential store enabled.
    *
    * @param stackId
    * @param service
-   * @param propertyType
    * @return
    * @throws AmbariException
      */
-  public Map<String, Map<String, String>> 
getPropertiesWithPropertyType(StackId stackId, Service service, PropertyType 
propertyType)
+  public Map<String, Map<String, String>> 
getCredentialStoreEnabledProperties(StackId stackId, Service service)
           throws AmbariException {
+    PropertyType propertyType = PropertyType.PASSWORD;
     StackInfo stack = ambariMetaInfo.getStack(stackId.getStackName(), 
stackId.getStackVersion());
     Map<String, Map<String, String>> result = new HashMap<>();
     Map<String, String> passwordProperties;
     Set<PropertyInfo> serviceProperties = 
ambariMetaInfo.getServiceProperties(stack.getName(), stack.getVersion(), 
service.getName());
     for (PropertyInfo serviceProperty : serviceProperties) {
       if (serviceProperty.getPropertyTypes().contains(propertyType)) {
+        if (!serviceProperty.getPropertyValueAttributes().isKeyStore())
+          continue;
         String stackPropertyConfigType = 
fileNameToConfigType(serviceProperty.getFilename());
         passwordProperties = result.get(stackPropertyConfigType);
         if (passwordProperties == null) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b2541ddb/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java
index 5ece0ec..30a1533 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/ValueAttributesInfo.java
@@ -86,6 +86,9 @@ public class ValueAttributesInfo {
   @JsonProperty("property-file-type")
   private String propertyFileType;
 
+  @XmlElement(name = "keystore")
+  private boolean keyStore;
+
   public ValueAttributesInfo() {
 
   }
@@ -250,6 +253,26 @@ public class ValueAttributesInfo {
     this.copy = copy;
   }
 
+  /**
+   * Get the keystore element, indicating whether this
+   * password property is to be encrypted in a keystore
+   * when credential store use is enabled
+   *
+   * @return "true", "false"
+   */
+  public boolean isKeyStore() {
+    return keyStore;
+  }
+
+  /**
+   * Set the keystore element.
+   *
+   * @param keyStore - "true", "false"
+   */
+  public void setKeyStore(boolean keyStore) {
+    this.keyStore = keyStore;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;

Reply via email to