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 7d4301e..8b15cbb 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 @@ -546,6 +546,7 @@ } requestData.setTimeToLive(securementTimeToLive); + messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(securementTimeToLive)); requestData.setUseDerivedKey(securementUseDerivedKey); 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 63ba917..0ad5f47 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 @@ -16,24 +16,26 @@ package org.springframework.ws.soap.security.wss4j; +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + import java.util.Properties; +import org.apache.ws.security.WSConstants; +import org.junit.After; +import org.junit.Test; import org.springframework.security.authentication.AuthenticationManager; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.provisioning.InMemoryUserDetailsManager; +import org.springframework.ws.client.support.interceptor.ClientInterceptor; import org.springframework.ws.context.DefaultMessageContext; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j.callback.SpringSecurityPasswordValidationCallbackHandler; - -import org.apache.ws.security.WSConstants; -import org.junit.After; -import org.junit.Test; - -import static org.easymock.EasyMock.*; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; public abstract class Wss4jMessageInterceptorSpringSecurityCallbackHandlerTestCase extends Wss4jTestCase { @@ -70,9 +72,15 @@ @Test public void testValidateUsernameTokenDigest() throws Exception { + Wss4jSecurityInterceptor clientInterceptor = new Wss4jSecurityInterceptor(); + clientInterceptor.setSecurementActions("UsernameToken"); + clientInterceptor.setSecurementUsername("Bert"); + clientInterceptor.setSecurementPassword("Ernie"); + clientInterceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); EndpointInterceptor interceptor = prepareInterceptor("UsernameToken", true, true); SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); + clientInterceptor.handleRequest(messageContext); interceptor.handleRequest(messageContext, null); assertValidateUsernameToken(message); 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 ba9f0ee..445d4fa 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 @@ -22,7 +22,6 @@ import org.springframework.ws.context.MessageContext; import org.springframework.ws.soap.SoapMessage; import org.springframework.ws.soap.security.wss4j.callback.SimplePasswordValidationCallbackHandler; - import org.apache.ws.security.WSConstants; import org.junit.Test; import org.w3c.dom.Document; @@ -49,9 +48,15 @@ @Test public void testValidateUsernameTokenDigest() throws Exception { + Wss4jSecurityInterceptor clientInterceptor = new Wss4jSecurityInterceptor(); + clientInterceptor.setSecurementActions("UsernameToken"); + clientInterceptor.setSecurementUsername("Bert"); + clientInterceptor.setSecurementPassword("Ernie"); + clientInterceptor.setSecurementPasswordType(WSConstants.PW_DIGEST); Wss4jSecurityInterceptor interceptor = prepareInterceptor("UsernameToken", true, true); SoapMessage message = loadSoap11Message("usernameTokenDigest-soap.xml"); MessageContext messageContext = new DefaultMessageContext(message, getSoap11MessageFactory()); + clientInterceptor.handleRequest(messageContext); interceptor.validateMessage(message, messageContext); assertValidateUsernameToken(message); } diff --git a/spring-ws-security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenDigest-soap.xml b/spring-ws-security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenDigest-soap.xml index 98d82b7..a3e0f6b 100755 --- a/spring-ws-security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenDigest-soap.xml +++ b/spring-ws-security/src/test/resources/org/springframework/ws/soap/security/wss4j/usernameTokenDigest-soap.xml @@ -1,6 +1,5 @@ - -BertkwNstEaiFOrI7B31j7GuETYvdgk=9mdsYDCrjjYRur0rxzYt2oD72006-06-01T23:48:42Z + QQQ