Removed Base64 file and use the apache version

This commit is contained in:
Alex Huang 2012-08-07 15:38:59 -07:00
parent 1d3a443237
commit a6a864a1a8
9 changed files with 1998 additions and 3756 deletions

View File

@ -1,22 +1,4 @@
<?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>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>

View File

@ -241,7 +241,7 @@
<available file="${setup.db.dir}/override/templates.sql" />
</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">
<arg value="deploy-db-dev.sh" />
<arg value="${server-setup.file}" />

View File

@ -53,6 +53,7 @@ import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.codec.binary.Base64;
import org.apache.http.ConnectionClosedException;
import org.apache.http.HttpException;
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.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CSExceptionErrorCode;
import com.cloud.uuididentity.dao.IdentityDao;
@ -751,7 +751,7 @@ public class ApiServer implements HttpRequestHandler {
mac.init(keySpec);
mac.update(unsignedRequest.getBytes());
byte[] encryptedBytes = mac.doFinal();
String computedSignature = Base64.encodeBytes(encryptedBytes);
String computedSignature = Base64.encodeBase64URLSafeString(encryptedBytes);
boolean equalSig = signature.equals(computedSignature);
if (!equalSig) {
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();
byte sessionKeyBytes[] = new byte[20];
sesssionKeyRandom.nextBytes(sessionKeyBytes);
String sessionKey = Base64.encodeBytes(sessionKeyBytes);
String sessionKey = Base64.encodeBase64URLSafeString(sessionKeyBytes);
session.setAttribute("sessionkey", sessionKey);
return;

View File

@ -66,7 +66,7 @@ public class ConsoleProxyServlet extends HttpServlet {
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 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
protected void doPost(HttpServletRequest req, HttpServletResponse resp) {
@ -573,7 +573,7 @@ public class ConsoleProxyServlet extends HttpServlet {
mac.init(keySpec);
mac.update(unsignedRequest.getBytes());
byte[] encryptedBytes = mac.doFinal();
String computedSignature = com.cloud.utils.encoding.Base64.encodeBytes(encryptedBytes);
String computedSignature = Base64.encodeBase64URLSafeString(encryptedBytes);
boolean equalSig = signature.equals(computedSignature);
if (!equalSig) {
s_logger.debug("User signature: " + signature + " is not equaled to computed signature: " + computedSignature);

View File

@ -31,7 +31,6 @@ import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import com.cloud.utils.encoding.Base64;
/**
*

View File

@ -35,6 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
@ -46,8 +47,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CloudRuntimeException;
import com.trilead.ssh2.ChannelCondition;
import com.trilead.ssh2.Connection;
@ -165,6 +164,7 @@ public class StressTestDirectAttach {
for (int i = 0; i < numThreads; i++) {
new Thread(new Runnable() {
@Override
public void run() {
do {
String username = null;
@ -1226,7 +1226,7 @@ public class StressTestDirectAttach {
mac.init(keySpec);
mac.update(request.getBytes());
byte[] encryptedBytes = mac.doFinal();
return Base64.encodeBytes(encryptedBytes);
return Base64.encodeBase64URLSafeString(encryptedBytes);
} catch (Exception ex) {
s_logger.error("unable to sign request", ex);
}

View File

@ -49,7 +49,6 @@ import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CloudRuntimeException;
import com.trilead.ssh2.ChannelCondition;
import com.trilead.ssh2.Connection;
@ -210,6 +209,7 @@ public class TestClientWithAPI {
for (int i = 0; i < numThreads; i++) {
new Thread(new Runnable() {
@Override
public void run() {
do {
String username = null;
@ -1977,7 +1977,7 @@ public class TestClientWithAPI {
mac.init(keySpec);
mac.update(request.getBytes());
byte[] encryptedBytes = mac.doFinal();
return Base64.encodeBytes(encryptedBytes);
return org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(encryptedBytes);
} catch (Exception ex) {
s_logger.error("unable to sign request", ex);
}

View File

@ -30,12 +30,12 @@ import javax.crypto.spec.SecretKeySpec;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.codec.binary.Base64;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.cloud.utils.encoding.Base64;
import com.cloud.utils.exception.CloudRuntimeException;
public class UtilsForTest {
@ -226,7 +226,7 @@ public class UtilsForTest {
mac.update(request.getBytes());
byte[] encryptedBytes = mac.doFinal();
//System.out.println("HmacSHA1 hash: " + encryptedBytes);
return Base64.encodeBytes(encryptedBytes);
return Base64.encodeBase64URLSafeString(encryptedBytes);
} catch (Exception ex) {
System.out.println("unable to sign request");
ex.printStackTrace();

File diff suppressed because it is too large Load Diff