Some times, when connecting to ONVIF cameras, I have to spoof my local
time to the camer's time for ONVIF and WS-Security to work. Here is a
patch to allow a custom WSTimeSource to be assinged to a Axis2
connection. David
Index:
modules/rampart-core/src/main/java/org/apache/rampart/RampartMessageData.java
===================================================================
---
modules/rampart-core/src/main/java/org/apache/rampart/RampartMessageData.java
(revision 1629724)
+++
modules/rampart-core/src/main/java/org/apache/rampart/RampartMessageData.java
(working copy)
@@ -58,6 +58,7 @@
import org.apache.ws.security.message.token.SecurityContextToken;
import org.apache.ws.security.util.Loader;
import org.apache.ws.security.util.WSSecurityUtil;
+import org.apache.ws.security.util.WSTimeSource;
import org.w3c.dom.Document;
import java.util.ArrayList;
@@ -103,6 +104,11 @@
public final static String KEY_WST_VERSION = "wstVersion";
public final static String PARAM_CLIENT_SIDE = "CLIENT_SIDE";
+
+ /**
+ * Key to hold the WSTimeSource
+ */
+ public final static String CUSTOM_WS_TIME_SOURCE = "wsTimeSource";
/**
* Key to hold the WS-SecConv version
@@ -180,6 +186,14 @@
//Update the UsernameToken validator
this.config.setValidator(WSSecurityEngine.USERNAME_TOKEN,
RampartUsernameTokenValidator.class);
+
+ // set the Time Source
+ try {
+ WSTimeSource wsTimeSource =
(WSTimeSource)msgCtx.getProperty(CUSTOM_WS_TIME_SOURCE);
+ if (wsTimeSource != null)
this.config.setCurrentTime(wsTimeSource);
+ } catch (Exception e) {
+ throw new RampartException("errorInWSTimeSource", e);
+ }
// First obtain the axis service as we have to do a null
check, there can be situations
// where Axis Service is null
--
David R Robison
Open Roads Consulting, Inc.
103 Watson Road, Chesapeake, VA 23320
phone: +1 757-546-3401
e-mail: [email protected]
web: http://www.openroadsconsulting.com
blog: http://therobe.blogspot.com
book: http://www.xulonpress.com/bookstore/bookdetail.php?PB_ISBN=9781597816526
This email communication (including any attachments) may contain confidential
and/or privileged material intended solely for the individual or entity to
which it is addressed.
If you are not the intended recipient, please delete this email immediately.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]