You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2013/10/14 13:50:48 UTC
svn commit: r1531861 - in /webservices/wss4j/trunk/ws-security-dom/src:
main/java/org/apache/wss4j/dom/message/token/Timestamp.java
test/java/org/apache/wss4j/dom/message/TimestampTest.java
Author: coheigea
Date: Mon Oct 14 11:50:48 2013
New Revision: 1531861
URL: http://svn.apache.org/r1531861
Log:
Allow Timestamps with no millisecond component
Modified:
webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java?rev=1531861&r1=1531860&r2=1531861&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java Mon Oct 14 11:50:48 2013
@@ -130,7 +130,8 @@ public class Timestamp {
throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
}
- if (createdCalendar.getFractionalSecond().scale() > 3) {
+ if (createdCalendar.getFractionalSecond() != null
+ && createdCalendar.getFractionalSecond().scale() > 3) {
bspEnforcer.handleBSPRule(BSPRule.R3220);
}
if (createdCalendar.getSecond() > 59) {
@@ -151,7 +152,8 @@ public class Timestamp {
throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY, e);
}
- if (expiresCalendar.getFractionalSecond().scale() > 3) {
+ if (expiresCalendar.getFractionalSecond() != null
+ && expiresCalendar.getFractionalSecond().scale() > 3) {
bspEnforcer.handleBSPRule(BSPRule.R3229);
}
if (expiresCalendar.getSecond() > 59) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java?rev=1531861&r1=1531860&r2=1531861&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java Mon Oct 14 11:50:48 2013
@@ -792,6 +792,35 @@ public class TimestampTest extends org.j
}
}
+ @org.junit.Test
+ public void testTimestampNoMilliseconds() throws Exception {
+
+ Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+ WSSecHeader secHeader = new WSSecHeader();
+ secHeader.insertSecurityHeader(doc);
+
+ WSSConfig wssConfig = WSSConfig.getNewInstance();
+ wssConfig.setPrecisionInMilliSeconds(false);
+ WSSecTimestamp timestamp = new WSSecTimestamp();
+ timestamp.setWsConfig(wssConfig);
+ timestamp.setTimeToLive(300);
+ Document createdDoc = timestamp.build(doc, secHeader);
+
+ if (LOG.isDebugEnabled()) {
+ String outputString =
+ XMLUtils.PrettyDocumentToString(createdDoc);
+ LOG.debug(outputString);
+ }
+
+ //
+ // Do some processing
+ //
+ List<WSSecurityEngineResult> wsResult = verify(createdDoc, WSSConfig.getNewInstance());
+ WSSecurityEngineResult actionResult =
+ WSSecurityUtil.fetchActionResult(wsResult, WSConstants.TS);
+ assertTrue(actionResult != null);
+ }
+
/**
* Verifies the soap envelope
*/