This is an automated email from the ASF dual-hosted git repository. coheigea pushed a commit to branch 4.1.x-fixes in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 1346ea667b074be2b9a23c52c89440d09adda5a4 Author: Colm O hEigeartaigh <[email protected]> AuthorDate: Thu Sep 10 12:20:09 2026 +0100 Fix encrypted properties tests to work with WSS4J 4.0.2 (#3458) --- .../apache/cxf/systest/ws/action/ActionTest.java | 39 ++++++++++++--------- .../cxf/systest/ws/fault/ModifiedRequestTest.java | 2 ++ .../apache/cxf/systest/ws/x509/X509TokenTest.java | 40 +++++++++++++--------- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java index 5931869f640..8f1a69e4322 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java @@ -235,23 +235,28 @@ public class ActionTest extends AbstractBusClientServerTestBase { return; } - SpringBusFactory bf = new SpringBusFactory(); - URL busFile = ActionTest.class.getResource("client.xml"); - - Bus bus = bf.createBus(busFile.toString()); - BusFactory.setDefaultBus(bus); - BusFactory.setThreadDefaultBus(bus); - - URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); - Service service = Service.create(wsdl, SERVICE_QNAME); - QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPasswordPort"); - DoubleItPortType port = - service.getPort(portQName, DoubleItPortType.class); - updateAddressPort(port, PORT); - assertEquals(50, port.doubleIt(25)); - - ((java.io.Closeable)port).close(); - bus.shutdown(true); + try { + System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true"); + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = ActionTest.class.getResource("client.xml"); + + Bus bus = bf.createBus(busFile.toString()); + BusFactory.setDefaultBus(bus); + BusFactory.setThreadDefaultBus(bus); + + URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPasswordPort"); + DoubleItPortType port = + service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(port, PORT); + assertEquals(50, port.doubleIt(25)); + + ((java.io.Closeable)port).close(); + bus.shutdown(true); + } finally { + System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm"); + } } @org.junit.Test diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/ModifiedRequestTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/ModifiedRequestTest.java index 8eb1d215159..4a323af39ed 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/ModifiedRequestTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/fault/ModifiedRequestTest.java @@ -73,11 +73,13 @@ public class ModifiedRequestTest extends AbstractBusClientServerTestBase { // set this to false to fork launchServer(ModifiedRequestServer.class, true) ); + System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true"); } @org.junit.AfterClass public static void cleanup() throws Exception { stopAllServers(); + System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm"); } @org.junit.Test diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java index 834e9a0beae..20a7d550bac 100644 --- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java +++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java @@ -763,28 +763,34 @@ public class X509TokenTest extends AbstractBusClientServerTestBase { return; } - SpringBusFactory bf = new SpringBusFactory(); - URL busFile = X509TokenTest.class.getResource("client.xml"); + try { + System.setProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm", "true"); - Bus bus = bf.createBus(busFile.toString()); - BusFactory.setDefaultBus(bus); - BusFactory.setThreadDefaultBus(bus); + SpringBusFactory bf = new SpringBusFactory(); + URL busFile = X509TokenTest.class.getResource("client.xml"); - URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); - Service service = Service.create(wsdl, SERVICE_QNAME); - QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptedPasswordPort"); - DoubleItPortType x509Port = - service.getPort(portQName, DoubleItPortType.class); - updateAddressPort(x509Port, test.getPort()); + Bus bus = bf.createBus(busFile.toString()); + BusFactory.setDefaultBus(bus); + BusFactory.setThreadDefaultBus(bus); - if (test.isStreaming()) { - SecurityTestUtil.enableStreaming(x509Port); - } + URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl"); + Service service = Service.create(wsdl, SERVICE_QNAME); + QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricEncryptedPasswordPort"); + DoubleItPortType x509Port = + service.getPort(portQName, DoubleItPortType.class); + updateAddressPort(x509Port, test.getPort()); - assertEquals(50, x509Port.doubleIt(25)); + if (test.isStreaming()) { + SecurityTestUtil.enableStreaming(x509Port); + } - ((java.io.Closeable)x509Port).close(); - bus.shutdown(true); + assertEquals(50, x509Port.doubleIt(25)); + + ((java.io.Closeable)x509Port).close(); + bus.shutdown(true); + } finally { + System.clearProperty("org.apache.wss4j.crypto.jasypt.useLegacyDefaultAlgorithm"); + } } @org.junit.Test
