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 2017/08/02 16:57:42 UTC
svn commit: r1803868 [4/4] - in /santuario/xml-security-java/trunk: ./
src/main/java/org/apache/xml/security/c14n/
src/main/java/org/apache/xml/security/encryption/
src/main/java/org/apache/xml/security/signature/
src/main/java/org/apache/xml/security/...
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java?rev=1803868&r1=1803867&r2=1803868&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureEncryptionTest.java Wed Aug 2 16:57:41 2017
@@ -40,6 +40,7 @@ import javax.xml.stream.XMLStreamWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.KeyStore;
import java.security.PublicKey;
@@ -87,7 +88,7 @@ public class SignatureEncryptionTest ext
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -97,7 +98,7 @@ public class SignatureEncryptionTest ext
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -156,7 +157,7 @@ public class SignatureEncryptionTest ext
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -166,7 +167,7 @@ public class SignatureEncryptionTest ext
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -233,7 +234,7 @@ public class SignatureEncryptionTest ext
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -243,7 +244,7 @@ public class SignatureEncryptionTest ext
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -310,7 +311,7 @@ public class SignatureEncryptionTest ext
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -320,7 +321,7 @@ public class SignatureEncryptionTest ext
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -387,7 +388,7 @@ public class SignatureEncryptionTest ext
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -397,7 +398,7 @@ public class SignatureEncryptionTest ext
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java?rev=1803868&r1=1803867&r2=1803868&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACCreationTest.java Wed Aug 2 16:57:41 2017
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.lang.reflect.Constructor;
+import java.nio.charset.StandardCharsets;
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
@@ -85,7 +86,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#hmac-sha1";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -101,7 +102,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -111,7 +112,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -130,7 +131,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -146,7 +147,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -156,7 +157,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -175,7 +176,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -191,7 +192,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -201,7 +202,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -220,7 +221,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -236,7 +237,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -246,7 +247,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -265,7 +266,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -281,7 +282,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -291,7 +292,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
@@ -312,7 +313,7 @@ public class SignatureHMACCreationTest e
properties.setActions(actions);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
properties.setSignatureKey(key);
@@ -328,7 +329,7 @@ public class SignatureHMACCreationTest e
OutboundXMLSec outboundXMLSec = XMLSec.getOutboundXMLSec(properties);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, "UTF-8");
+ XMLStreamWriter xmlStreamWriter = outboundXMLSec.processOutMessage(baos, StandardCharsets.UTF_8.name());
InputStream sourceDocument =
this.getClass().getClassLoader().getResourceAsStream(
@@ -338,7 +339,7 @@ public class SignatureHMACCreationTest e
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
- // System.out.println("Got:\n" + new String(baos.toByteArray(), "UTF-8"));
+ // System.out.println("Got:\n" + new String(baos.toByteArray(), StandardCharsets.UTF_8.name()));
Document document = null;
try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) {
document = XMLUtils.createDocumentBuilder(false).parse(is);
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java?rev=1803868&r1=1803867&r2=1803868&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureHMACVerificationTest.java Wed Aug 2 16:57:41 2017
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.lang.reflect.Constructor;
+import java.nio.charset.StandardCharsets;
import java.security.Provider;
import java.security.Security;
import java.util.ArrayList;
@@ -100,7 +101,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2000/09/xmldsig#hmac-sha1";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
@@ -146,7 +147,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha224";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
@@ -192,7 +193,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha256";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
@@ -238,7 +239,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha384";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
@@ -284,7 +285,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-sha512";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
@@ -332,7 +333,7 @@ public class SignatureHMACVerificationTe
Document document = builder.parse(sourceDocument);
// Set the key up
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
String signatureAlgorithm = "http://www.w3.org/2001/04/xmldsig-more#hmac-ripemd160";
SecretKey key = new SecretKeySpec(hmacKey, signatureAlgorithm);
Modified: santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java?rev=1803868&r1=1803867&r2=1803868&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java (original)
+++ santuario/xml-security-java/trunk/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java Wed Aug 2 16:57:41 2017
@@ -22,6 +22,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.lang.reflect.Field;
+import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.security.KeyStore;
import java.security.Security;
@@ -386,7 +387,7 @@ public class SignatureVerificationTest e
Document document = builder.parse(sourceDocument);
// Set up the Key
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
SecretKey key = new SecretKeySpec(hmacKey, "http://www.w3.org/2000/09/xmldsig#hmac-sha1");
// Sign using DOM
@@ -466,7 +467,7 @@ public class SignatureVerificationTest e
Document document = builder.parse(sourceDocument);
// Set up the Key
- byte[] hmacKey = "secret".getBytes("ASCII");
+ byte[] hmacKey = "secret".getBytes(StandardCharsets.US_ASCII);
SecretKey key = new SecretKeySpec(hmacKey, "http://www.w3.org/2000/09/xmldsig#hmac-sha1");
// Sign using DOM
@@ -496,7 +497,7 @@ public class SignatureVerificationTest e
// Verify signature
XMLSecurityProperties properties = new XMLSecurityProperties();
- byte[] badKey = "secret2".getBytes("ASCII");
+ byte[] badKey = "secret2".getBytes(StandardCharsets.US_ASCII);
key = new SecretKeySpec(badKey, "http://www.w3.org/2000/09/xmldsig#hmac-sha1");
properties.setSignatureVerificationKey(key);
InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties);