ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject [54/58] [abbrv] ambari git commit: AMBARI-18529. Custom properties are now overriding default proplerties (Miklos Gergely via oleewere)
Date Sat, 05 Nov 2016 14:56:44 GMT
AMBARI-18529. Custom properties are now overriding default proplerties (Miklos Gergely via
oleewere)

Change-Id: I28b8d74836df85dc2e7538686563df5de9b0eada


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

Branch: refs/heads/logsearch-ga
Commit: 0e852c140cbebdfafa690eaf24e7614cc76c5a3e
Parents: c9d3b59
Author: Miklos Gergely <mgergely@hortonworks.com>
Authored: Fri Oct 7 01:49:44 2016 +0200
Committer: oleewere <oleewere@gmail.com>
Committed: Sat Nov 5 14:46:47 2016 +0100

----------------------------------------------------------------------
 .../apache/ambari/logsearch/dao/UserDao.java    | 17 ++++----
 ...LogsearchAbstractAuthenticationProvider.java | 14 -------
 .../LogsearchSimpleAuthenticationProvider.java  | 11 ------
 .../LOGSEARCH/0.5.0/package/scripts/params.py   | 41 +++++++++++++++-----
 4 files changed, 40 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0e852c14/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
index 0810571..912442d 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/dao/UserDao.java
@@ -88,17 +88,18 @@ public class UserDao {
     }
   }
 
