From 1a5416d84c4f2fd10a3afc42f54ba970ac2bfcd5 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Fri, 25 Apr 2014 12:05:44 +0200 Subject: [PATCH] Upgraded to WSS4J 1.6.15 --- build.gradle | 2 +- .../security/wss4j/Wss4jSecurityInterceptor.java | 2 ++ ...ptorSpringSecurityCallbackHandlerTestCase.java | 15 ++++++++++++--- ...4jMessageInterceptorUsernameTokenTestCase.java | 12 ++++++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 2acaba6c..1abe7f8f 100644 --- a/build.gradle +++ b/build.gradle @@ -223,7 +223,7 @@ project('spring-ws-security') { optional("com.sun.xml.wss:xws-security:3.0") { exclude group: 'javax.xml.crypto', module: 'xmldsig' } - optional("org.apache.ws.security:wss4j:1.6.5") + optional("org.apache.ws.security:wss4j:1.6.15") // SOAP provided("com.sun.xml.messaging.saaj:saaj-impl:1.3.19") // required for XWSS diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java index 962be2f9..2740b86f 100755 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j/Wss4jSecurityInterceptor.java @@ -564,6 +564,8 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl requestData.setWssConfig(wssConfig); + messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(securementTimeToLive)); + return requestData; } diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java index 63ba9179..4bb0b913 100755 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase.java @@ -70,9 +70,18 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa @Test public void testValidateUsernameTokenDigest() throws Exception { - EndpointInterceptor interceptor = prepareInterceptor("UsernameToken", true, true); - SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml"); + Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); + interceptor.setSecurementActions("UsernameToken"); + interceptor.setSecurementUsername("Bert"); + interceptor.setSecurementPassword("Ernie"); + interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); + + + SoapMessage message = loadSoap11Message("empty-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); + interceptor.handleRequest(messageContext); + + interceptor = prepareInterceptor("UsernameToken", true, true); interceptor.handleRequest(messageContext, null); assertValidateUsernameToken(message); @@ -91,7 +100,7 @@ public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCa assertNotNull("No Authentication created", SecurityContextHolder.getContext().getAuthentication()); } - protected EndpointInterceptor prepareInterceptor(String actions, boolean validating, boolean digest) + protected Wss4jSecurityInterceptor prepareInterceptor(String actions, boolean validating, boolean digest) throws Exception { Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); if (validating) { diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java index ba9f0eec..a69ab90e 100755 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j/Wss4jMessageInterceptorUsernameTokenTestCase.java @@ -49,9 +49,17 @@ public abstract class Wss4jMessageInterceptorUsernameTokenTestCase extends Wss4j @Test public void testValidateUsernameTokenDigest() throws Exception { - Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, true); - SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml"); + Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); + interceptor.setSecurementActions("UsernameToken"); + interceptor.setSecurementUsername("Bert"); + interceptor.setSecurementPassword("Ernie"); + interceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); + + SoapMessage message = loadSoap11Message("empty-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); + interceptor.handleRequest(messageContext); + + interceptor = prepareInterceptor("UsernameToken", true, true); interceptor.validateMessage(message, messageContext); assertValidateUsernameToken(message); }