mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Revert "Merge pull request #825 from borisroman/charset"
This reverts commit a44e2bff7ec0c1548d89722c40488746454adce1, reversing changes made to 06cefaf493423c953a95ee92482a2d0a20a21095. We are reverting the PR #825 because it breaks Master.
This commit is contained in:
parent
a44e2bff7e
commit
6e426fa46d
@ -19,6 +19,7 @@ package com.cloud.hypervisor.hyperv.discoverer;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -42,8 +43,8 @@ import com.cloud.agent.api.SetupAnswer;
|
|||||||
import com.cloud.agent.api.SetupCommand;
|
import com.cloud.agent.api.SetupCommand;
|
||||||
import com.cloud.agent.api.StartupCommand;
|
import com.cloud.agent.api.StartupCommand;
|
||||||
import com.cloud.agent.api.StartupRoutingCommand;
|
import com.cloud.agent.api.StartupRoutingCommand;
|
||||||
import com.cloud.alert.AlertManager;
|
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
|
import com.cloud.alert.AlertManager;
|
||||||
import com.cloud.dc.ClusterVO;
|
import com.cloud.dc.ClusterVO;
|
||||||
import com.cloud.dc.DataCenterVO;
|
import com.cloud.dc.DataCenterVO;
|
||||||
import com.cloud.dc.HostPodVO;
|
import com.cloud.dc.HostPodVO;
|
||||||
@ -65,7 +66,6 @@ import com.cloud.resource.ResourceStateAdapter;
|
|||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.resource.UnableDeleteHostException;
|
import com.cloud.resource.UnableDeleteHostException;
|
||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods to discover and managem a Hyper-V agent. Prepares a
|
* Methods to discover and managem a Hyper-V agent. Prepares a
|
||||||
@ -256,7 +256,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
// pool in the database
|
// pool in the database
|
||||||
// This GUID may change.
|
// This GUID may change.
|
||||||
if (cluster.getGuid() == null) {
|
if (cluster.getGuid() == null) {
|
||||||
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes(StringUtils.getPreferredCharset())).toString());
|
cluster.setGuid(UUID.nameUUIDFromBytes(String.valueOf(clusterId).getBytes(Charset.forName("UTF-8"))).toString());
|
||||||
_clusterDao.update(clusterId, cluster);
|
_clusterDao.update(clusterId, cluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ public class HypervServerDiscoverer extends DiscovererBase implements Discoverer
|
|||||||
* @return GUID in form of a string.
|
* @return GUID in form of a string.
|
||||||
*/
|
*/
|
||||||
public static String calcServerResourceGuid(final String uuidSeed) {
|
public static String calcServerResourceGuid(final String uuidSeed) {
|
||||||
String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes(StringUtils.getPreferredCharset())).toString();
|
String guid = UUID.nameUUIDFromBytes(uuidSeed.getBytes(Charset.forName("UTF-8"))).toString();
|
||||||
return guid;
|
return guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.channels.SocketChannel;
|
import java.nio.channels.SocketChannel;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
import java.security.KeyManagementException;
|
import java.security.KeyManagementException;
|
||||||
import java.security.KeyStoreException;
|
import java.security.KeyStoreException;
|
||||||
@ -42,7 +43,6 @@ import javax.ejb.Local;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import org.apache.cloudstack.storage.command.CopyCommand;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
@ -62,6 +62,11 @@ import org.apache.http.impl.conn.BasicClientConnectionManager;
|
|||||||
import org.apache.http.util.EntityUtils;
|
import org.apache.http.util.EntityUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.storage.command.CopyCommand;
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.CheckRouterAnswer;
|
import com.cloud.agent.api.CheckRouterAnswer;
|
||||||
import com.cloud.agent.api.CheckRouterCommand;
|
import com.cloud.agent.api.CheckRouterCommand;
|
||||||
@ -151,8 +156,6 @@ import com.cloud.utils.ssh.SshHelper;
|
|||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VirtualMachine.PowerState;
|
import com.cloud.vm.VirtualMachine.PowerState;
|
||||||
import com.cloud.vm.VirtualMachineName;
|
import com.cloud.vm.VirtualMachineName;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -650,7 +653,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||||||
public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) {
|
public ExecutionResult createFileInVR(String routerIp, String filePath, String fileName, String content) {
|
||||||
File keyFile = getSystemVMKeyFile();
|
File keyFile = getSystemVMKeyFile();
|
||||||
try {
|
try {
|
||||||
SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes(StringUtils.getPreferredCharset()), fileName, null);
|
SshHelper.scpTo(routerIp, 3922, "root", keyFile, null, filePath, content.getBytes(Charset.forName("UTF-8")), fileName, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e);
|
s_logger.warn("Fail to create file " + filePath + fileName + " in VR " + routerIp, e);
|
||||||
return new ExecutionResult(false, e.getMessage());
|
return new ExecutionResult(false, e.getMessage());
|
||||||
@ -1315,7 +1318,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(StringUtils.getPreferredCharset()), routerIp.replace('.', '_') +
|
SshHelper.scpTo(controlIp, DEFAULT_DOMR_SSHPORT, "root", keyFile, null, "/tmp/", tmpCfgFileContents.toString().getBytes(Charset.forName("UTF-8")), routerIp.replace('.', '_') +
|
||||||
".cfg", null);
|
".cfg", null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1512,7 +1515,7 @@ public class HypervDirectConnectResource extends ServerResourceBase implements S
|
|||||||
String json = new Gson().toJson(data);
|
String json = new Gson().toJson(data);
|
||||||
s_logger.debug("VM data JSON IS:" + json);
|
s_logger.debug("VM data JSON IS:" + json);
|
||||||
|
|
||||||
json = Base64.encodeBase64String(json.getBytes(StringUtils.getPreferredCharset()));
|
json = Base64.encodeBase64String(json.getBytes(Charset.forName("UTF-8")));
|
||||||
|
|
||||||
String args = "-d " + json;
|
String args = "-d " + json;
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import java.io.UnsupportedEncodingException;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -48,7 +49,6 @@ import org.apache.commons.httpclient.protocol.Protocol;
|
|||||||
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
|
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ public class BigSwitchBcfApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String authString = username + ":" + password;
|
String authString = username + ":" + password;
|
||||||
String encodedAuthString = "Basic " + Base64.encodeBase64String(authString.getBytes(StringUtils.getPreferredCharset()));
|
String encodedAuthString = "Basic " + Base64.encodeBase64String(authString.getBytes(Charset.forName("UTF-8")));
|
||||||
m.setRequestHeader("Authorization", encodedAuthString);
|
m.setRequestHeader("Authorization", encodedAuthString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,8 +23,8 @@ import java.io.StringReader;
|
|||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import javax.persistence.Basic;
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Marshaller;
|
import javax.xml.bind.Marshaller;
|
||||||
@ -45,9 +45,21 @@ import org.apache.http.entity.StringEntity;
|
|||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.dc.Vlan;
|
import com.cloud.network.schema.interfacevlan.InterfaceVlan;
|
||||||
import com.cloud.utils.StringUtils;
|
import com.cloud.network.schema.interfacevlan.Interface;
|
||||||
import com.cloud.utils.cisco.n1kv.vsm.PortProfile;
|
import com.cloud.network.schema.interfacevlan.Vlan;
|
||||||
|
import com.cloud.network.schema.portprofile.PortProfile;
|
||||||
|
import com.cloud.network.schema.portprofile.PortProfile.Activate;
|
||||||
|
import com.cloud.network.schema.portprofile.PortProfile.Static;
|
||||||
|
import com.cloud.network.schema.portprofile.PortProfileGlobal;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.Switchport;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Mode;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Trunk;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.Switchport.Trunk.Allowed;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.SwitchportBasic;
|
||||||
|
import com.cloud.network.schema.portprofile.VlanProfile.SwitchportBasic.Basic;
|
||||||
|
import com.cloud.network.schema.showvcs.Output;
|
||||||
|
|
||||||
public class BrocadeVcsApi {
|
public class BrocadeVcsApi {
|
||||||
private static final Logger s_logger = Logger.getLogger(BrocadeVcsApi.class);
|
private static final Logger s_logger = Logger.getLogger(BrocadeVcsApi.class);
|
||||||
@ -449,7 +461,7 @@ public class BrocadeVcsApi {
|
|||||||
throw new BrocadeVcsApiException("Failed to retreive status : " + errorMessage);
|
throw new BrocadeVcsApiException("Failed to retreive status : " + errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StringUtils.getPreferredCharset()))) {
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")))) {
|
||||||
sb = new StringBuffer();
|
sb = new StringBuffer();
|
||||||
|
|
||||||
while (((readLine = br.readLine()) != null)) {
|
while (((readLine = br.readLine()) != null)) {
|
||||||
@ -519,7 +531,7 @@ public class BrocadeVcsApi {
|
|||||||
|
|
||||||
if ("text/html".equals(response.getEntity().getContentType().getValue())) {
|
if ("text/html".equals(response.getEntity().getContentType().getValue())) {
|
||||||
|
|
||||||
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StringUtils.getPreferredCharset()))) {
|
try (BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), Charset.forName("UTF-8")))) {
|
||||||
|
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
String line = "";
|
String line = "";
|
||||||
|
|||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.cloud.network.manager;
|
package com.cloud.network.manager;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -72,7 +73,6 @@ import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
|
|||||||
import com.cloud.resource.ResourceManager;
|
import com.cloud.resource.ResourceManager;
|
||||||
import com.cloud.resource.ResourceState;
|
import com.cloud.resource.ResourceState;
|
||||||
import com.cloud.resource.ServerResource;
|
import com.cloud.resource.ServerResource;
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
import com.cloud.utils.db.Transaction;
|
import com.cloud.utils.db.Transaction;
|
||||||
import com.cloud.utils.db.TransactionCallback;
|
import com.cloud.utils.db.TransactionCallback;
|
||||||
@ -159,7 +159,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
|
|||||||
params.put("name", "Nuage VSD - " + cmd.getHostName());
|
params.put("name", "Nuage VSD - " + cmd.getHostName());
|
||||||
params.put("hostname", cmd.getHostName());
|
params.put("hostname", cmd.getHostName());
|
||||||
params.put("cmsuser", cmd.getUserName());
|
params.put("cmsuser", cmd.getUserName());
|
||||||
String cmsUserPasswordBase64 = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.encodeBase64(cmd.getPassword().getBytes(StringUtils.getPreferredCharset())));
|
String cmsUserPasswordBase64 = org.apache.commons.codec.binary.StringUtils.newStringUtf8(Base64.encodeBase64(cmd.getPassword().getBytes(Charset.forName("UTF-8"))));
|
||||||
params.put("cmsuserpass", cmsUserPasswordBase64);
|
params.put("cmsuserpass", cmsUserPasswordBase64);
|
||||||
int port = cmd.getPort();
|
int port = cmd.getPort();
|
||||||
if (0 == port) {
|
if (0 == port) {
|
||||||
@ -301,7 +301,6 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
|
|||||||
|
|
||||||
if (numOfSyncThreads != null && syncUpIntervalInMinutes != null) {
|
if (numOfSyncThreads != null && syncUpIntervalInMinutes != null) {
|
||||||
ThreadFactory threadFactory = new ThreadFactory() {
|
ThreadFactory threadFactory = new ThreadFactory() {
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable runnable) {
|
public Thread newThread(Runnable runnable) {
|
||||||
Thread thread = new Thread(runnable, "Nuage Vsp sync task");
|
Thread thread = new Thread(runnable, "Nuage Vsp sync task");
|
||||||
if (thread.isDaemon())
|
if (thread.isDaemon())
|
||||||
|
|||||||
@ -19,42 +19,7 @@
|
|||||||
|
|
||||||
package org.apache.cloudstack.saml;
|
package org.apache.cloudstack.saml;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import com.cloud.utils.HttpUtils;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
import java.security.KeyFactory;
|
|
||||||
import java.security.KeyPair;
|
|
||||||
import java.security.KeyPairGenerator;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.NoSuchProviderException;
|
|
||||||
import java.security.PrivateKey;
|
|
||||||
import java.security.PublicKey;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.security.Security;
|
|
||||||
import java.security.Signature;
|
|
||||||
import java.security.SignatureException;
|
|
||||||
import java.security.cert.CertificateEncodingException;
|
|
||||||
import java.security.cert.X509Certificate;
|
|
||||||
import java.security.spec.InvalidKeySpecException;
|
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.Deflater;
|
|
||||||
import java.util.zip.DeflaterOutputStream;
|
|
||||||
|
|
||||||
import javax.security.auth.x500.X500Principal;
|
|
||||||
import javax.servlet.http.Cookie;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import javax.xml.stream.FactoryConfigurationError;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
import org.apache.cloudstack.api.ApiConstants;
|
||||||
import org.apache.cloudstack.api.response.LoginCmdResponse;
|
import org.apache.cloudstack.api.response.LoginCmdResponse;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
@ -98,8 +63,41 @@ import org.w3c.dom.Document;
|
|||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import com.cloud.utils.HttpUtils;
|
import javax.security.auth.x500.X500Principal;
|
||||||
import com.cloud.utils.StringUtils;
|
import javax.servlet.http.Cookie;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.stream.FactoryConfigurationError;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
import java.security.KeyFactory;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyPairGenerator;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.NoSuchProviderException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.security.Signature;
|
||||||
|
import java.security.SignatureException;
|
||||||
|
import java.security.cert.CertificateEncodingException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.security.spec.InvalidKeySpecException;
|
||||||
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.Deflater;
|
||||||
|
import java.util.zip.DeflaterOutputStream;
|
||||||
|
|
||||||
public class SAMLUtils {
|
public class SAMLUtils {
|
||||||
public static final Logger s_logger = Logger.getLogger(SAMLUtils.class);
|
public static final Logger s_logger = Logger.getLogger(SAMLUtils.class);
|
||||||
@ -221,7 +219,7 @@ public class SAMLUtils {
|
|||||||
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
|
Deflater deflater = new Deflater(Deflater.DEFLATED, true);
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||||
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, deflater);
|
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, deflater);
|
||||||
deflaterOutputStream.write(requestMessage.getBytes(StringUtils.getPreferredCharset()));
|
deflaterOutputStream.write(requestMessage.getBytes(Charset.forName("UTF-8")));
|
||||||
deflaterOutputStream.close();
|
deflaterOutputStream.close();
|
||||||
String encodedRequestMessage = Base64.encodeBytes(byteArrayOutputStream.toByteArray(), Base64.DONT_BREAK_LINES);
|
String encodedRequestMessage = Base64.encodeBytes(byteArrayOutputStream.toByteArray(), Base64.DONT_BREAK_LINES);
|
||||||
encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, HttpUtils.UTF_8).trim();
|
encodedRequestMessage = URLEncoder.encode(encodedRequestMessage, HttpUtils.UTF_8).trim();
|
||||||
@ -265,7 +263,7 @@ public class SAMLUtils {
|
|||||||
String url = urlEncodedString + "&SigAlg=" + URLEncoder.encode(opensamlAlgoIdSignature, HttpUtils.UTF_8);
|
String url = urlEncodedString + "&SigAlg=" + URLEncoder.encode(opensamlAlgoIdSignature, HttpUtils.UTF_8);
|
||||||
Signature signature = Signature.getInstance(javaSignatureAlgorithmName);
|
Signature signature = Signature.getInstance(javaSignatureAlgorithmName);
|
||||||
signature.initSign(signingKey);
|
signature.initSign(signingKey);
|
||||||
signature.update(url.getBytes(StringUtils.getPreferredCharset()));
|
signature.update(url.getBytes(Charset.forName("UTF-8")));
|
||||||
String signatureString = Base64.encodeBytes(signature.sign(), Base64.DONT_BREAK_LINES);
|
String signatureString = Base64.encodeBytes(signature.sign(), Base64.DONT_BREAK_LINES);
|
||||||
if (signatureString != null) {
|
if (signatureString != null) {
|
||||||
return url + "&Signature=" + URLEncoder.encode(signatureString, HttpUtils.UTF_8);
|
return url + "&Signature=" + URLEncoder.encode(signatureString, HttpUtils.UTF_8);
|
||||||
@ -289,7 +287,7 @@ public class SAMLUtils {
|
|||||||
KeyFactory keyFactory = SAMLUtils.getKeyFactory();
|
KeyFactory keyFactory = SAMLUtils.getKeyFactory();
|
||||||
if (keyFactory == null) return null;
|
if (keyFactory == null) return null;
|
||||||
X509EncodedKeySpec spec = keyFactory.getKeySpec(key, X509EncodedKeySpec.class);
|
X509EncodedKeySpec spec = keyFactory.getKeySpec(key, X509EncodedKeySpec.class);
|
||||||
return new String(org.bouncycastle.util.encoders.Base64.encode(spec.getEncoded()), StringUtils.getPreferredCharset());
|
return new String(org.bouncycastle.util.encoders.Base64.encode(spec.getEncoded()), Charset.forName("UTF-8"));
|
||||||
} catch (InvalidKeySpecException e) {
|
} catch (InvalidKeySpecException e) {
|
||||||
s_logger.error("Unable to create KeyFactory:" + e.getMessage());
|
s_logger.error("Unable to create KeyFactory:" + e.getMessage());
|
||||||
}
|
}
|
||||||
@ -302,7 +300,7 @@ public class SAMLUtils {
|
|||||||
if (keyFactory == null) return null;
|
if (keyFactory == null) return null;
|
||||||
PKCS8EncodedKeySpec spec = keyFactory.getKeySpec(key,
|
PKCS8EncodedKeySpec spec = keyFactory.getKeySpec(key,
|
||||||
PKCS8EncodedKeySpec.class);
|
PKCS8EncodedKeySpec.class);
|
||||||
return new String(org.bouncycastle.util.encoders.Base64.encode(spec.getEncoded()), StringUtils.getPreferredCharset());
|
return new String(org.bouncycastle.util.encoders.Base64.encode(spec.getEncoded()), Charset.forName("UTF-8"));
|
||||||
} catch (InvalidKeySpecException e) {
|
} catch (InvalidKeySpecException e) {
|
||||||
s_logger.error("Unable to create KeyFactory:" + e.getMessage());
|
s_logger.error("Unable to create KeyFactory:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,7 @@ public class ConstantTimeComparator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean compareStrings(String s1, String s2) {
|
public static boolean compareStrings(String s1, String s2) {
|
||||||
final Charset encoding = StringUtils.getPreferredCharset();
|
final Charset encoding = Charset.forName("UTF-8");
|
||||||
return compareBytes(s1.getBytes(encoding), s2.getBytes(encoding));
|
return compareBytes(s1.getBytes(encoding), s2.getBytes(encoding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,12 +24,11 @@ import java.io.ByteArrayInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
|
|
||||||
public class QCOW2UtilsTest {
|
public class QCOW2UtilsTest {
|
||||||
|
|
||||||
InputStream inputStream;
|
InputStream inputStream;
|
||||||
@ -68,7 +67,7 @@ public class QCOW2UtilsTest {
|
|||||||
ByteBuffer byteBuffer = ByteBuffer.allocate(72);
|
ByteBuffer byteBuffer = ByteBuffer.allocate(72);
|
||||||
|
|
||||||
// Magic
|
// Magic
|
||||||
byteBuffer.put("QFI".getBytes(StringUtils.getPreferredCharset()));
|
byteBuffer.put("QFI".getBytes(Charset.forName("UTF-8")));
|
||||||
byteBuffer.put((byte)0xfb);
|
byteBuffer.put((byte)0xfb);
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user