You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/06/12 12:26:08 UTC

[1/3] git commit: updated refs/heads/4.4 to 40d3503

Repository: cloudstack
Updated Branches:
  refs/heads/4.4 b24f5355f -> 40d350376


CLOUDSTACK-6864: UploadSSlCert API requires double encoding of URL params

(cherry picked from commit c5ee5ad5c828d9f0b128e3d7280a30dcf717e045)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/23b7993d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/23b7993d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/23b7993d

Branch: refs/heads/4.4
Commit: 23b7993d581563108199c9930827c042245fb8c5
Parents: b24f535
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Mon Jun 9 12:24:30 2014 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Jun 12 12:23:52 2014 +0200

----------------------------------------------------------------------
 .../cloudstack/network/lb/CertServiceImpl.java  | 25 ++++----
 .../cloudstack/network/lb/CertServiceTest.java  | 62 ++++++++++----------
 2 files changed, 41 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/23b7993d/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java b/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
index ba71d63..c2c155d 100644
--- a/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
+++ b/server/src/org/apache/cloudstack/network/lb/CertServiceImpl.java
@@ -18,8 +18,6 @@ package org.apache.cloudstack.network.lb;
 
 import java.io.IOException;
 import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.security.KeyPair;
@@ -53,18 +51,17 @@ import javax.crypto.NoSuchPaddingException;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.log4j.Logger;
-import org.bouncycastle.jce.provider.BouncyCastleProvider;
-import org.bouncycastle.openssl.PEMReader;
-import org.bouncycastle.openssl.PasswordFinder;
-
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
 import org.apache.cloudstack.api.command.user.loadbalancer.ListSslCertsCmd;
 import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
 import org.apache.cloudstack.api.response.SslCertResponse;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.commons.io.IOUtils;
+import org.apache.log4j.Logger;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.bouncycastle.openssl.PEMReader;
+import org.bouncycastle.openssl.PasswordFinder;
 
 import com.cloud.event.ActionEvent;
 import com.cloud.event.EventTypes;
