mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Removed Base64 file and use the apache version
This commit is contained in:
parent
1d3a443237
commit
a6a864a1a8
@ -1,22 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!--
|
|
||||||
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.
|
|
||||||
-->
|
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
<classpathentry kind="src" path="test"/>
|
<classpathentry kind="src" path="test"/>
|
||||||
|
|||||||
@ -241,7 +241,7 @@
|
|||||||
<available file="${setup.db.dir}/override/templates.sql" />
|
<available file="${setup.db.dir}/override/templates.sql" />
|
||||||
</condition>
|
</condition>
|
||||||
|
|
||||||
<echo message="deploydb ${server-setup.file} ${templates.file} ${DBROOTPW}" />
|
<echo message="${db.scripts.dir}\\deploy-db-dev.sh ${server-setup.file} ${templates.file} ${DBROOTPW}" />
|
||||||
<exec dir="${db.scripts.dir}" executable="bash" failonerror="true">
|
<exec dir="${db.scripts.dir}" executable="bash" failonerror="true">
|
||||||
<arg value="deploy-db-dev.sh" />
|
<arg value="deploy-db-dev.sh" />
|
||||||
<arg value="${server-setup.file}" />
|
<arg value="${server-setup.file}" />
|
||||||
|
|||||||
@ -53,6 +53,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.http.ConnectionClosedException;
|
import org.apache.http.ConnectionClosedException;
|
||||||
import org.apache.http.HttpException;
|
import org.apache.http.HttpException;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
@ -112,7 +113,6 @@ import com.cloud.utils.component.PluggableService;
|
|||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
import com.cloud.utils.db.SearchCriteria;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.encoding.Base64;
|
|
||||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||||
import com.cloud.uuididentity.dao.IdentityDao;
|
import com.cloud.uuididentity.dao.IdentityDao;
|
||||||
|
|
||||||
@ -751,7 +751,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
mac.init(keySpec);
|
mac.init(keySpec);
|
||||||
mac.update(unsignedRequest.getBytes());
|
mac.update(unsignedRequest.getBytes());
|
||||||
byte[] encryptedBytes = mac.doFinal();
|
byte[] encryptedBytes = mac.doFinal();
|
||||||
String computedSignature = Base64.encodeBytes(encryptedBytes);
|
String computedSignature = Base64.encodeBase64URLSafeString(encryptedBytes);
|
||||||
boolean equalSig = signature.equals(computedSignature);
|
boolean equalSig = signature.equals(computedSignature);
|
||||||
if (!equalSig) {
|
if (!equalSig) {
|
||||||
s_logger.info("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);
|
s_logger.info("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);
|
||||||
@ -843,7 +843,7 @@ public class ApiServer implements HttpRequestHandler {
|
|||||||
SecureRandom sesssionKeyRandom = new SecureRandom();
|
SecureRandom sesssionKeyRandom = new SecureRandom();
|
||||||
byte sessionKeyBytes[] = new byte[20];
|
byte sessionKeyBytes[] = new byte[20];
|
||||||
sesssionKeyRandom.nextBytes(sessionKeyBytes);
|
sesssionKeyRandom.nextBytes(sessionKeyBytes);
|
||||||
String sessionKey = Base64.encodeBytes(sessionKeyBytes);
|
String sessionKey = Base64.encodeBase64URLSafeString(sessionKeyBytes);
|
||||||
session.setAttribute("sessionkey", sessionKey);
|
session.setAttribute("sessionkey", sessionKey);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -66,7 +66,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||||||
private final static AccountManager _accountMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(AccountManager.class);
|
private final static AccountManager _accountMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(AccountManager.class);
|
||||||
private final static VirtualMachineManager _vmMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(VirtualMachineManager.class);
|
private final static VirtualMachineManager _vmMgr = ComponentLocator.getLocator(ManagementServer.Name).getManager(VirtualMachineManager.class);
|
||||||
private final static ManagementServer _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
|
private final static ManagementServer _ms = (ManagementServer)ComponentLocator.getComponent(ManagementServer.Name);
|
||||||
private final static IdentityService _identityService = (IdentityService)ComponentLocator.getLocator(ManagementServer.Name).getManager(IdentityService.class);
|
private final static IdentityService _identityService = ComponentLocator.getLocator(ManagementServer.Name).getManager(IdentityService.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
|
||||||
@ -573,7 +573,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
|||||||
mac.init(keySpec);
|
mac.init(keySpec);
|
||||||
mac.update(unsignedRequest.getBytes());
|
mac.update(unsignedRequest.getBytes());
|
||||||
byte[] encryptedBytes = mac.doFinal();
|
byte[] encryptedBytes = mac.doFinal();
|
||||||
String computedSignature = com.cloud.utils.encoding.Base64.encodeBytes(encryptedBytes);
|
String computedSignature = Base64.encodeBase64URLSafeString(encryptedBytes);
|
||||||
boolean equalSig = signature.equals(computedSignature);
|
boolean equalSig = signature.equals(computedSignature);
|
||||||
if (!equalSig) {
|
if (!equalSig) {
|
||||||
s_logger.debug("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);
|
s_logger.debug("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);
|
||||||
|
|||||||
@ -31,10 +31,9 @@ import org.apache.commons.httpclient.HttpClient;
|
|||||||
import org.apache.commons.httpclient.HttpMethod;
|
import org.apache.commons.httpclient.HttpMethod;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
|
|
||||||
import com.cloud.utils.encoding.Base64;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
import org.apache.commons.httpclient.HttpClient;
|
||||||
import org.apache.commons.httpclient.HttpException;
|
import org.apache.commons.httpclient.HttpException;
|
||||||
import org.apache.commons.httpclient.HttpMethod;
|
import org.apache.commons.httpclient.HttpMethod;
|
||||||
@ -46,8 +47,6 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
|
||||||
import com.cloud.utils.encoding.Base64;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.trilead.ssh2.ChannelCondition;
|
import com.trilead.ssh2.ChannelCondition;
|
||||||
import com.trilead.ssh2.Connection;
|
import com.trilead.ssh2.Connection;
|
||||||
@ -165,6 +164,7 @@ public class StressTestDirectAttach {
|
|||||||
|
|
||||||
for (int i = 0; i < numThreads; i++) {
|
for (int i = 0; i < numThreads; i++) {
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
do {
|
do {
|
||||||
String username = null;
|
String username = null;
|
||||||
@ -1226,7 +1226,7 @@ public class StressTestDirectAttach {
|
|||||||
mac.init(keySpec);
|
mac.init(keySpec);
|
||||||
mac.update(request.getBytes());
|
mac.update(request.getBytes());
|
||||||
byte[] encryptedBytes = mac.doFinal();
|
byte[] encryptedBytes = mac.doFinal();
|
||||||
return Base64.encodeBytes(encryptedBytes);
|
return Base64.encodeBase64URLSafeString(encryptedBytes);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.error("unable to sign request", ex);
|
s_logger.error("unable to sign request", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
import com.cloud.utils.encoding.Base64;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.trilead.ssh2.ChannelCondition;
|
import com.trilead.ssh2.ChannelCondition;
|
||||||
import com.trilead.ssh2.Connection;
|
import com.trilead.ssh2.Connection;
|
||||||
@ -210,6 +209,7 @@ public class TestClientWithAPI {
|
|||||||
|
|
||||||
for (int i = 0; i < numThreads; i++) {
|
for (int i = 0; i < numThreads; i++) {
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
do {
|
do {
|
||||||
String username = null;
|
String username = null;
|
||||||
@ -609,7 +609,7 @@ public class TestClientWithAPI {
|
|||||||
s_logger.error("Create virtual network failed for account " + username + " with error code :" + responseCode + ", aborting deployment test. The command was sent with url " + url);
|
s_logger.error("Create virtual network failed for account " + username + " with error code :" + responseCode + ", aborting deployment test. The command was sent with url " + url);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
// CREATE DIRECT NETWORK
|
// CREATE DIRECT NETWORK
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
@ -629,7 +629,7 @@ public class TestClientWithAPI {
|
|||||||
s_logger.error("Create direct network failed for account " + username + " with error code :" + responseCode + ", aborting deployment test. The command was sent with url " + url);
|
s_logger.error("Create direct network failed for account " + username + " with error code :" + responseCode + ", aborting deployment test. The command was sent with url " + url);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
@ -1222,7 +1222,7 @@ public class TestClientWithAPI {
|
|||||||
return responseCode;
|
return responseCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// Execute reboot/stop/start commands for the VMs before deleting the account - made to exercise xen
|
// Execute reboot/stop/start commands for the VMs before deleting the account - made to exercise xen
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@ -1977,7 +1977,7 @@ public class TestClientWithAPI {
|
|||||||
mac.init(keySpec);
|
mac.init(keySpec);
|
||||||
mac.update(request.getBytes());
|
mac.update(request.getBytes());
|
||||||
byte[] encryptedBytes = mac.doFinal();
|
byte[] encryptedBytes = mac.doFinal();
|
||||||
return Base64.encodeBytes(encryptedBytes);
|
return org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(encryptedBytes);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
s_logger.error("unable to sign request", ex);
|
s_logger.error("unable to sign request", ex);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,12 +30,12 @@ import javax.crypto.spec.SecretKeySpec;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
import com.cloud.utils.encoding.Base64;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
|
|
||||||
public class UtilsForTest {
|
public class UtilsForTest {
|
||||||
@ -226,7 +226,7 @@ public class UtilsForTest {
|
|||||||
mac.update(request.getBytes());
|
mac.update(request.getBytes());
|
||||||
byte[] encryptedBytes = mac.doFinal();
|
byte[] encryptedBytes = mac.doFinal();
|
||||||
//System.out.println("HmacSHA1 hash: " + encryptedBytes);
|
//System.out.println("HmacSHA1 hash: " + encryptedBytes);
|
||||||
return Base64.encodeBytes(encryptedBytes);
|
return Base64.encodeBase64URLSafeString(encryptedBytes);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println("unable to sign request");
|
System.out.println("unable to sign request");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user