Repository: ambari Updated Branches: refs/heads/trunk e10f6922e -> e65996f94
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/e65996f9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e65996f9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e65996f9 Branch: refs/heads/trunk Commit: e65996f94d5c5d7d2b398f76fda18f4e01a4bf00 Parents: e10f692 Author: Nahappan Somasundaram <nsomasunda...@hortonworks.com> Authored: Mon Jan 9 10:35:55 2017 -0800 Committer: Nahappan Somasundaram <nsomasunda...@hortonworks.com> Committed: Tue Jan 10 09:44:03 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/e65996f9/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 0affa4f..3963a19 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/e65996f9/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 7e75469..d304bb3 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/e65996f9/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 36feba9..2a499ab 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 @@ -87,6 +87,9 @@ public class ValueAttributesInfo { @JsonProperty("property-file-type") private String propertyFileType; + @XmlElement(name = "keystore") + private boolean keyStore; + public ValueAttributesInfo() { } @@ -251,6 +254,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;