-  public User loadUserByUsername(final String username) {
+  public User loadUserByUsername(String username) {
     logger.debug(" loadUserByUsername username" + username);
     HashMap<String, String> userInfo = findByusername(username);
-    User user = new User();
-
-    if (userInfo != null) {
-      user.setFirstName(userInfo.get(NAME) != null ? userInfo.get(NAME) : "Unknown");
-      user.setLastName(userInfo.get(NAME) != null ? userInfo.get(NAME) : "Unknown");
-      user.setUsername(userInfo.get(USER_NAME) != null ? userInfo.get(USER_NAME) : "");
-      user.setPassword(userInfo.get(ENC_PASSWORD) != null ? userInfo.get(ENC_PASSWORD) :
"");
+    if (userInfo == null) {
+      return null;
     }
+    
+    User user = new User();
+    user.setFirstName(StringUtils.defaultString(userInfo.get(NAME), "Unknown"));
+    user.setLastName(StringUtils.defaultString(userInfo.get(NAME), "Unknown"));
+    user.setUsername(StringUtils.defaultString(userInfo.get(USER_NAME), ""));
+    user.setPassword(StringUtils.defaultString(userInfo.get(ENC_PASSWORD), ""));
 
     Role r = new Role();
     r.setName("ROLE_USER");

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e852c14/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
index eb6c9f1..1c7bf3b 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchAbstractAuthenticationProvider.java
@@ -21,7 +21,6 @@ package org.apache.ambari.logsearch.web.security;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.ambari.logsearch.common.PropertiesHelper;
 import org.springframework.security.authentication.AuthenticationProvider;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.GrantedAuthority;
@@ -29,8 +28,6 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority;
 
 abstract class LogsearchAbstractAuthenticationProvider implements AuthenticationProvider
{
 
-  private static final String AUTH_METHOD_PROPERTY_PREFIX = "logsearch.auth.";
-
   protected enum AuthMethod {
     LDAP, FILE, EXTERNAL_AUTH, SIMPLE
   };
@@ -48,15 +45,4 @@ abstract class LogsearchAbstractAuthenticationProvider implements Authentication
     grantedAuths.add(new SimpleGrantedAuthority("ROLE_USER"));
     return grantedAuths;
   }
-
-  /**
-   * Check authentication provider is enable or disable for specified method
-   */
-  public boolean isEnable(AuthMethod method) {
-    String methodName = method.name().toLowerCase();
-    String property = AUTH_METHOD_PROPERTY_PREFIX + methodName + ".enable";
-    boolean isEnable = PropertiesHelper.getBooleanProperty(property, false);
-    return isEnable;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e852c14/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
index 92a7aaa..3506264 100644
--- a/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
+++ b/ambari-logsearch/ambari-logsearch-portal/src/main/java/org/apache/ambari/logsearch/web/security/LogsearchSimpleAuthenticationProvider.java
@@ -58,15 +58,4 @@ public class LogsearchSimpleAuthenticationProvider extends LogsearchAbstractAuth
     authentication = new UsernamePasswordAuthenticationToken(username, password, getAuthorities());
     return authentication;
   }
-
-  @Override
-  public boolean isEnable(AuthMethod method) {
-    boolean ldapEnabled = super.isEnable(AuthMethod.LDAP);
-    boolean fileEnabled = super.isEnable(AuthMethod.FILE);
-    boolean externalAuthEnabled = super.isEnable(AuthMethod.EXTERNAL_AUTH);
-    boolean simpleEnabled = super.isEnable(method);
-    
-    // simple is enabled only when rest three are disabled and simple is enable
-    return !ldapEnabled && !fileEnabled && !externalAuthEnabled &&
simpleEnabled;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0e852c14/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/params.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/params.py
index e55653f..4526640 100644
--- a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/scripts/params.py
@@ -196,7 +196,9 @@ else:
 
 # Logsearch propreties
 
-logsearch_properties = dict(config['configurations']['logsearch-properties'])
+logsearch_properties = {}
+
+# default values
 
 logsearch_properties['logsearch.solr.zk_connect_string'] = zookeeper_quorum + infra_solr_znode
 logsearch_properties['logsearch.solr.audit.logs.zk_connect_string'] = logsearch_solr_audit_logs_zk_quorum
+ logsearch_solr_audit_logs_zk_node
@@ -205,13 +207,6 @@ logsearch_properties['logsearch.solr.collection.history'] = 'history'
 logsearch_properties['logsearch.solr.history.config.name'] = 'history'
 logsearch_properties['logsearch.collection.history.replication.factor'] = '1'
 
-if logsearch_properties['logsearch.solr.audit.logs.use.ranger'] == 'false':
-  del logsearch_properties['logsearch.ranger.audit.logs.collection.name']
-
-del logsearch_properties['logsearch.solr.audit.logs.use.ranger']
-
-logsearch_properties['logsearch.solr.metrics.collector.hosts'] = format(logsearch_properties['logsearch.solr.metrics.collector.hosts'])
-
 logsearch_properties['logsearch.solr.jmx.port'] = infra_solr_jmx_port
 
 logsearch_properties['logsearch.login.credentials.file'] = logsearch_admin_credential_file
@@ -219,10 +214,23 @@ logsearch_properties['logsearch.auth.file.enabled'] = 'true'
 logsearch_properties['logsearch.auth.ldap.enabled'] = 'false'
 logsearch_properties['logsearch.auth.simple.enabled'] = 'false'
 logsearch_properties['logsearch.roles.allowed'] = 'AMBARI.ADMINISTRATOR'
-logsearch_properties['logsearch.auth.external_auth.host_url'] = format(logsearch_properties['logsearch.auth.external_auth.host_url'])
 
 logsearch_properties['logsearch.protocol'] = logsearch_ui_protocol
 
+# load config values
+
+logsearch_properties = dict(logsearch_properties.items() + dict(config['configurations']['logsearch-properties']).items())
+
+# load derivated values
+
+if logsearch_properties['logsearch.solr.audit.logs.use.ranger'] == 'false':
+  del logsearch_properties['logsearch.ranger.audit.logs.collection.name']
+
+del logsearch_properties['logsearch.solr.audit.logs.use.ranger']
+
+logsearch_properties['logsearch.solr.metrics.collector.hosts'] = format(logsearch_properties['logsearch.solr.metrics.collector.hosts'])
+logsearch_properties['logsearch.auth.external_auth.host_url'] = format(logsearch_properties['logsearch.auth.external_auth.host_url'])
+
 if security_enabled:
   logsearch_properties['logsearch.solr.kerberos.enable'] = 'true'
   logsearch_properties['logsearch.solr.jaas.file'] = logsearch_jaas_file
@@ -286,9 +294,22 @@ if config['configurations']['logfeeder-grok']['custom_grok_patterns'].strip():
 
 logfeeder_properties = dict(config['configurations']['logfeeder-properties'])
 
+# logfeeder properties
+
+# load default values
+
+logfeeder_properties = {}
+
+logfeeder_properties['logfeeder.solr.core.config.name'] = 'history'
+
+# load config values
+
+logfeeder_properties = dict(logfeeder_properties.items() + dict(config['configurations']['logfeeder-properties']).items())
+
+# load derivated values
+
 logfeeder_properties['logfeeder.metrics.collector.hosts'] = format(logfeeder_properties['logfeeder.metrics.collector.hosts'])
 logfeeder_properties['logfeeder.config.files'] = format(logfeeder_properties['logfeeder.config.files'])
-logfeeder_properties['logfeeder.solr.core.config.name'] = 'history'
 logfeeder_properties['logfeeder.solr.zk_connect_string'] = zookeeper_quorum + infra_solr_znode
 
 if security_enabled:


Mime
View raw message