brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [27/50] brooklyn-library git commit: ProxySslConfig is able to deal the same with empty string, white space strings, and null strings in a similar matter. So the fields don't need to be null but can also be empty strings to let the nginx ssl configuratio
Date Mon, 01 Feb 2016 17:46:30 GMT
ProxySslConfig is able to deal the same with empty string, white space strings, and null strings
in a similar matter. So the fields don't need to be null but can also be empty strings to
let the nginx ssl configuration still work correctly. Also renamed the ProxySslConfig sourceurl
fields so that they are in line with the destination fields


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

Branch: refs/heads/0.4.0
Commit: 3192fb8b6ba7fa9327fe925bb00e1adfe40b4aa6
Parents: 4eff322
Author: Peter Veentjer <peter.veentjer@cloudsoft.com>
Authored: Tue Oct 9 07:57:16 2012 +0300
Committer: Peter Veentjer <peter.veentjer@cloudsoft.com>
Committed: Tue Oct 9 07:57:16 2012 +0300

----------------------------------------------------------------------
 .../brooklyn/entity/proxy/ProxySslConfig.groovy | 14 ++++++------
 .../entity/proxy/nginx/NginxController.groovy   | 24 +++++++++++---------
 .../nginx/NginxHttpsSslIntegrationTest.groovy   |  4 +++-
 3 files changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/3192fb8b/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.groovy b/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.groovy
