mirror of https://github.com/apache/cloudstack.git
Merge pull request #1092 from nlivens/master
Fix NuageVsp errors for build-master-slowbuild * pr/1092: Fix NuageVsp errors for build-master-slowbuild Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
commit
5c801a1d2b
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue