You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/03/30 15:59:55 UTC

[18/50] brooklyn-server git commit: Generate random password if no securiyt provider

Generate random password if no securiyt provider

Replicate classical launcher behaviour. Note that when accessing from localhost username will still be requested, but will accept any provider.


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

Branch: refs/heads/master
Commit: b7813d9df68faa91ceb68a2d591fe986401de6a6
Parents: b70c2b0
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Thu Mar 17 16:00:08 2016 +0200
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Thu Mar 17 16:00:08 2016 +0200

----------------------------------------------------------------------
 karaf/init/pom.xml                               |  5 +++++
 .../brooklyn/launcher/osgi/OsgiLauncher.java     | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b7813d9d/karaf/init/pom.xml
----------------------------------------------------------------------
diff --git a/karaf/init/pom.xml b/karaf/init/pom.xml
index 6f2ac86..710d2e4 100644
--- a/karaf/init/pom.xml
+++ b/karaf/init/pom.xml
@@ -44,6 +44,11 @@
             <artifactId>brooklyn-launcher-common</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.brooklyn</groupId>
+            <artifactId>brooklyn-rest-resources</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
         <dependency>
             <groupId>org.testng</groupId>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b7813d9d/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
----------------------------------------------------------------------
diff --git a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
index d08504d..15c19de 100644
--- a/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
+++ b/karaf/init/src/main/java/org/apache/brooklyn/launcher/osgi/OsgiLauncher.java
@@ -17,12 +17,17 @@ package org.apache.brooklyn.launcher.osgi;
 
 import javax.annotation.Nullable;
 
+import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.api.mgmt.ha.HighAvailabilityMode;
 import org.apache.brooklyn.core.BrooklynVersionService;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
 import org.apache.brooklyn.core.mgmt.persist.PersistMode;
 import org.apache.brooklyn.launcher.common.BasicLauncher;
+import org.apache.brooklyn.rest.BrooklynWebConfig;
+import org.apache.brooklyn.rest.security.provider.BrooklynUserWithRandomPasswordSecurityProvider;
 import org.apache.brooklyn.util.time.Duration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Initializer for brooklyn-core when running in an OSGi environment.
@@ -30,6 +35,7 @@ import org.apache.brooklyn.util.time.Duration;
  * Temporarily here; should be totally contained in blueprint beans' init-methods.
  */
 public class OsgiLauncher extends BasicLauncher<OsgiLauncher> {
+    private static final Logger LOG = LoggerFactory.getLogger(OsgiLauncher.class);
 
     private BrooklynVersionService brooklynVersion;
 
@@ -103,4 +109,17 @@ public class OsgiLauncher extends BasicLauncher<OsgiLauncher> {
         copyPersistedState(destinationDir);
     }
 
+    @Override
+    protected void startingUp() {
+        super.startingUp();
+        ManagementContext managementContext = getManagementContext();
+        BrooklynProperties brooklynProperties = (BrooklynProperties) managementContext.getConfig();
+        if (BrooklynWebConfig.hasNoSecurityOptions(brooklynProperties)) {
+            LOG.info("No security provider options specified. Define a security provider or users to prevent a random password being created and logged.");
+            brooklynProperties.put(
+                    BrooklynWebConfig.SECURITY_PROVIDER_INSTANCE,
+                    new BrooklynUserWithRandomPasswordSecurityProvider(managementContext));
+        }
+    }
+
 }