index e7f75f3..0e1fb92 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.groovy
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.groovy
@@ -22,15 +22,15 @@ public class ProxySslConfig implements Serializable {
      *  (however it will not currently merge multiple certificates.
      *  if conflicting certificates are attempted to be installed nginx will complain.) 
      */
-    String sourceCertificateUrl;
+    String certificateSourceUrl;
 
-    String sourceKeyUrl;
+    String keySourceUrl;
 
     /**
      * Sets the ssl_certificate path to be used within the generated LoadBalancer configuration.
If set to null,
      * Brooklyn will use an auto generated path.
      *
-     * If sourceCertificateUrl, then Brooklyn will copy the certificate the certificateDestination.
+     * If certificateSourceUrl, then Brooklyn will copy the certificate the certificateDestination.
      *
      * Setting this field is useful if there is a certificate on the nginx machine you want
to make use of.
      */
@@ -40,7 +40,7 @@ public class ProxySslConfig implements Serializable {
      * Sets the ssl_certificate_key path to be used within the generated LoadBalancer configuration.
If set to null,
      * Brooklyn will use an auto generated path.
      *
-     * If sourceKeyUrl, then Brooklyn will copy the certificate the keyDestination.
+     * If keySourceUrl, then Brooklyn will copy the certificate the keyDestination.
      *
      * Setting this field is useful if there is a certificate_key on the nginx machine you
want to make use of.
      */
@@ -57,7 +57,7 @@ public class ProxySslConfig implements Serializable {
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(sourceCertificateUrl, sourceKeyUrl, certificateDestination,
keyDestination, reuseSessions, targetIsSsl);
+        return Objects.hashCode(certificateSourceUrl, keySourceUrl, certificateDestination,
keyDestination, reuseSessions, targetIsSsl);
     }
 
     @Override
@@ -70,10 +70,10 @@ public class ProxySslConfig implements Serializable {
             return false;
         ProxySslConfig other = (ProxySslConfig) obj;
 
-        return Objects.equal(sourceCertificateUrl, other.sourceCertificateUrl) &&
+        return Objects.equal(certificateSourceUrl, other.certificateSourceUrl) &&
                Object.equals(certificateDestination, other.certificateDestination) &&
                Object.equals(keyDestination, other.keyDestination) &&
-                Objects.equal(sourceKeyUrl, other.sourceKeyUrl) &&
+                Objects.equal(keySourceUrl, other.keySourceUrl) &&
                 Objects.equal(reuseSessions, other.reuseSessions) &&
                 Objects.equal(targetIsSsl, other.targetIsSsl);
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/3192fb8b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
index 031ab70..884ff15 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/nginx/NginxController.groovy
@@ -25,6 +25,8 @@ import com.google.common.collect.Iterables
 import com.google.common.collect.LinkedHashMultimap
 import com.google.common.collect.Multimap
 
+import brooklyn.util.text.Strings
+
 /**
  * An entity that represents an Nginx proxy (e.g. for routing requests to servers in a cluster).
  * <p>
@@ -173,17 +175,17 @@ public class NginxController extends AbstractController {
 
         NginxSshDriver driver = (NginxSshDriver) getDriver();
 
-        if (ssl.sourceCertificateUrl != null) {
+        if (!Strings.isEmpty(ssl.certificateSourceUrl)) {
             String certificateDestination = ssl.certificateDestination == null ? driver.getRunDir()
+ "/conf/" + id + ".crt" : ssl.certificateDestination;
             driver.machine.copyTo(permissions: "0400",
-                    new ResourceUtils(this).getResourceFromUrl(ssl.sourceCertificateUrl),
+                    new ResourceUtils(this).getResourceFromUrl(ssl.certificateSourceUrl),
                     certificateDestination);
         }
 
-        if (ssl.sourceKeyUrl != null) {
+        if (!Strings.isEmpty(ssl.keySourceUrl)) {
             String keyDestination = ssl.keyDestination == null ? driver.getRunDir() + "/conf/"
+ id + ".key" : ssl.keyDestination;
             driver.machine.copyTo(permissions: "0400",
-                    new ResourceUtils(this).getResourceFromUrl(ssl.sourceKeyUrl),
+                    new ResourceUtils(this).getResourceFromUrl(ssl.keySourceUrl),
                     keyDestination);
         }
 
@@ -347,8 +349,8 @@ public class NginxController extends AbstractController {
     }
 
     void verifyConfig(ProxySslConfig proxySslConfig) {
-        if(proxySslConfig.certificateDestination == null && proxySslConfig.sourceCertificateUrl
== null){
-            throw new IllegalStateException("ProxySslConfig can't have a null certificateDestination
and null sourceCertificateUrl. One or both need to be set")
+          if(Strings.isEmpty(proxySslConfig.certificateDestination) && Strings.isEmpty(proxySslConfig.certificateSourceUrl)){
+            throw new IllegalStateException("ProxySslConfig can't have a null certificateDestination
and null certificateSourceUrl. One or both need to be set")
         }
     }
 
@@ -365,19 +367,19 @@ public class NginxController extends AbstractController {
         }
         if (certificateBlock) {
             String cert;
-            if (ssl.certificateDestination != null) {
-                cert = ssl.certificateDestination;
-            } else {
+            if (Strings.isEmpty(ssl.certificateDestination)) {
                 cert = "" + id + ".crt";
+            } else {
+                cert = ssl.certificateDestination;
             }
 
             out.append(prefix);
             out.append("ssl_certificate " + cert + ";\n");
 
             String key;
-            if (ssl.keyDestination != null) {
+            if (!Strings.isEmpty(ssl.keyDestination)) {
                 key = ssl.keyDestination;
-            } else if (ssl.sourceKeyUrl != null) {
+            } else if (!Strings.isEmpty(ssl.keySourceUrl)) {
                 key = "" + id + ".key";
             } else {
                 key = null;

http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/3192fb8b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
index 7b38635..2cb5433 100644
--- a/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
+++ b/software/webapp/src/test/java/brooklyn/entity/proxy/nginx/NginxHttpsSslIntegrationTest.groovy
@@ -55,7 +55,9 @@ public class NginxHttpsSslIntegrationTest {
         cluster = new DynamicCluster(owner:app, factory:template, initialSize:1)
         cluster.setConfig(JavaWebAppService.ROOT_WAR, WAR_URL)
         
-        ProxySslConfig ssl = new ProxySslConfig(sourceCertificateUrl:CERTIFICATE_URL, sourceKeyUrl:KEY_URL);
+        ProxySslConfig ssl = new ProxySslConfig(
+                certificateSourceUrl:CERTIFICATE_URL,
+                keySourceUrl:KEY_URL);
         nginx = new NginxController(app,
                 sticky: false,
                 cluster: cluster,


Mime
View raw message