incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1392747 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/src/main/python/ambari_agent/ ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ ambari-server/src/main/java/org/apache/ambari/server/configuration/ ambar...
Date Tue, 02 Oct 2012 05:35:13 GMT
Author: mahadev
Date: Tue Oct  2 05:35:12 2012
New Revision: 1392747

URL: http://svn.apache.org/viewvc?rev=1392747&view=rev
Log:
AMBARI-783. Fix guice injection in the server. (mahadev)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/main.py
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Oct  2 05:35:12 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-783. Fix guice injection in the server. (mahadev)
+
   AMBARI-784. Add Resource download API on the server. (mahadev)
 
   AMBARI-781. Registration unit test. (jitendra)

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
Tue Oct  2 05:35:12 2012
@@ -42,6 +42,10 @@ facter_home=/root/workspace/puppet-insta
 maxretries=2
 sleepBetweenRetries=1
 
+[security]
+keysdir="/tmp/"
+server_crt=ca.crt
+passphrase_env_name=AMBARI_PASSPHRASE
 """
 s = StringIO.StringIO(content)
 config.readfp(s)

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/main.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/main.py?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/main.py
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/main.py
Tue Oct  2 05:35:12 2012
@@ -75,7 +75,7 @@ def debug(sig, frame):
     d.update(frame.f_globals)  # Unless shadowed by global
     d.update(frame.f_locals)
 
-    message  = "Signal recieved : entering python shell.\nTraceback:\n"
+    message  = "Signal received : entering python shell.\nTraceback:\n"
     message += ''.join(traceback.format_stack(frame))
     logger.info(message)
 
@@ -136,11 +136,11 @@ def main():
 
 
   #Initiate security
-  
+  """ Check if security is enable if not then disable it"""
+  logger.info("Creating certs")
   certMan = CertificateManager(config)
-  
   certMan.initSecurity()
-
+  
   # Launch Controller communication
   controller = Controller(config) 
   controller.start()

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/security.py
Tue Oct  2 05:35:12 2012
@@ -24,9 +24,13 @@ class VerifiedHTTPSConnection(httplib.HT
     if self._tunnel_host:
       self.sock = sock
       self._tunnel()
-    agent_key = AmbariConfig.config.get('security', 'keysdir') + os.sep + socket.gethostname()
+ ".key"
-    agent_crt = AmbariConfig.config.get('security', 'keysdir') + os.sep + socket.gethostname()
+ ".crt"
-    server_crt = AmbariConfig.config.get('security', 'keysdir') + os.sep + "ca.crt"
+    agent_key = AmbariConfig.config.get('security', 'keysdir') + os.sep + \
+     socket.gethostname() + ".key"
+    agent_crt = AmbariConfig.config.get('security', 'keysdir') + os.sep \
+    + socket.gethostname() + ".crt" 
+    server_crt = AmbariConfig.config.get('security', 'keysdir') + os.sep \
+    + "ca.crt"
+    
     self.sock = ssl.wrap_socket(sock,
                                 keyfile=agent_key,
                                 certfile=agent_crt,
@@ -45,6 +49,7 @@ def secured_url_open(req):
   url_opener = urllib2.build_opener(https_handler)
   stream = url_opener.open(req)
   return stream
+
 class CertificateManager():
   def __init__(self, config):
     self.config = config

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionManager.java
Tue Oct  2 05:35:12 2012
@@ -25,6 +25,7 @@ import org.apache.ambari.server.state.li
 
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
+import com.google.inject.name.Named;
 
 
 /**
@@ -38,7 +39,8 @@ public class ActionManager {
   private final Clusters fsm;
 
   @Inject
-  public ActionManager(long schedulerSleepTime, long actionTimeout,
+  public ActionManager(@Named("schedulerSleeptime") long schedulerSleepTime,
+      @Named("actionTimeout") long actionTimeout,
       ActionQueue aq, Clusters fsm, ActionDBAccessor db) {
     this.actionQueue = aq;
     this.db = db;

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
Tue Oct  2 05:35:12 2012
@@ -21,12 +21,13 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
 
 import org.apache.ambari.server.security.ClientSecurityType;
 import org.apache.ambari.server.security.authorization.LdapServerProperties;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -47,23 +48,34 @@ public class Configuration {
   public static final String SRVR_KSTR_DIR_KEY = "security.server.keys_dir";
   public static final String SRVR_CRT_NAME_KEY = "security.server.cert_name";
   public static final String SRVR_KEY_NAME_KEY = "security.server.key_name";
-  public static final String KSTR_NAME_KEY = "security.server.keystore_name";
-  public static final String SRVR_CRT_PASS_FILE_KEY = "security.server.crt_pass_file";
+  public static final String KSTR_NAME_KEY = 
+      "security.server.keystore_name";
+  public static final String SRVR_CRT_PASS_FILE_KEY = 
+      "security.server.crt_pass_file";
   public static final String SRVR_CRT_PASS_KEY = "security.server.crt_pass";
-  public static final String PASSPHRASE_ENV_KEY = "security.server.passphrase_env_var";
+  public static final String PASSPHRASE_ENV_KEY = 
+      "security.server.passphrase_env_var";
   public static final String PASSPHRASE_KEY = "security.server.passphrase";
   public static final String RESOURCES_DIR_KEY = "resources.dir";
 
   public static final String CLIENT_SECURITY_KEY = "client.security";
   public static final String LDAP_USE_SSL_KEY = "authorization.ldap.useSSL";
-  public static final String LDAP_PRIMARY_URL_KEY = "authorization.ldap.primaryUrl";
-  public static final String LDAP_SECONDARY_URL_KEY = "authorization.ldap.secondaryUrl";
-  public static final String LDAP_BASE_DN_KEY = "authorization.ldap.baseDn";
-  public static final String LDAP_BIND_ANONYMOUSLY_KEY = "authorization.ldap.bindAnonymously";
-  public static final String LDAP_MANAGER_DN_KEY = "authorization.ldap.managerDn";
-  public static final String LDAP_MANAGER_PASSWORD_KEY = "authorization.ldap.managerPassword";
-  public static final String LDAP_USERNAME_ATTRIBUTE_KEY = "authorization.ldap.usernameAttribute";
-  public static final String LDAP_USER_DEFAULT_ROLE_KEY = "authorization.ldap.userDefaultRole";
+  public static final String LDAP_PRIMARY_URL_KEY = 
+      "authorization.ldap.primaryUrl";
+  public static final String LDAP_SECONDARY_URL_KEY = 
+      "authorization.ldap.secondaryUrl";
+  public static final String LDAP_BASE_DN_KEY = 
+      "authorization.ldap.baseDn";
+  public static final String LDAP_BIND_ANONYMOUSLY_KEY =
+      "authorization.ldap.bindAnonymously";
+  public static final String LDAP_MANAGER_DN_KEY = 
+      "authorization.ldap.managerDn";
+  public static final String LDAP_MANAGER_PASSWORD_KEY =
+      "authorization.ldap.managerPassword";
+  public static final String LDAP_USERNAME_ATTRIBUTE_KEY = 
+      "authorization.ldap.usernameAttribute";
+  public static final String LDAP_USER_DEFAULT_ROLE_KEY =
+      "authorization.ldap.userDefaultRole";
 
   private static final String SRVR_KSTR_DIR_DEFAULT = ".";
   public static final String SRVR_CRT_NAME_DEFAULT = "ca.crt";
@@ -111,28 +123,39 @@ public class Configuration {
     this.properties = properties;
 
     configsMap = new HashMap<String, String>();
-    configsMap.put(SRVR_KSTR_DIR_KEY, properties.getProperty(SRVR_KSTR_DIR_KEY, SRVR_KSTR_DIR_DEFAULT));
-    configsMap.put(SRVR_KSTR_DIR_KEY, properties.getProperty(SRVR_KSTR_DIR_KEY, SRVR_KSTR_DIR_DEFAULT));
-    configsMap.put(SRVR_CRT_NAME_KEY, properties.getProperty(SRVR_CRT_NAME_KEY, SRVR_CRT_NAME_DEFAULT));
-    configsMap.put(SRVR_KEY_NAME_KEY, properties.getProperty(SRVR_KEY_NAME_KEY, SRVR_KEY_NAME_DEFAULT));
-    configsMap.put(KSTR_NAME_KEY, properties.getProperty(KSTR_NAME_KEY, KSTR_NAME_DEFAULT));
-    configsMap.put(SRVR_CRT_PASS_FILE_KEY, properties.getProperty(SRVR_CRT_PASS_FILE_KEY,
SRVR_CRT_PASS_FILE_DEFAULT));
-
-    configsMap.put(PASSPHRASE_ENV_KEY, properties.getProperty(PASSPHRASE_ENV_KEY, PASSPHRASE_ENV_DEFAULT));
-	configsMap.put(PASSPHRASE_KEY, System.getenv(configsMap.get(PASSPHRASE_ENV_KEY)));
-    configsMap.put(CLIENT_SECURITY_KEY, properties.getProperty(CLIENT_SECURITY_KEY, CLIENT_SECURITY_DEFAULT));
-    configsMap.put(LDAP_USER_DEFAULT_ROLE_KEY, properties.getProperty(LDAP_USER_DEFAULT_ROLE_KEY,
LDAP_USER_DEFAULT_ROLE_DEFAULT));
-    configsMap.put(RESOURCES_DIR_KEY, properties.getProperty(RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT));
+    configsMap.put(SRVR_KSTR_DIR_KEY, properties.getProperty(
+        SRVR_KSTR_DIR_KEY, SRVR_KSTR_DIR_DEFAULT));
+    configsMap.put(SRVR_KSTR_DIR_KEY, properties.getProperty(
+        SRVR_KSTR_DIR_KEY, SRVR_KSTR_DIR_DEFAULT));
+    configsMap.put(SRVR_CRT_NAME_KEY, properties.getProperty(
+        SRVR_CRT_NAME_KEY, SRVR_CRT_NAME_DEFAULT));
+    configsMap.put(SRVR_KEY_NAME_KEY, properties.getProperty(
+        SRVR_KEY_NAME_KEY, SRVR_KEY_NAME_DEFAULT));
+    configsMap.put(KSTR_NAME_KEY, properties.getProperty(
+        KSTR_NAME_KEY, KSTR_NAME_DEFAULT));
+    configsMap.put(SRVR_CRT_PASS_FILE_KEY, properties.getProperty(
+        SRVR_CRT_PASS_FILE_KEY, SRVR_CRT_PASS_FILE_DEFAULT));
+
+    configsMap.put(PASSPHRASE_ENV_KEY, properties.getProperty(
+        PASSPHRASE_ENV_KEY, PASSPHRASE_ENV_DEFAULT));
+    configsMap.put(PASSPHRASE_KEY, System.getenv(configsMap.get(
+        PASSPHRASE_ENV_KEY)));
+    configsMap.put(CLIENT_SECURITY_KEY, properties.getProperty(
+        CLIENT_SECURITY_KEY, CLIENT_SECURITY_DEFAULT));
+    configsMap.put(LDAP_USER_DEFAULT_ROLE_KEY, properties.getProperty(
+        LDAP_USER_DEFAULT_ROLE_KEY, LDAP_USER_DEFAULT_ROLE_DEFAULT));
+    configsMap.put(RESOURCES_DIR_KEY, properties.getProperty(
+        RESOURCES_DIR_KEY, RESOURCES_DIR_DEFAULT));
     try {
-        File passFile = new File(configsMap.get(SRVR_KSTR_DIR_KEY) + File.separator
-            + configsMap.get(SRVR_CRT_PASS_FILE_KEY));
-        if (passFile.exists()) {
-          String srvrCrtPass = FileUtils.readFileToString(passFile);
-          configsMap.put(SRVR_CRT_PASS_KEY, srvrCrtPass.trim());
-        } else {
-          LOG.info("Not found pass file at " + passFile);
-        }
-      } catch (IOException e) {
+      File passFile = new File(configsMap.get(SRVR_KSTR_DIR_KEY) + File.separator
+          + configsMap.get(SRVR_CRT_PASS_FILE_KEY));
+      if (passFile.exists()) {
+        String srvrCrtPass = FileUtils.readFileToString(passFile);
+        configsMap.put(SRVR_CRT_PASS_KEY, srvrCrtPass.trim());
+      } else {
+        LOG.info("Not found pass file at " + passFile);
+      }
+    } catch (IOException e) {
       e.printStackTrace();
       throw new RuntimeException("Error reading certificate password from file");
     }
@@ -211,14 +234,23 @@ public class Configuration {
   public LdapServerProperties getLdapServerProperties() {
     LdapServerProperties ldapServerProperties = new LdapServerProperties();
 
-    ldapServerProperties.setPrimaryUrl(properties.getProperty(LDAP_PRIMARY_URL_KEY, LDAP_PRIMARY_URL_DEFAULT));
-    ldapServerProperties.setSecondaryUrl(properties.getProperty(LDAP_SECONDARY_URL_KEY));
-    ldapServerProperties.setUseSsl("true".equalsIgnoreCase(properties.getProperty(LDAP_USE_SSL_KEY)));
-    ldapServerProperties.setAnonymousBind("true".equalsIgnoreCase(properties.getProperty(LDAP_BIND_ANONYMOUSLY_KEY,
LDAP_BIND_ANONYMOUSLY_DEFAULT)));
-    ldapServerProperties.setManagerDn(properties.getProperty(LDAP_MANAGER_DN_KEY));
-    ldapServerProperties.setManagerPassword(properties.getProperty(LDAP_MANAGER_PASSWORD_KEY));
-    ldapServerProperties.setBaseDN(properties.getProperty(LDAP_BASE_DN_KEY, LDAP_BASE_DN_DEFAULT));
-    ldapServerProperties.setUsernameAttribute(properties.getProperty(LDAP_USERNAME_ATTRIBUTE_KEY,
LDAP_USERNAME_ATTRIBUTE_DEFAULT));
+    ldapServerProperties.setPrimaryUrl(properties.getProperty(
+        LDAP_PRIMARY_URL_KEY, LDAP_PRIMARY_URL_DEFAULT));
+    ldapServerProperties.setSecondaryUrl(properties.getProperty(
+        LDAP_SECONDARY_URL_KEY));
+    ldapServerProperties.setUseSsl("true".equalsIgnoreCase(properties.
+        getProperty(LDAP_USE_SSL_KEY)));
+    ldapServerProperties.setAnonymousBind("true".
+        equalsIgnoreCase(properties.getProperty(LDAP_BIND_ANONYMOUSLY_KEY,
+            LDAP_BIND_ANONYMOUSLY_DEFAULT)));
+    ldapServerProperties.setManagerDn(properties.getProperty(
+        LDAP_MANAGER_DN_KEY));
+    ldapServerProperties.setManagerPassword(properties.getProperty(
+        LDAP_MANAGER_PASSWORD_KEY));
+    ldapServerProperties.setBaseDN(properties.getProperty
+        (LDAP_BASE_DN_KEY, LDAP_BASE_DN_DEFAULT));
+    ldapServerProperties.setUsernameAttribute(properties.
+        getProperty(LDAP_USERNAME_ATTRIBUTE_KEY, LDAP_USERNAME_ATTRIBUTE_DEFAULT));
 
     return ldapServerProperties;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
Tue Oct  2 05:35:12 2012
@@ -19,12 +19,11 @@
 package org.apache.ambari.server.controller;
 
 
-import com.google.inject.Guice;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.Singleton;
-import com.google.inject.persist.jpa.JpaPersistModule;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.security.CertificateManager;
@@ -42,12 +41,12 @@ import org.springframework.context.suppo
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.GenericWebApplicationContext;
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.google.inject.persist.jpa.JpaPersistModule;
+import com.sun.jersey.spi.container.servlet.ServletContainer;
 
 @Singleton
 public class AmbariServer {
@@ -62,7 +61,8 @@ public class AmbariServer {
   final URL warUrl = this.getClass().getClassLoader().getResource(WEB_APP_DIR);
   final String warUrlString = warUrl.toExternalForm();
   final String CONTEXT_PATH = "/";
-  final String SPRING_CONTEXT_LOCATION = "classpath:/webapp/WEB-INF/spring-security.xml";
+  final String SPRING_CONTEXT_LOCATION = 
+      "classpath:/webapp/WEB-INF/spring-security.xml";
 
   @Inject
   Configuration configs;
@@ -75,13 +75,17 @@ public class AmbariServer {
     server = new Server();
 
     try {
-      ClassPathXmlApplicationContext parentSpringAppContext = new ClassPathXmlApplicationContext();
+      ClassPathXmlApplicationContext parentSpringAppContext = 
+          new ClassPathXmlApplicationContext();
       parentSpringAppContext.refresh();
-      ConfigurableListableBeanFactory factory = parentSpringAppContext.getBeanFactory();
-      factory.registerSingleton("guiceInjector", injector); //Spring Security xml config
depends on this Bean
+      ConfigurableListableBeanFactory factory = parentSpringAppContext.
+          getBeanFactory();
+      factory.registerSingleton("guiceInjector", injector); 
+      //Spring Security xml config depends on this Bean
 
       String[] contextLocations = {SPRING_CONTEXT_LOCATION};
-      ClassPathXmlApplicationContext springAppContext = new ClassPathXmlApplicationContext(contextLocations,
parentSpringAppContext);
+      ClassPathXmlApplicationContext springAppContext = new 
+          ClassPathXmlApplicationContext(contextLocations, parentSpringAppContext);
 
       WebAppContext webAppContext = new WebAppContext(warUrlString, CONTEXT_PATH);
 
@@ -89,7 +93,9 @@ public class AmbariServer {
       springWebAppContext.setServletContext(webAppContext.getServletContext());
       springWebAppContext.setParent(springAppContext);
 
-      webAppContext.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
springWebAppContext);
+      webAppContext.getServletContext().setAttribute(
+          WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, 
+          springWebAppContext);
 
 
       server.setHandler(webAppContext);
@@ -108,7 +114,8 @@ public class AmbariServer {
       sslConnectorTwoWay.setPort(CLIENT_TWO_WAY);
 
       Map<String, String> configsMap = configs.getConfigsMap();
-      String keystore = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + File.separator
+ configsMap.get(Configuration.KSTR_NAME_KEY);
+      String keystore = configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + 
+          File.separator + configsMap.get(Configuration.KSTR_NAME_KEY);
       String srvrCrtPass = configsMap.get(Configuration.SRVR_CRT_PASS_KEY);
 
       sslConnectorTwoWay.setKeystore(keystore);
@@ -202,7 +209,8 @@ public class AmbariServer {
   }
 
   public static void main(String[] args) throws IOException {
-    Injector injector = Guice.createInjector(new ControllerModule(), new JpaPersistModule(PERSISTENCE_PROVIDER));
+    Injector injector = Guice.createInjector(new ControllerModule(), 
+        new JpaPersistModule(PERSISTENCE_PROVIDER));
 
     try {
       LOG.info("Getting the controller");

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
Tue Oct  2 05:35:12 2012
@@ -16,12 +16,17 @@
  * limitations under the License.
  */
 package org.apache.ambari.server.controller;
+import org.apache.ambari.server.actionmanager.ActionDBAccessor;
+import org.apache.ambari.server.actionmanager.ActionDBInMemoryImpl;
 import org.apache.ambari.server.agent.rest.AgentResource;
 import org.apache.ambari.server.resources.api.rest.GetResource;
 import org.apache.ambari.server.security.unsecured.rest.CertificateDownload;
 import org.apache.ambari.server.security.unsecured.rest.CertificateSign;
+import org.apache.ambari.server.state.live.Clusters;
+import org.apache.ambari.server.state.live.ClustersImpl;
 
 import com.google.inject.AbstractModule;
+import com.google.inject.name.Names;
 
 /**
  * Used for injection purposes.
@@ -36,5 +41,9 @@ public class ControllerModule extends Ab
     requestStaticInjection(CertificateDownload.class);
     requestStaticInjection(CertificateSign.class);
     requestStaticInjection(GetResource.class);
+    bind(Clusters.class).to(ClustersImpl.class);
+    bind(ActionDBAccessor.class).to(ActionDBInMemoryImpl.class);
+    bindConstant().annotatedWith(Names.named("schedulerSleeptime")).to(10L);
+    bindConstant().annotatedWith(Names.named("actionTimeout")).to(10L);
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java?rev=1392747&r1=1392746&r2=1392747&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/security/CertificateManager.java
Tue Oct  2 05:35:12 2012
@@ -44,11 +44,19 @@ public class CertificateManager {
   private static final Log LOG = LogFactory.getLog(CertificateManager.class);
 	
 	
-  private static final String GEN_SRVR_KEY = "openssl genrsa -des3 -passout pass:{0} -out
{1}/{2} 4096 ";
-  private static final String GEN_SRVR_REQ = "openssl req -passin pass:{0} -new -key {1}/{2}
-out {1}/{3} -batch";
-  private static final String SIGN_SRVR_CRT = "openssl x509 -passin pass:{0} -req -days 365
-in {1}/{3} -signkey {1}/{2} -out {1}/{3} \n";
-  private static final String EXPRT_KSTR = "openssl pkcs12 -export -in {1}/{3} -inkey {1}/{2}
-certfile {1}/{3} -out {1}/{4} -password pass:{0} -passin pass:{0} \n";
-  private static final String SIGN_AGENT_CRT = "openssl ca -config {0}/ca.config -in {0}/{1}
-out {0}/{2} -batch -passin pass:{3} -keyfile {0}/{4} -cert {0}/{5}"; /**
+  private static final String GEN_SRVR_KEY = "openssl genrsa -des3 " +
+  		"-passout pass:{0} -out {1}/{2} 4096 ";
+  private static final String GEN_SRVR_REQ = "openssl req -passin pass:{0} " +
+  		"-new -key {1}/{2} -out {1}/{3} -batch";
+  private static final String SIGN_SRVR_CRT = "openssl x509 " +
+  		"-passin pass:{0} -req -days 365 -in {1}/{3} -signkey {1}/{2} " +
+  		"-out {1}/{3} \n";
+  private static final String EXPRT_KSTR = "openssl pkcs12 -export" +
+  		" -in {1}/{3} -inkey {1}/{2} -certfile {1}/{3} -out {1}/{4} " +
+  		"-password pass:{0} -passin pass:{0} \n";
+  private static final String SIGN_AGENT_CRT = "openssl ca -config " +
+  		"{0}/ca.config -in {0}/{1} -out {0}/{2} -batch -passin pass:{3} " +
+  		"-keyfile {0}/{4} -cert {0}/{5}"; /**
    * Verify that root certificate exists, generate it otherwise.
    */
   public void initRootCert() {
@@ -60,7 +68,7 @@ public class CertificateManager {
 		
 	if (!certExists) {
       generateServerCertificate();
-	}
+	  }
   }
 	
   /**
@@ -87,7 +95,8 @@ public class CertificateManager {
       Process process = null;
       try {
         process = Runtime.getRuntime().exec(command);
-        BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
+        BufferedReader br = new BufferedReader(new InputStreamReader(
+            process.getInputStream()));
 
         while ((line = br.readLine()) != null) {
           LOG.info(line);
@@ -139,7 +148,8 @@ public class CertificateManager {
    */
   public String getServerCert() {
     Map<String, String> configsMap = configs.getConfigsMap();
-    File certFile = new File(configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + File.separator
+ configsMap.get(Configuration.SRVR_CRT_NAME_KEY));
+    File certFile = new File(configsMap.get(Configuration.SRVR_KSTR_DIR_KEY) + 
+        File.separator + configsMap.get(Configuration.SRVR_CRT_NAME_KEY));
     String srvrCrtContent = null;
     try {
       srvrCrtContent = FileUtils.readFileToString(certFile);
@@ -160,7 +170,8 @@ public class CertificateManager {
 
 
 
-    String passphraseSrvr = configs.getConfigsMap().get(Configuration.PASSPHRASE_KEY);
+    String passphraseSrvr = configs.getConfigsMap().get(Configuration.
+        PASSPHRASE_KEY);
 
     System.out.println(passphraseSrvr);
     System.out.println(passphraseAgent);
@@ -179,7 +190,8 @@ public class CertificateManager {
     String agentCrtName = agentHostname + ".crt";
 
 
-    File agentCrtReqFile = new File(srvrKstrDir + File.separator + agentCrtReqName);
+    File agentCrtReqFile = new File(srvrKstrDir + File.separator + 
+        agentCrtReqName);
     try {
 		FileUtils.writeStringToFile(agentCrtReqFile, agentCrtReqContent);
 	} catch (IOException e1) {



Mime
View raw message