You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2011/04/15 18:46:09 UTC
svn commit: r1092762 - in /santuario/xml-security-java/branches/1.4.x-fixes:
./ src/org/apache/xml/security/encryption/
src/org/apache/xml/security/signature/ src/org/apache/xml/security/utils/
src/org/apache/xml/security/utils/resolver/implementations/
Author: coheigea
Date: Fri Apr 15 16:46:09 2011
New Revision: 1092762
URL: http://svn.apache.org/viewvc?rev=1092762&view=rev
Log:
[SANTUARIO-262] - Invalid use of String.getBytes()
- Patch applied.
Modified:
santuario/xml-security-java/branches/1.4.x-fixes/CHANGELOG.txt
santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/encryption/XMLCipher.java
santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/signature/XMLSignatureInput.java
santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/XMLUtils.java
santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
Modified: santuario/xml-security-java/branches/1.4.x-fixes/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/CHANGELOG.txt?rev=1092762&r1=1092761&r2=1092762&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/CHANGELOG.txt (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/CHANGELOG.txt Fri Apr 15 16:46:09 2011
@@ -1,4 +1,7 @@
Changelog for "Apache xml-security" <http://santuario.apache.org/>
+New in v1.4.5-SNAPSHOT
+ Fixed SANTUARIO-262: Invalid use of String.getBytes(). Thanks to Martin Koegler.
+
New in v1.4.4
Fixed Bug 50248: Concurrency problem on incomplete Init.init() calls. Thanks to Oliver Moehrke.
Fixed Bug 50215: test_jsr105 target appears to fail certain tests because of changes to W3C xml-stylesheet spec
Modified: santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/encryption/XMLCipher.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/encryption/XMLCipher.java?rev=1092762&r1=1092761&r2=1092762&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/encryption/XMLCipher.java (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/encryption/XMLCipher.java Fri Apr 15 16:46:09 2011
@@ -976,7 +976,7 @@ public class XMLCipher {
encryptedBytes = c.doFinal(serializedOctets.getBytes("UTF-8"));
logger.debug("Expected cipher.outputSize = " +
Integer.toString(c.getOutputSize(
- serializedOctets.getBytes().length)));
+ serializedOctets.getBytes("UTF-8").length)));
}
logger.debug("Actual cipher.outputSize = " +
Integer.toString(encryptedBytes.length));
@@ -2042,7 +2042,11 @@ public class XMLCipher {
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_KA_NONCE).item(0);
if (null != kaNonceElement) {
- result.setKANonce(kaNonceElement.getNodeValue().getBytes());
+ try {
+ result.setKANonce(kaNonceElement.getNodeValue().getBytes("UTF-8"));
+ } catch(UnsupportedEncodingException e) {
+ throw new XMLEncryptionException("UTF-8 not supported", e);
+ }
}
// TODO: ///////////////////////////////////////////////////////////
// Figure out how to make this pesky line work..
@@ -2411,8 +2415,12 @@ public class XMLCipher {
EncryptionConstants.EncryptionSpecNS,
EncryptionConstants._TAG_OAEPPARAMS).item(0);
if (null != oaepParamsElement) {
- result.setOAEPparams(
- oaepParamsElement.getNodeValue().getBytes());
+ try {
+ result.setOAEPparams(
+ oaepParamsElement.getNodeValue().getBytes("UTF-8"));
+ } catch(UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported", e);
+ }
}
// TODO: Make this mess work
@@ -2743,11 +2751,15 @@ public class XMLCipher {
result.setAttributeNS(
null, EncryptionConstants._ATT_ALGORITHM, algorithmURI);
if (null != kaNonce) {
- result.appendChild(
- XMLUtils.createElementInEncryptionSpace(
- _contextDocument,
- EncryptionConstants._TAG_KA_NONCE)).appendChild(
- _contextDocument.createTextNode(new String(kaNonce)));
+ try {
+ result.appendChild(
+ XMLUtils.createElementInEncryptionSpace(
+ _contextDocument,
+ EncryptionConstants._TAG_KA_NONCE)).appendChild(
+ _contextDocument.createTextNode(new String(kaNonce, "UTF-8")));
+ } catch(UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported", e);
+ }
}
if (!agreementMethodInformation.isEmpty()) {
Iterator itr = agreementMethodInformation.iterator();
@@ -3428,11 +3440,15 @@ public class XMLCipher {
String.valueOf(keySize))));
}
if (null != oaepParams) {
- result.appendChild(
- XMLUtils.createElementInEncryptionSpace(_contextDocument,
- EncryptionConstants._TAG_OAEPPARAMS).appendChild(
- _contextDocument.createTextNode(
- new String(oaepParams))));
+ try {
+ result.appendChild(
+ XMLUtils.createElementInEncryptionSpace(
+ _contextDocument,
+ EncryptionConstants._TAG_OAEPPARAMS)).appendChild(
+ _contextDocument.createTextNode(new String(oaepParams, "UTF-8")));
+ } catch(UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported", e);
+ }
}
Iterator itr = encryptionMethodInformation.iterator();
while (itr.hasNext()) {
Modified: santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/signature/XMLSignatureInput.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/signature/XMLSignatureInput.java?rev=1092762&r1=1092761&r2=1092762&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/signature/XMLSignatureInput.java (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/signature/XMLSignatureInput.java Fri Apr 15 16:46:09 2011
@@ -147,7 +147,11 @@ public class XMLSignatureInput implement
* @param inputStr the input String which including XML document or node
*/
public XMLSignatureInput(String inputStr) {
- this(inputStr.getBytes());
+ try {
+ this.bytes = inputStr.getBytes("UTF-8");
+ } catch(UnsupportedEncodingException e) {
+ throw new RuntimeException("UTF-8 not supported", e);
+ }
}
/**
@@ -614,9 +618,9 @@ public class XMLSignatureInput implement
// if a not-wellformed nodeset exists, put a container around it...
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- baos.write("<container>".getBytes());
+ baos.write("<container>".getBytes("UTF-8"));
baos.write(this.getBytes());
- baos.write("</container>".getBytes());
+ baos.write("</container>".getBytes("UTF-8"));
byte result[] = baos.toByteArray();
Document document = db.parse(new ByteArrayInputStream(result));
Modified: santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/XMLUtils.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/XMLUtils.java?rev=1092762&r1=1092761&r2=1092762&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/XMLUtils.java (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/XMLUtils.java Fri Apr 15 16:46:09 2011
@@ -153,7 +153,7 @@ public class XMLUtils {
try {
if (addPreamble) {
- os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes());
+ os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes("UTF-8"));
}
os.write(
Modified: santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java?rev=1092762&r1=1092761&r2=1092762&view=diff
==============================================================================
--- santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java (original)
+++ santuario/xml-security-java/branches/1.4.x-fixes/src/org/apache/xml/security/utils/resolver/implementations/ResolverDirectHTTP.java Fri Apr 15 16:46:09 2011
@@ -161,7 +161,7 @@ public class ResolverDirectHTTP extends
if ((proxyUser != null) && (proxyPass != null)) {
String password = proxyUser + ":" + proxyPass;
- String encodedPassword = Base64.encode(password.getBytes());
+ String encodedPassword = Base64.encode(password.getBytes("ISO-8859-1"));
// or was it Proxy-Authenticate ?
urlConnection.setRequestProperty("Proxy-Authorization",
@@ -190,7 +190,7 @@ public class ResolverDirectHTTP extends
String password = user + ":" + pass;
String encodedPassword =
- Base64.encode(password.getBytes());
+ Base64.encode(password.getBytes("ISO-8859-1"));
// set authentication property in the http header
urlConnection.setRequestProperty("Authorization",