diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java index f370b068..de89dd05 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java @@ -689,7 +689,13 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl requestData.setCallbackHandler(validationCallbackHandler); + messageContext.setProperty(WSHandlerConstants.TIMESTAMP_STRICT, timestampStrict); messageContext.setProperty(WSHandlerConstants.TTL_TIMESTAMP, Integer.toString(validationTimeToLive)); + messageContext.setProperty(WSHandlerConstants.TTL_FUTURE_TIMESTAMP, Integer.toString(futureTimeToLive)); + + requestData.setTimeStampStrict(timestampStrict); + requestData.setTimeStampTTL(validationTimeToLive); + requestData.setTimeStampFutureTTL(futureTimeToLive); requestData.setAllowRSA15KeyTransportAlgorithm(allowRSA15KeyTransportAlgorithm); diff --git a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java index 9c949d57..e8a1c34c 100644 --- a/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java +++ b/spring-ws-security/src/test/java/org/springframework/ws/soap/security/wss4j2/Wss4jMessageInterceptorTimestampTestCase.java @@ -74,6 +74,22 @@ public abstract class Wss4jMessageInterceptorTimestampTestCase extends Wss4jTest }); } + @Test + public void testValidateTimestampWithExpiredTtlCustomTtl() throws Exception { + + assertThatExceptionOfType(WsSecurityValidationException.class).isThrownBy(() -> { + + Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor(); + interceptor.setValidationActions("Timestamp"); + interceptor.setValidationTimeToLive(1); + interceptor.afterPropertiesSet(); + SoapMessage message = getMessageWithTimestamp(); + Thread.sleep(2000); + MessageContext context = new DefaultMessageContext(message, getSoap11MessageFactory()); + interceptor.validateMessage(message, context); + }); + } + @Test public void testSecureTimestampWithCustomTtl() throws Exception {