cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: updated refs/heads/master to 5c801a1
Date Fri, 27 Nov 2015 18:42:05 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 806807f8e -> 5c801a1d2


Fix NuageVsp errors for build-master-slowbuild


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

Branch: refs/heads/master
Commit: 453333cc67ecc490d432383efc36c4d9b9544f2c
Parents: 45fa8ff
Author: Nick Livens <nick.livens@nuagenetworks.net>
Authored: Thu Nov 26 09:08:40 2015 +0100
Committer: Nick Livens <nick.livens@nuagenetworks.net>
Committed: Thu Nov 26 09:08:40 2015 +0100

----------------------------------------------------------------------
 .../network/manager/NuageVspManagerImpl.java    |  6 +--
 .../network/resource/NuageVspResource.java      |  4 +-
 .../src/com/cloud/util/NuageVspUtil.java        | 14 +++++++
 .../test/com/cloud/util/NuageVspUtilTest.java   | 43 ++++++++++++++++++++
 4 files changed, 62 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/453333cc/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
index 4c0b0f7..ce2a363 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/manager/NuageVspManagerImpl.java
@@ -88,6 +88,7 @@ import com.cloud.resource.ResourceManager;
 import com.cloud.resource.ResourceState;
 import com.cloud.user.AccountManager;
 import com.cloud.user.DomainManager;
+import com.cloud.util.NuageVspUtil;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.Transaction;
@@ -112,7 +113,6 @@ import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.framework.messagebus.MessageSubscriber;
 import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
-import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.log4j.Logger;
 
@@ -250,7 +250,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
             if (0 == port) {
                 port = 8443;
             }
-            String cmsUserPasswordBase64 = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.encodeBase64(cmd.getPassword().getBytes()));
+            String cmsUserPasswordBase64 = NuageVspUtil.encodePassword(cmd.getPassword());
             String retryCount = String.valueOf(MoreObjects.firstNonNull(cmd.getApiRetryCount(),
clientDefaults.get("DEFAULT_API_RETRY_COUNT")));
             String retryInterval = String.valueOf(MoreObjects.firstNonNull(cmd.getApiRetryInterval(),
clientDefaults.get("DEFAULT_API_RETRY_INTERVAL")));
             NuageVspResource.Configuration resourceConfiguration = new NuageVspResource.Configuration()
@@ -355,7 +355,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
         }
 
         if (!Strings.isNullOrEmpty(command.getPassword())) {
-            String encodedNewPassword = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.encodeBase64(command.getPassword().getBytes()));
+            String encodedNewPassword = NuageVspUtil.encodePassword(command.getPassword());
             if (!encodedNewPassword.equals(resourceConfiguration.cmsUserPassword())) {
                 resourceConfiguration.cmsUserPassword(encodedNewPassword);
                 updateRequired = true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/453333cc/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
index c89ea15..8e14237 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/network/resource/NuageVspResource.java
@@ -50,6 +50,7 @@ import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand;
 import com.cloud.agent.api.sync.SyncVspCommand;
 import com.cloud.host.Host;
 import com.cloud.resource.ServerResource;
+import com.cloud.util.NuageVspUtil;
 import com.cloud.utils.StringUtils;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -60,7 +61,6 @@ import net.nuage.vsp.acs.client.NuageVspElementClient;
 import net.nuage.vsp.acs.client.NuageVspGuruClient;
 import net.nuage.vsp.acs.client.NuageVspManagerClient;
 import net.nuage.vsp.acs.client.NuageVspSyncClient;
-import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.log4j.Logger;
 
@@ -189,7 +189,7 @@ public class NuageVspResource extends ManagerBase implements ServerResource
{
 
         _relativePath = new StringBuffer().append("https://").append(_hostName).append(":").append(port).append(apiRelativePath).toString();
 
-        String cmsUserPass = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.decodeBase64(cmsUserPassBase64));
+        String cmsUserPass = NuageVspUtil.decodePassword(cmsUserPassBase64);
         _cmsUserInfo = new String[] {CMS_USER_ENTEPRISE_NAME, cmsUser, cmsUserPass};
 
         _nuageVspCmsId = (String)params.get(NUAGE_VSP_CMS_ID);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/453333cc/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
index 143a741..2300289 100644
--- a/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
+++ b/plugins/network-elements/nuage-vsp/src/com/cloud/util/NuageVspUtil.java
@@ -22,7 +22,9 @@ package com.cloud.util;
 import com.cloud.network.Network;
 import com.cloud.network.manager.NuageVspManager;
 import com.cloud.offering.NetworkOffering;
+import com.cloud.utils.StringUtils;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.commons.codec.binary.Base64;
 
 public class NuageVspUtil {
 
@@ -37,4 +39,16 @@ public class NuageVspUtil {
         }
         return configDao.getValue(configKey);
     }
+
+    public static String encodePassword(String originalPassword) {
+        byte[] passwordBytes = originalPassword.getBytes(StringUtils.getPreferredCharset());
+        byte[] encodedPasswordBytes = Base64.encodeBase64(passwordBytes);
+        return new String(encodedPasswordBytes, StringUtils.getPreferredCharset());
+    }
+
+    public static String decodePassword(String encodedPassword) {
+        byte[] encodedPasswordBytes = encodedPassword.getBytes(StringUtils.getPreferredCharset());
+        byte[] passwordBytes = Base64.decodeBase64(encodedPasswordBytes);
+        return new String(passwordBytes, StringUtils.getPreferredCharset());
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/453333cc/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspUtilTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspUtilTest.java
b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspUtilTest.java
new file mode 100644
index 0000000..6f1414a
--- /dev/null
+++ b/plugins/network-elements/nuage-vsp/test/com/cloud/util/NuageVspUtilTest.java
@@ -0,0 +1,43 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.util;
+
+import org.junit.Test;
+
+import static junit.framework.Assert.assertEquals;
+
+public class NuageVspUtilTest {
+
+    @Test
+    public void testEncodePassword() {
+        String password = "Password!@#$%^&*()-_{}?><";
+        String expectedEncodedPassword = "UGFzc3dvcmQhQCMkJV4mKigpLV97fT8+PA==";
+        String encodedPassword = NuageVspUtil.encodePassword(password);
+        assertEquals(expectedEncodedPassword, encodedPassword);
+    }
+
+    @Test
+    public void testDecodePassword() {
+        String password = "UGFzc3dvcmQhQCMkJV4mKigpLV97fT8+PA==";
+        String expectedDecodedPassword = "Password!@#$%^&*()-_{}?><";
+        String decodedPassword = NuageVspUtil.decodePassword(password);
+        assertEquals(expectedDecodedPassword, decodedPassword);
+    }
+}


Mime
View raw message