@@ -109,10 +106,10 @@ public class CertServiceImpl implements CertService {
     public SslCertResponse uploadSslCert(UploadSslCertCmd certCmd) {
         try {
 
-            String cert = URLDecoder.decode(certCmd.getCert(), "UTF-8");
-            String key = URLDecoder.decode(certCmd.getKey(), "UTF-8");
+            String cert = certCmd.getCert();
+            String key = certCmd.getKey();
             String password = certCmd.getPassword();
-            String chain = certCmd.getChain() == null ? null : URLDecoder.decode(certCmd.getChain(), "UTF-8");
+            String chain = certCmd.getChain();
 
             validate(cert, key, password, chain);
             s_logger.debug("Certificate Validation succeeded");
@@ -127,8 +124,8 @@ public class CertServiceImpl implements CertService {
 
             return createCertResponse(certVO, null);
 
-        } catch (UnsupportedEncodingException e) {
-            throw new CloudRuntimeException("Error decoding certificate data");
+        } catch (Exception e) {
+            throw new CloudRuntimeException("Error parsing certificate data " + e.getMessage());
         }
 
     }
@@ -429,7 +426,7 @@ public class CertServiceImpl implements CertService {
         try {
             return (Certificate)certPem.readObject();
         } catch (Exception e) {
-            throw new InvalidParameterValueException("Invalid Certificate format. Expected X509 certificate");
+            throw new InvalidParameterValueException("Invalid Certificate format. Expected X509 certificate. Failed due to " + e.getMessage());
         } finally {
             IOUtils.closeQuietly(certPem);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/23b7993d/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
----------------------------------------------------------------------
diff --git a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
index a67a9ab..038845d 100644
--- a/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
+++ b/server/test/org/apache/cloudstack/network/lb/CertServiceTest.java
@@ -27,21 +27,19 @@ import static org.mockito.Mockito.when;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
-import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.UUID;
 
+import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
+import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
+import org.apache.cloudstack.context.CallContext;
 import org.junit.After;
 import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-import org.apache.cloudstack.api.command.user.loadbalancer.DeleteSslCertCmd;
-import org.apache.cloudstack.api.command.user.loadbalancer.UploadSslCertCmd;
-import org.apache.cloudstack.context.CallContext;
-
 import com.cloud.network.dao.LoadBalancerCertMapDao;
 import com.cloud.network.dao.LoadBalancerCertMapVO;
 import com.cloud.network.dao.LoadBalancerVO;
@@ -101,9 +99,9 @@ public class CertServiceTest {
         String chainFile = getClass().getResource("/certs/root_chain.crt").getFile();
         String password = "user";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
-        String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
+        String chain = readFileToString(new File(chainFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -153,8 +151,8 @@ public class CertServiceTest {
         String keyFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile();
         String password = "test";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -199,8 +197,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
         String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -239,9 +237,9 @@ public class CertServiceTest {
         String chainFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
         String password = "user";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
-        String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
+        String chain = readFileToString(new File(chainFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -291,9 +289,9 @@ public class CertServiceTest {
         String chainFile = getClass().getResource("/certs/rsa_ca_signed2.crt").getFile();
         String password = "user";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
-        String chain = URLEncoder.encode(readFileToString(new File(chainFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
+        String chain = readFileToString(new File(chainFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -343,8 +341,8 @@ public class CertServiceTest {
         String keyFile = getClass().getResource("/certs/rsa_ca_signed.key").getFile();
         String password = "user";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -388,8 +386,8 @@ public class CertServiceTest {
         String keyFile = getClass().getResource("/certs/rsa_self_signed_with_pwd.key").getFile();
         String password = "bad_password";
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -432,8 +430,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
         String keyFile = getClass().getResource("/certs/rsa_random_pkey.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -471,8 +469,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/rsa_self_signed.crt").getFile();
         String keyFile = getClass().getResource("/certs/dsa_self_signed.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -511,8 +509,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/expired_cert.crt").getFile();
         String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -550,8 +548,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/non_x509_pem.crt").getFile();
         String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 
@@ -590,8 +588,8 @@ public class CertServiceTest {
         String certFile = getClass().getResource("/certs/bad_format_cert.crt").getFile();
         String keyFile = getClass().getResource("/certs/rsa_self_signed.key").getFile();
 
-        String cert = URLEncoder.encode(readFileToString(new File(certFile)), "UTF-8");
-        String key = URLEncoder.encode(readFileToString(new File(keyFile)), "UTF-8");
+        String cert = readFileToString(new File(certFile));
+        String key = readFileToString(new File(keyFile));
 
         CertServiceImpl certService = new CertServiceImpl();
 


[3/3] git commit: updated refs/heads/4.4 to 40d3503

Posted by da...@apache.org.
CLOUDSTACK-6812: Do not allow edit of storage.overprovision.factor for non supported types

(cherry picked from commit f14f36170e94c0184ade28a50226b17d25ecf57c)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/40d35037
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/40d35037
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/40d35037

Branch: refs/heads/4.4
Commit: 40d35037601f8299e438a8df5e165312b02b62e0
Parents: 9771e79
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Mon Jun 9 18:02:48 2014 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Jun 12 12:25:55 2014 +0200

----------------------------------------------------------------------
 .../com/cloud/configuration/ConfigurationManagerImpl.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/40d35037/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 1549e12..d2f5af3 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -38,8 +38,8 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import com.cloud.storage.StorageManager;
-import org.apache.log4j.Logger;
 
+import org.apache.log4j.Logger;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.affinity.AffinityGroup;
 import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -178,6 +178,7 @@ import com.cloud.service.ServiceOfferingVO;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.service.dao.ServiceOfferingDetailsDao;
 import com.cloud.storage.DiskOfferingVO;
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.test.IPRangeConfig;
 import com.cloud.user.Account;
@@ -471,6 +472,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 if (pool == null) {
                     throw new InvalidParameterValueException("unable to find storage pool by id " + resourceId);
                 }
+                if(name.equals(CapacityManager.StorageOverprovisioningFactor.key())) {
+                    if(pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.VMFS) {
+                        throw new InvalidParameterValueException("Unable to update  storage pool with id " + resourceId + ". Overprovision not supported for " + pool.getPoolType());
+                    }
+                }
                 _storagePoolDetailsDao.addDetail(resourceId, name, value, true);
 
                 break;


[2/3] git commit: updated refs/heads/4.4 to 40d3503

Posted by da...@apache.org.
CLOUDSTACK-6654: Configkey parameters are not validated

(cherry picked from commit 5bcd017de6f421a6125406120b39fb8602276dc7)


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/9771e79b
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/9771e79b
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/9771e79b

Branch: refs/heads/4.4
Commit: 9771e79b1bb9662fee4b95dd59432a9d77d42cd9
Parents: 23b7993
Author: Saksham Srivastava <sa...@citrix.com>
Authored: Tue Jun 10 18:27:54 2014 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Jun 12 12:25:14 2014 +0200

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java  | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9771e79b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 0dc067a..1549e12 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -701,12 +701,19 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                 return "Invalid scope id provided for the parameter " + name;
             }
         }
+        Class<?> type = null;
         Config c = Config.getConfig(name);
         if (c == null) {
-            s_logger.warn("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot?");
-            return null;
+            s_logger.warn("Did not find configuration " + name + " in Config.java. Perhaps moved to ConfigDepot");
+            ConfigKey<?> configKey = _configDepot.get(name);
+            if(configKey == null) {
+                s_logger.warn("Did not find configuration " + name + " in ConfigDepot too.");
+                return null;
+            }
+            type = configKey.type();
+        } else {
+            type = c.getType();
         }
-        Class<?> type = c.getType();
 
         if (value == null) {
             if (type.equals(Boolean.class)) {
@@ -765,6 +772,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
         }
 
+        if(c == null ) {
+            //range validation has to be done per case basis, for now
+            //return in case of Configkey parameters
+            return null;
+        }
+
         String range = c.getRange();
         if (range == null) {
             return null;