|
|
@@ -51,7 +51,6 @@ import java.util.concurrent.TimeUnit;
|
|
|
import org.apache.ambari.annotations.Experimental;
|
|
|
import org.apache.ambari.annotations.ExperimentalFeature;
|
|
|
import org.apache.ambari.annotations.Markdown;
|
|
|
-import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.actionmanager.CommandExecutionType;
|
|
|
import org.apache.ambari.server.actionmanager.HostRoleCommand;
|
|
|
import org.apache.ambari.server.actionmanager.Stage;
|
|
|
@@ -64,7 +63,6 @@ import org.apache.ambari.server.orm.dao.HostRoleCommandStatusSummaryDTO;
|
|
|
import org.apache.ambari.server.orm.entities.StageEntity;
|
|
|
import org.apache.ambari.server.security.ClientSecurityType;
|
|
|
import org.apache.ambari.server.security.authentication.kerberos.AmbariKerberosAuthenticationProperties;
|
|
|
-import org.apache.ambari.server.security.authorization.LdapServerProperties;
|
|
|
import org.apache.ambari.server.security.authorization.UserType;
|
|
|
import org.apache.ambari.server.security.authorization.jwt.JwtAuthenticationProperties;
|
|
|
import org.apache.ambari.server.security.encryption.CertificateUtils;
|
|
|
@@ -76,7 +74,7 @@ import org.apache.ambari.server.upgrade.AbstractUpgradeCatalog;
|
|
|
import org.apache.ambari.server.utils.AmbariPath;
|
|
|
import org.apache.ambari.server.utils.DateUtils;
|
|
|
import org.apache.ambari.server.utils.HostUtils;
|
|
|
-import org.apache.ambari.server.utils.Parallel;
|
|
|
+import org.apache.ambari.server.utils.PasswordUtils;
|
|
|
import org.apache.ambari.server.utils.ShellCommandUtil;
|
|
|
import org.apache.ambari.server.utils.StageUtils;
|
|
|
import org.apache.commons.cli.CommandLine;
|
|
|
@@ -163,7 +161,7 @@ public class Configuration {
|
|
|
*/
|
|
|
@Inject
|
|
|
private OsFamily osFamily;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* The filename of the {@link Properties} file which contains all of the
|
|
|
* configurations for Ambari.
|
|
|
@@ -182,24 +180,6 @@ public class Configuration {
|
|
|
*/
|
|
|
public static final float JDK_MIN_VERSION = 1.7f;
|
|
|
|
|
|
- /**
|
|
|
- * The default regex pattern to use when replacing the member attribute ID
|
|
|
- * value with a placeholder, such as {@code ${member}}. This is used in cases
|
|
|
- * where a UID of an LDAP member is not a full CN or unique ID.
|
|
|
- */
|
|
|
- private static final String LDAP_SYNC_MEMBER_REPLACE_PATTERN_DEFAULT = "";
|
|
|
-
|
|
|
- /**
|
|
|
- * The default LDAP filter to use when syncing user or group members. This
|
|
|
- * default filter can include a {@code {member}} placeholder which allows
|
|
|
- * substitution of a direct ID. For example:
|
|
|
- *
|
|
|
- * <pre>
|
|
|
- * (&(objectclass=posixaccount)(dn={member})) -> (&(objectclass=posixaccount)(dn=cn=mycn,dc=apache,dc=org))
|
|
|
- * </pre>
|
|
|
- */
|
|
|
- private static final String LDAP_SYNC_MEMBER_FILTER_DEFAULT = "";
|
|
|
-
|
|
|
/**
|
|
|
* The prefix for any configuration property which will be appended to
|
|
|
* {@code eclipselink.jdbc.property.} before being passed into EclipseLink.
|
|
|
@@ -692,16 +672,6 @@ public class Configuration {
|
|
|
public static final ConfigurationProperty<String> COMMON_SERVICES_DIR_PATH = new ConfigurationProperty<>(
|
|
|
"common.services.path", null);
|
|
|
|
|
|
- /**
|
|
|
- * Determines whether an existing local users will be updated as LDAP users.
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "Determines how to handle username collision while updating from LDAP.",
|
|
|
- examples = { "skip", "convert" }
|
|
|
- )
|
|
|
- public static final ConfigurationProperty<String> LDAP_SYNC_USERNAME_COLLISIONS_BEHAVIOR = new ConfigurationProperty<>(
|
|
|
- "ldap.sync.username.collision.behavior", "convert");
|
|
|
-
|
|
|
/**
|
|
|
* The location on the Ambari Server where stack extensions exist.
|
|
|
*/
|
|
|
@@ -986,252 +956,6 @@ public class Configuration {
|
|
|
public static final ConfigurationProperty<String> MYSQL_JAR_NAME = new ConfigurationProperty<>(
|
|
|
"db.mysql.jdbc.name", "mysql-connector-java.jar");
|
|
|
|
|
|
- /**
|
|
|
- * For development purposes only, should be changed to 'false'
|
|
|
- */
|
|
|
- @Markdown(description = "An internal property used for unit testing and development purposes.")
|
|
|
- public static final ConfigurationProperty<String> IS_LDAP_CONFIGURED = new ConfigurationProperty<>(
|
|
|
- "ambari.ldap.isConfigured", "false");
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines whether to use LDAP over SSL (LDAPS).
|
|
|
- */
|
|
|
- @Markdown(description = "Determines whether to use LDAP over SSL (LDAPS).")
|
|
|
- public static final ConfigurationProperty<String> LDAP_USE_SSL = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.useSSL", "false");
|
|
|
-
|
|
|
- /**
|
|
|
- * The default value is used for embedded purposes only.
|
|
|
- */
|
|
|
- @Markdown(description = "The LDAP URL used for connecting to an LDAP server when authenticating users. This should include both the host name and port.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_PRIMARY_URL = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.primaryUrl", "localhost:33389");
|
|
|
-
|
|
|
- /**
|
|
|
- * A second LDAP URL to use as a backup when authenticating users.
|
|
|
- */
|
|
|
- @Markdown(description = "A second LDAP URL to use as a backup when authenticating users. This should include both the host name and port.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_SECONDARY_URL = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.secondaryUrl", null);
|
|
|
-
|
|
|
- /**
|
|
|
- * The base DN to use when filtering LDAP users and groups.
|
|
|
- */
|
|
|
- @Markdown(description = "The base DN to use when filtering LDAP users and groups. This is only used when LDAP authentication is enabled.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_BASE_DN = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.baseDn", "dc=ambari,dc=apache,dc=org");
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines whether LDAP requests can connect anonymously or if a managed
|
|
|
- * user is required to connect.
|
|
|
- */
|
|
|
- @Markdown(description = "Determines whether LDAP requests can connect anonymously or if a managed user is required to connect.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_BIND_ANONYMOUSLY = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.bindAnonymously", "true");
|
|
|
-
|
|
|
- /**
|
|
|
- * The DN of the manager account to use when binding to LDAP if
|
|
|
- * {@link #LDAP_BIND_ANONYMOUSLY} is turned off.
|
|
|
- */
|
|
|
- @Markdown(description = "The DN of the manager account to use when binding to LDAP if anonymous binding is disabled.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_MANAGER_DN = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.managerDn", null);
|
|
|
-
|
|
|
- /**
|
|
|
- * The password for the account used to bind to LDAP if
|
|
|
- * {@link #LDAP_BIND_ANONYMOUSLY} is turned off.
|
|
|
- */
|
|
|
- @Markdown(description = "The password for the manager account used to bind to LDAP if anonymous binding is disabled.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_MANAGER_PASSWORD = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.managerPassword", null);
|
|
|
-
|
|
|
- /**
|
|
|
- * The attribute used for determining what the distinguished name property is.
|
|
|
- */
|
|
|
- @Markdown(description = "The attribute used for determining what the distinguished name property is.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_DN_ATTRIBUTE = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.dnAttribute", "dn");
|
|
|
-
|
|
|
- /**
|
|
|
- * The attribute used for determining the user name.
|
|
|
- */
|
|
|
- @Markdown(description = "The attribute used for determining the user name, such as `uid`.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_USERNAME_ATTRIBUTE = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.usernameAttribute", "uid");
|
|
|
-
|
|
|
- /**
|
|
|
- * Declares whether to force the ldap user name to be lowercase or leave as-is. This is useful when
|
|
|
- * local user names are expected to be lowercase but the LDAP user names are not.
|
|
|
- */
|
|
|
- @Markdown(description = "Declares whether to force the ldap user name to be lowercase or leave as-is." +
|
|
|
- " This is useful when local user names are expected to be lowercase but the LDAP user names are not.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_USERNAME_FORCE_LOWERCASE = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.username.forceLowercase", "false");
|
|
|
-
|
|
|
- /**
|
|
|
- * The filter used when searching for users in LDAP.
|
|
|
- */
|
|
|
- @Markdown(description = "The filter used when searching for users in LDAP.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_USER_BASE = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.userBase", "ou=people,dc=ambari,dc=apache,dc=org");
|
|
|
-
|
|
|
- /**
|
|
|
- * The class to which user objects in LDAP belong.
|
|
|
- */
|
|
|
- @Markdown(description = "The class to which user objects in LDAP belong.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_USER_OBJECT_CLASS = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.userObjectClass", "person");
|
|
|
-
|
|
|
- /**
|
|
|
- * The filter used when searching for groups in LDAP.
|
|
|
- */
|
|
|
- @Markdown(description = "The filter used when searching for groups in LDAP.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_GROUP_BASE = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.groupBase", "ou=groups,dc=ambari,dc=apache,dc=org");
|
|
|
-
|
|
|
- /**
|
|
|
- * The class to which group objects in LDAP belong.
|
|
|
- */
|
|
|
- @Markdown(description = "The class to which group objects in LDAP belong.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_GROUP_OBJECT_CLASS = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.groupObjectClass", "group");
|
|
|
-
|
|
|
- /**
|
|
|
- * The attribute used to determine the group name.
|
|
|
- */
|
|
|
- @Markdown(description = "The attribute used to determine the group name in LDAP.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_GROUP_NAMING_ATTR = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.groupNamingAttr", "cn");
|
|
|
-
|
|
|
- /**
|
|
|
- * The LDAP attribute which identifies group membership.
|
|
|
- */
|
|
|
- @Markdown(description = "The LDAP attribute which identifies group membership.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_GROUP_MEMBERSHIP_ATTR = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.groupMembershipAttr", "member");
|
|
|
-
|
|
|
- /**
|
|
|
- * A comma-separate list of groups which would give a user administrative access to Ambari.
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "A comma-separate list of groups which would give a user administrative access to Ambari when syncing from LDAP. This is only used when `authorization.ldap.groupSearchFilter` is blank.",
|
|
|
- examples = { "administrators", "Hadoop Admins,Hadoop Admins.*,DC Admins,.*Hadoop Operators" })
|
|
|
- public static final ConfigurationProperty<String> LDAP_ADMIN_GROUP_MAPPING_RULES = new ConfigurationProperty<>(
|
|
|
- "authorization.ldap.adminGroupMappingRules", "Ambari Administrators");
|
|
|
-
|
|
|
- /**
|
|
|
- * When authentication through LDAP is enabled then Ambari Server uses this
|
|
|
- * filter to lookup the user in LDAP based on the provided ambari user name.
|
|
|
- *
|
|
|
- * If it is not set then
|
|
|
- * {@code (&({usernameAttribute}={0})(objectClass={userObjectClass}))} is
|
|
|
- * used.
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "A filter used to lookup a user in LDAP based on the Ambari user name",
|
|
|
- examples = { "(&({usernameAttribute}={0})(objectClass={userObjectClass}))" })
|
|
|
- public static final ConfigurationProperty<String> LDAP_USER_SEARCH_FILTER = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.userSearchFilter",
|
|
|
- "(&({usernameAttribute}={0})(objectClass={userObjectClass}))");
|
|
|
-
|
|
|
- /**
|
|
|
- * This configuration controls whether the use of alternate user search filter
|
|
|
- * is enabled. If the default LDAP user search filter is not able to find the
|
|
|
- * authenticating user in LDAP than Ambari can fall back an alternative user
|
|
|
- * search filter if this functionality is enabled.
|
|
|
- *
|
|
|
- * If it is not set then the default
|
|
|
- */
|
|
|
- @Markdown(description = "Determines whether a secondary (alternate) LDAP user search filer is used if the primary filter fails to find a user.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_ALT_USER_SEARCH_ENABLED = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.alternateUserSearchEnabled", "false");
|
|
|
-
|
|
|
- /**
|
|
|
- * When authentication through LDAP is enabled Ambari Server uses this filter
|
|
|
- * by default to lookup the user in LDAP when the user provides beside user
|
|
|
- * name additional information. There might be cases when
|
|
|
- * {@link #LDAP_USER_SEARCH_FILTER} may match multiple users in LDAP. In such
|
|
|
- * cases the user is prompted to provide additional info, e.g. the domain he
|
|
|
- * or she wants ot log in upon login beside the username. This filter will be
|
|
|
- * used by Ambari Server to lookup users in LDAP if the login name the user
|
|
|
- * logs in contains additional information beside ambari user name.
|
|
|
- * <p>
|
|
|
- * Note: Currently the use of alternate user search filter is triggered only
|
|
|
- * if the user login name is in the username@domain format (e.g.
|
|
|
- * user1@x.y.com) which is the userPrincipalName format used in AD.
|
|
|
- * </p>
|
|
|
- */
|
|
|
- @Markdown(description = "An alternate LDAP user search filter which can be used if `authentication.ldap.alternateUserSearchEnabled` is enabled and the primary filter fails to find a user.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_ALT_USER_SEARCH_FILTER = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.alternateUserSearchFilter",
|
|
|
- "(&(userPrincipalName={0})(objectClass={userObjectClass}))");
|
|
|
-
|
|
|
- /**
|
|
|
- * The DN to use when searching for LDAP groups.
|
|
|
- */
|
|
|
- @Markdown(description = "The DN to use when searching for LDAP groups.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_GROUP_SEARCH_FILTER = new ConfigurationProperty<>(
|
|
|
- "authorization.ldap.groupSearchFilter", "");
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines whether to follow LDAP referrals when the LDAP controller doesn't have the requested object.
|
|
|
- */
|
|
|
- @Markdown(description = "Determines whether to follow LDAP referrals to other URLs when the LDAP controller doesn't have the requested object.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_REFERRAL = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.referral", "follow");
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines whether results from LDAP are paginated when requested.
|
|
|
- */
|
|
|
- @Markdown(description = "Determines whether results from LDAP are paginated when requested.")
|
|
|
- public static final ConfigurationProperty<String> LDAP_PAGINATION_ENABLED = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.pagination.enabled", "true");
|
|
|
-
|
|
|
- /**
|
|
|
- * Regex pattern to use when replacing the user member attribute
|
|
|
- * ID value with a placeholder. This is used in cases where a UID of an LDAP
|
|
|
- * member is not a full CN or unique ID.
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "Regex pattern to use when replacing the user member attribute ID value with a placeholder. This is used in cases where a UID of an LDAP member is not a full CN or unique ID (e.g.: `member: <SID=123>;<GID=123>;cn=myCn,dc=org,dc=apache`)",
|
|
|
- examples = { "(?<sid>.*);(?<guid>.*);(?<member>.*)" })
|
|
|
- public static final ConfigurationProperty<String> LDAP_SYNC_USER_MEMBER_REPLACE_PATTERN = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.sync.userMemberReplacePattern",
|
|
|
- LDAP_SYNC_MEMBER_REPLACE_PATTERN_DEFAULT);
|
|
|
-
|
|
|
- /**
|
|
|
- * Regex pattern to use when replacing the group member attribute
|
|
|
- * ID value with a placeholder. This is used in cases where a UID of an LDAP
|
|
|
- * member is not a full CN or unique ID.
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "Regex pattern to use when replacing the group member attribute ID value with a placeholder. This is used in cases where a UID of an LDAP member is not a full CN or unique ID (e.g.: `member: <SID=123>;<GID=123>;cn=myCn,dc=org,dc=apache`)",
|
|
|
- examples = { "(?<sid>.*);(?<guid>.*);(?<member>.*)" })
|
|
|
- public static final ConfigurationProperty<String> LDAP_SYCN_GROUP_MEMBER_REPLACE_PATTERN = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.sync.groupMemberReplacePattern",
|
|
|
- LDAP_SYNC_MEMBER_REPLACE_PATTERN_DEFAULT);
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter to use for syncing user members of group from LDAP. (by default it is not used)
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "Filter to use for syncing user members of a group from LDAP (by default it is not used).",
|
|
|
- examples = {"(&(objectclass=posixaccount)(uid={member}))"})
|
|
|
- public static final ConfigurationProperty<String> LDAP_SYNC_USER_MEMBER_FILTER = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.sync.userMemberFilter",
|
|
|
- LDAP_SYNC_MEMBER_FILTER_DEFAULT);
|
|
|
-
|
|
|
- /**
|
|
|
- * Filter to use for syncing group members of a group from LDAP. (by default it is not used)
|
|
|
- */
|
|
|
- @Markdown(
|
|
|
- description = "Filter to use for syncing group members of a group from LDAP. (by default it is not used)",
|
|
|
- examples = {"(&(objectclass=posixgroup)(cn={member}))"})
|
|
|
- public static final ConfigurationProperty<String> LDAP_SYNC_GROUP_MEMBER_FILTER = new ConfigurationProperty<>(
|
|
|
- "authentication.ldap.sync.groupMemberFilter",
|
|
|
- LDAP_SYNC_MEMBER_FILTER_DEFAULT);
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* Enable the profiling of internal locks.
|
|
|
*/
|
|
|
@@ -2087,8 +1811,6 @@ public class Configuration {
|
|
|
public static final ConfigurationProperty<String> LEGACY_OVERRIDE = new ConfigurationProperty<>(
|
|
|
"repositories.legacy-override.enabled", "false");
|
|
|
|
|
|
- private static final String LDAP_ADMIN_GROUP_MAPPING_MEMBER_ATTR_DEFAULT = "";
|
|
|
-
|
|
|
/**
|
|
|
* The time, in {@link TimeUnit#MILLISECONDS}, that agent connections can remain open and idle.
|
|
|
*/
|
|
|
@@ -2804,8 +2526,6 @@ public class Configuration {
|
|
|
private JsonObject hostChangesJson;
|
|
|
private Map<String, String> configsMap;
|
|
|
private Map<String, String> agentConfigsMap;
|
|
|
- private CredentialProvider credentialProvider = null;
|
|
|
- private volatile boolean credentialProviderInitialized = false;
|
|
|
private Properties customDbProperties = null;
|
|
|
private Properties customPersistenceProperties = null;
|
|
|
private Long configLastModifiedDateForCustomJDBC = 0L;
|
|
|
@@ -2829,16 +2549,6 @@ public class Configuration {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Ldap username collision handling behavior.
|
|
|
- * CONVERT - convert existing local users to LDAP users.
|
|
|
- * SKIP - skip existing local users.
|
|
|
- */
|
|
|
- public enum LdapUsernameCollisionHandlingBehavior {
|
|
|
- CONVERT,
|
|
|
- SKIP
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* The {@link DatabaseType} enum represents the database being used.
|
|
|
*/
|
|
|
@@ -3100,8 +2810,7 @@ public class Configuration {
|
|
|
System.setProperty(JAVAX_SSL_TRUSTSTORE, getProperty(SSL_TRUSTSTORE_PATH));
|
|
|
}
|
|
|
if (getProperty(SSL_TRUSTSTORE_PASSWORD) != null) {
|
|
|
- String ts_password = readPasswordFromStore(
|
|
|
- getProperty(SSL_TRUSTSTORE_PASSWORD));
|
|
|
+ String ts_password = PasswordUtils.getInstance().readPasswordFromStore(getProperty(SSL_TRUSTSTORE_PASSWORD), getMasterKeyLocation(), isMasterKeyPersisted(), getMasterKeyStoreLocation());
|
|
|
if (ts_password != null) {
|
|
|
System.setProperty(JAVAX_SSL_TRUSTSTORE_PASSWORD, ts_password);
|
|
|
} else {
|
|
|
@@ -3114,24 +2823,6 @@ public class Configuration {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private synchronized void loadCredentialProvider() {
|
|
|
- if (!credentialProviderInitialized) {
|
|
|
- try {
|
|
|
- credentialProvider = new CredentialProvider(null,
|
|
|
- getMasterKeyLocation(),
|
|
|
- isMasterKeyPersisted(),
|
|
|
- getMasterKeyStoreLocation());
|
|
|
- } catch (Exception e) {
|
|
|
- LOG.info("Credential provider creation failed. Reason: " + e.getMessage());
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- credentialProvider = null;
|
|
|
- }
|
|
|
- credentialProviderInitialized = true;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Find, read, and parse the configuration file.
|
|
|
* @return the properties that were found or empty if no file was found
|
|
|
@@ -4034,7 +3725,7 @@ public class Configuration {
|
|
|
String dbpasswd = null;
|
|
|
boolean isPasswordAlias = false;
|
|
|
if (CredentialProvider.isAliasString(passwdProp)) {
|
|
|
- dbpasswd = readPasswordFromStore(passwdProp);
|
|
|
+ dbpasswd = PasswordUtils.getInstance().readPasswordFromStore(passwdProp, getMasterKeyLocation(), isMasterKeyPersisted(), getMasterKeyStoreLocation());
|
|
|
isPasswordAlias =true;
|
|
|
}
|
|
|
|
|
|
@@ -4044,7 +3735,7 @@ public class Configuration {
|
|
|
LOG.error("Can't read db password from keystore. Please, check master key was set correctly.");
|
|
|
throw new RuntimeException("Can't read db password from keystore. Please, check master key was set correctly.");
|
|
|
} else {
|
|
|
- return readPasswordFromFile(passwdProp, SERVER_JDBC_USER_PASSWD.getDefaultValue());
|
|
|
+ return PasswordUtils.getInstance().readPasswordFromFile(passwdProp, SERVER_JDBC_USER_PASSWD.getDefaultValue());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -4062,117 +3753,7 @@ public class Configuration {
|
|
|
|
|
|
public String getRcaDatabasePassword() {
|
|
|
String passwdProp = properties.getProperty(SERVER_JDBC_RCA_USER_PASSWD.getKey());
|
|
|
- if (passwdProp != null) {
|
|
|
- String dbpasswd = readPasswordFromStore(passwdProp);
|
|
|
- if (dbpasswd != null) {
|
|
|
- return dbpasswd;
|
|
|
- }
|
|
|
- }
|
|
|
- return readPasswordFromFile(passwdProp, SERVER_JDBC_RCA_USER_PASSWD.getDefaultValue());
|
|
|
- }
|
|
|
-
|
|
|
- private String readPasswordFromFile(String filePath, String defaultPassword) {
|
|
|
- if (filePath == null) {
|
|
|
- LOG.debug("DB password file not specified - using default");
|
|
|
- return defaultPassword;
|
|
|
- } else {
|
|
|
- LOG.debug("Reading password from file {}", filePath);
|
|
|
- String password;
|
|
|
- try {
|
|
|
- password = FileUtils.readFileToString(new File(filePath));
|
|
|
- password = StringUtils.chomp(password);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException("Unable to read database password", e);
|
|
|
- }
|
|
|
- return password;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String readPasswordFromStore(String aliasStr) {
|
|
|
- String password = null;
|
|
|
- loadCredentialProvider();
|
|
|
- if (credentialProvider != null) {
|
|
|
- char[] result = null;
|
|
|
- try {
|
|
|
- result = credentialProvider.getPasswordForAlias(aliasStr);
|
|
|
- } catch (AmbariException e) {
|
|
|
- LOG.error("Error reading from credential store.");
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- if (result != null) {
|
|
|
- password = new String(result);
|
|
|
- } else {
|
|
|
- if (CredentialProvider.isAliasString(aliasStr)) {
|
|
|
- LOG.error("Cannot read password for alias = " + aliasStr);
|
|
|
- } else {
|
|
|
- LOG.warn("Raw password provided, not an alias. It cannot be read from credential store.");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return password;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Gets parameters of LDAP server to connect to
|
|
|
- * @return LdapServerProperties object representing connection parameters
|
|
|
- */
|
|
|
- public LdapServerProperties getLdapServerProperties() {
|
|
|
- LdapServerProperties ldapServerProperties = new LdapServerProperties();
|
|
|
-
|
|
|
- ldapServerProperties.setPrimaryUrl(getProperty(LDAP_PRIMARY_URL));
|
|
|
- ldapServerProperties.setSecondaryUrl(getProperty(LDAP_SECONDARY_URL));
|
|
|
- ldapServerProperties.setUseSsl(Boolean.parseBoolean(getProperty(LDAP_USE_SSL)));
|
|
|
- ldapServerProperties.setAnonymousBind(Boolean.parseBoolean(getProperty(LDAP_BIND_ANONYMOUSLY)));
|
|
|
- ldapServerProperties.setManagerDn(getProperty(LDAP_MANAGER_DN));
|
|
|
- String ldapPasswordProperty = getProperty(LDAP_MANAGER_PASSWORD);
|
|
|
- String ldapPassword = null;
|
|
|
- if (CredentialProvider.isAliasString(ldapPasswordProperty)) {
|
|
|
- ldapPassword = readPasswordFromStore(ldapPasswordProperty);
|
|
|
- }
|
|
|
- if (ldapPassword != null) {
|
|
|
- ldapServerProperties.setManagerPassword(ldapPassword);
|
|
|
- } else {
|
|
|
- if (ldapPasswordProperty != null && new File(ldapPasswordProperty).exists()) {
|
|
|
- ldapServerProperties.setManagerPassword(readPasswordFromFile(ldapPasswordProperty, ""));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ldapServerProperties.setBaseDN(getProperty(LDAP_BASE_DN));
|
|
|
- ldapServerProperties.setUsernameAttribute(getProperty(LDAP_USERNAME_ATTRIBUTE));
|
|
|
- ldapServerProperties.setForceUsernameToLowercase(Boolean.parseBoolean(getProperty(LDAP_USERNAME_FORCE_LOWERCASE)));
|
|
|
- ldapServerProperties.setUserBase(getProperty(LDAP_USER_BASE));
|
|
|
- ldapServerProperties.setUserObjectClass(getProperty(LDAP_USER_OBJECT_CLASS));
|
|
|
- ldapServerProperties.setDnAttribute(getProperty(LDAP_DN_ATTRIBUTE));
|
|
|
- ldapServerProperties.setGroupBase(getProperty(LDAP_GROUP_BASE));
|
|
|
- ldapServerProperties.setGroupObjectClass(getProperty(LDAP_GROUP_OBJECT_CLASS));
|
|
|
- ldapServerProperties.setGroupMembershipAttr(getProperty(LDAP_GROUP_MEMBERSHIP_ATTR));
|
|
|
- ldapServerProperties.setGroupNamingAttr(getProperty(LDAP_GROUP_NAMING_ATTR));
|
|
|
- ldapServerProperties.setAdminGroupMappingRules(getProperty(LDAP_ADMIN_GROUP_MAPPING_RULES));
|
|
|
- ldapServerProperties.setAdminGroupMappingMemberAttr(getProperty(LDAP_ADMIN_GROUP_MAPPING_MEMBER_ATTR_DEFAULT));
|
|
|
- ldapServerProperties.setUserSearchFilter(getProperty(LDAP_USER_SEARCH_FILTER));
|
|
|
- ldapServerProperties.setAlternateUserSearchFilter(getProperty(LDAP_ALT_USER_SEARCH_FILTER));
|
|
|
- ldapServerProperties.setGroupSearchFilter(getProperty(LDAP_GROUP_SEARCH_FILTER));
|
|
|
- ldapServerProperties.setReferralMethod(getProperty(LDAP_REFERRAL));
|
|
|
- ldapServerProperties.setSyncUserMemberReplacePattern(getProperty(LDAP_SYNC_USER_MEMBER_REPLACE_PATTERN));
|
|
|
- ldapServerProperties.setSyncGroupMemberReplacePattern(getProperty(LDAP_SYCN_GROUP_MEMBER_REPLACE_PATTERN));
|
|
|
- ldapServerProperties.setSyncUserMemberFilter(getProperty(LDAP_SYNC_USER_MEMBER_FILTER));
|
|
|
- ldapServerProperties.setSyncGroupMemberFilter(getProperty(LDAP_SYNC_GROUP_MEMBER_FILTER));
|
|
|
- ldapServerProperties.setPaginationEnabled(
|
|
|
- Boolean.parseBoolean(getProperty(LDAP_PAGINATION_ENABLED)));
|
|
|
-
|
|
|
- if (properties.containsKey(LDAP_GROUP_BASE) || properties.containsKey(LDAP_GROUP_OBJECT_CLASS)
|
|
|
- || properties.containsKey(LDAP_GROUP_MEMBERSHIP_ATTR)
|
|
|
- || properties.containsKey(LDAP_GROUP_NAMING_ATTR)
|
|
|
- || properties.containsKey(LDAP_ADMIN_GROUP_MAPPING_RULES)
|
|
|
- || properties.containsKey(LDAP_GROUP_SEARCH_FILTER)) {
|
|
|
- ldapServerProperties.setGroupMappingEnabled(true);
|
|
|
- }
|
|
|
-
|
|
|
- return ldapServerProperties;
|
|
|
- }
|
|
|
-
|
|
|
- public boolean isLdapConfigured() {
|
|
|
- return Boolean.parseBoolean(getProperty(IS_LDAP_CONFIGURED));
|
|
|
+ return PasswordUtils.getInstance().readPassword(passwdProp, SERVER_JDBC_RCA_USER_PASSWD.getDefaultValue());
|
|
|
}
|
|
|
|
|
|
public String getServerOsType() {
|
|
|
@@ -5056,17 +4637,6 @@ public class Configuration {
|
|
|
return Boolean.parseBoolean(getProperty(KERBEROS_CHECK_JAAS_CONFIGURATION));
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Determines whether an existing local users will be skipped on updated during LDAP sync.
|
|
|
- *
|
|
|
- * @return true if ambari need to skip existing user during LDAP sync.
|
|
|
- */
|
|
|
- public LdapUsernameCollisionHandlingBehavior getLdapSyncCollisionHandlingBehavior() {
|
|
|
- if (getProperty(LDAP_SYNC_USERNAME_COLLISIONS_BEHAVIOR).toLowerCase().equals("skip")) {
|
|
|
- return LdapUsernameCollisionHandlingBehavior.SKIP;
|
|
|
- }
|
|
|
- return LdapUsernameCollisionHandlingBehavior.CONVERT;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* Gets the type of database by examining the {@link #getDatabaseUrl()} JDBC
|
|
|
@@ -5510,10 +5080,6 @@ public class Configuration {
|
|
|
return StringUtils.isEmpty(udpPort) ? null : Integer.parseInt(udpPort);
|
|
|
}
|
|
|
|
|
|
- public boolean isLdapAlternateUserSearchEnabled() {
|
|
|
- return Boolean.parseBoolean(getProperty(LDAP_ALT_USER_SEARCH_ENABLED));
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Gets the hosts/ports that proxy calls are allowed to be made to.
|
|
|
*
|