SANTUARIO-529 - Removing tests that don't run with Java 8+ git-svn-id: https://svn.apache.org/repos/asf/santuario/xml-security-java/trunk@1876036 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java index f9d3fa5..ce871ba 100644 --- a/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java +++ b/src/test/java/org/apache/xml/security/test/stax/signature/SignatureVerificationTest.java
@@ -1443,131 +1443,6 @@ } @Test - public void testAllowMD5Algorithm() throws Exception { - - String jsv = System.getProperty("java.specification.version"); - if (Double.parseDouble(jsv) > 1.7) { - System.out.println("testAllowMD5Algorithm skipped"); - return; - } - - // Read in plaintext document - InputStream sourceDocument = - this.getClass().getClassLoader().getResourceAsStream( - "ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml"); - Document document = XMLUtils.read(sourceDocument, false); - - // Set up the Key - KeyStore keyStore = KeyStore.getInstance("jks"); - keyStore.load( - this.getClass().getClassLoader().getResource("transmitter.jks").openStream(), - "default".toCharArray() - ); - Key key = keyStore.getKey("transmitter", "default".toCharArray()); - X509Certificate cert = (X509Certificate)keyStore.getCertificate("transmitter"); - - // Sign using DOM - List<String> localNames = new ArrayList<>(); - localNames.add("PaymentInfo"); - XMLSignature sig = signUsingDOM( - "http://www.w3.org/2001/04/xmldsig-more#rsa-md5", document, localNames, key - ); - - // Add KeyInfo - sig.addKeyInfo(cert); - - // Convert Document to a Stream Reader - javax.xml.transform.Transformer transformer = transformerFactory.newTransformer(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - transformer.transform(new DOMSource(document), new StreamResult(baos)); - - XMLStreamReader xmlStreamReader = null; - try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) { - xmlStreamReader = xmlInputFactory.createXMLStreamReader(is); - } - - // Verify signature - XMLSecurityProperties properties = new XMLSecurityProperties(); - InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties); - TestSecurityEventListener securityEventListener = new TestSecurityEventListener(); - XMLStreamReader securityStreamReader = - inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener); - - try { - TestUtils.switchAllowMD5Algorithm(true); - document = StAX2DOM.readDoc(securityStreamReader); - } finally { - TestUtils.switchAllowMD5Algorithm(false); - } - } - - @Test - public void testMaximumAllowedXMLStructureDepth() throws Exception { - - String jsv = System.getProperty("java.specification.version"); - if (Double.parseDouble(jsv) > 1.7) { - System.out.println("testMaximumAllowedXMLStructureDepth skipped"); - return; - } - - // Read in plaintext document - InputStream sourceDocument = - this.getClass().getClassLoader().getResourceAsStream( - "ie/baltimore/merlin-examples/merlin-xmlenc-five/plaintext.xml"); - Document document = XMLUtils.read(sourceDocument, false); - - // Set up the Key - KeyStore keyStore = KeyStore.getInstance("jks"); - keyStore.load( - this.getClass().getClassLoader().getResource("transmitter.jks").openStream(), - "default".toCharArray() - ); - Key key = keyStore.getKey("transmitter", "default".toCharArray()); - X509Certificate cert = (X509Certificate)keyStore.getCertificate("transmitter"); - - // Sign using DOM - List<String> localNames = new ArrayList<>(); - localNames.add("PaymentInfo"); - XMLSignature sig = signUsingDOM( - "http://www.w3.org/2000/09/xmldsig#rsa-sha1", document, localNames, key - ); - - // Add KeyInfo - sig.addKeyInfo(cert); - - // Convert Document to a Stream Reader - javax.xml.transform.Transformer transformer = transformerFactory.newTransformer(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - transformer.transform(new DOMSource(document), new StreamResult(baos)); - - XMLStreamReader xmlStreamReader = null; - try (InputStream is = new ByteArrayInputStream(baos.toByteArray())) { - xmlStreamReader = xmlInputFactory.createXMLStreamReader(is); - } - - // Verify signature - XMLSecurityProperties properties = new XMLSecurityProperties(); - InboundXMLSec inboundXMLSec = XMLSec.getInboundWSSec(properties); - TestSecurityEventListener securityEventListener = new TestSecurityEventListener(); - XMLStreamReader securityStreamReader = - inboundXMLSec.processInMessage(xmlStreamReader, null, securityEventListener); - - int oldval = 0; - try { - oldval = TestUtils.changeValueOfMaximumAllowedXMLStructureDepth(5); - document = StAX2DOM.readDoc(securityStreamReader); - fail("Exception expected"); - } catch (XMLStreamException e) { - assertTrue(e.getCause() instanceof XMLSecurityException); - assertEquals("Maximum depth (5) of the XML structure reached. You can raise the maximum via the " + - "\"MaximumAllowedXMLStructureDepth\" property in the configuration.", - e.getCause().getMessage()); - } finally { - TestUtils.changeValueOfMaximumAllowedXMLStructureDepth(oldval); - } - } - - @Test public void testCustomC14nAlgo() throws Exception { final String customC14N = "customC14N";
diff --git a/src/test/java/org/apache/xml/security/test/stax/utils/TestUtils.java b/src/test/java/org/apache/xml/security/test/stax/utils/TestUtils.java index c8dfcdd..6aab27d 100644 --- a/src/test/java/org/apache/xml/security/test/stax/utils/TestUtils.java +++ b/src/test/java/org/apache/xml/security/test/stax/utils/TestUtils.java
@@ -54,28 +54,5 @@ field.set(null, value); return oldval; } - - public static void switchAllowMD5Algorithm(Boolean value) throws NoSuchFieldException, IllegalAccessException { - Field field = InboundSecurityContextImpl.class.getDeclaredField("allowMD5Algorithm"); - field.setAccessible(true); - - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - - field.set(null, value); - } - - public static int changeValueOfMaximumAllowedXMLStructureDepth(Integer value) throws NoSuchFieldException, IllegalAccessException { - Field field = XMLEventReaderInputProcessor.class.getDeclaredField("maximumAllowedXMLStructureDepth"); - field.setAccessible(true); - - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL); - - Integer oldval = (Integer) field.get(null); - field.set(null, value); - return oldval; - } + }