org.apache.ws.security.message.token
Class Timestamp

java.lang.Object
  extended by org.apache.ws.security.message.token.Timestamp

public class Timestamp
extends java.lang.Object

Timestamp according to SOAP Message Security 1.0, chapter 10 / appendix A.2

Author:
Christof Soehngen (christof.soehngen@syracom.de)

Field Summary
protected  java.util.Date createdDate
           
protected  java.util.List<org.w3c.dom.Element> customElements
           
protected  org.w3c.dom.Element element
           
protected  java.util.Date expiresDate
           
 
Constructor Summary
Timestamp(boolean milliseconds, org.w3c.dom.Document doc, int ttl)
          Constructs a Timestamp object according to the defined parameters.
Timestamp(org.w3c.dom.Element timestampElement)
          Constructs a Timestamp object and parses the wsu:Timestamp element to initialize it.
Timestamp(org.w3c.dom.Element timestampElement, boolean bspCompliant)
          Constructs a Timestamp object and parses the wsu:Timestamp element to initialize it.
 
Method Summary
 void addCustomElement(org.w3c.dom.Document doc, org.w3c.dom.Element customElement)
          Creates and adds a custom element to this Timestamp
 void addWSUNamespace()
          Add the WSU Namespace to this T.
 java.util.Date getCreated()
          Get the time of creation.
 java.util.List<org.w3c.dom.Element> getCustomElements()
          Get the the custom elements from this Timestamp
 org.w3c.dom.Element getElement()
          Returns the dom element of this Timestamp object.
 java.util.Date getExpires()
          Get the time of expiration.
 java.lang.String getID()
           
 boolean isExpired()
          Return true if the current Timestamp is expired, meaning if the "Expires" value is before the current time.
 void setID(java.lang.String id)
          Set wsu:Id attribute of this timestamp
 java.lang.String toString()
          Returns the string representation of the token.
 boolean verifyCreated(int timeToLive, int futureTimeToLive)
          Return true if the "Created" value is before the current time minus the timeToLive argument, and if the Created value is not "in the future".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

element

protected org.w3c.dom.Element element

customElements

protected java.util.List<org.w3c.dom.Element> customElements

createdDate

protected java.util.Date createdDate

expiresDate

protected java.util.Date expiresDate
Constructor Detail

Timestamp

public Timestamp(org.w3c.dom.Element timestampElement)
          throws WSSecurityException
Constructs a Timestamp object and parses the wsu:Timestamp element to initialize it.

Parameters:
timestampElement - the wsu:Timestamp element that contains the timestamp data
Throws:
WSSecurityException

Timestamp

public Timestamp(org.w3c.dom.Element timestampElement,
                 boolean bspCompliant)
          throws WSSecurityException
Constructs a Timestamp object and parses the wsu:Timestamp element to initialize it.

Parameters:
timestampElement - the wsu:Timestamp element that contains the timestamp data
bspCompliant - whether the Timestamp processing complies with the BSP spec
Throws:
WSSecurityException

Timestamp

public Timestamp(boolean milliseconds,
                 org.w3c.dom.Document doc,
                 int ttl)
Constructs a Timestamp object according to the defined parameters.

Parameters:
doc - the SOAP envelope as Document
ttl - the time to live (validity of the security semantics) in seconds
Method Detail

addWSUNamespace

public void addWSUNamespace()
Add the WSU Namespace to this T. The namespace is not added by default for efficiency purposes.


getElement

public org.w3c.dom.Element getElement()
Returns the dom element of this Timestamp object.

Returns:
the wsse:UsernameToken element

toString

public java.lang.String toString()
Returns the string representation of the token.

Overrides:
toString in class java.lang.Object
Returns:
a XML string representation

getCreated

public java.util.Date getCreated()
Get the time of creation.

Returns:
the "created" time

getExpires

public java.util.Date getExpires()
Get the time of expiration.

Returns:
the "expires" time

addCustomElement

public void addCustomElement(org.w3c.dom.Document doc,
                             org.w3c.dom.Element customElement)
Creates and adds a custom element to this Timestamp


getCustomElements

public java.util.List<org.w3c.dom.Element> getCustomElements()
Get the the custom elements from this Timestamp

Returns:
the list containing the custom elements.

setID

public void setID(java.lang.String id)
Set wsu:Id attribute of this timestamp

Parameters:
id -

getID

public java.lang.String getID()
Returns:
the value of the wsu:Id attribute

isExpired

public boolean isExpired()
Return true if the current Timestamp is expired, meaning if the "Expires" value is before the current time. It returns false if there is no Expires value.


verifyCreated

public boolean verifyCreated(int timeToLive,
                             int futureTimeToLive)
Return true if the "Created" value is before the current time minus the timeToLive argument, and if the Created value is not "in the future".

Parameters:
timeToLive - the value in seconds for the validity of the Created time
futureTimeToLive - the value in seconds for the future validity of the Created time
Returns:
true if the timestamp is before (now-timeToLive), false otherwise


Copyright © 2004-2011 The Apache Software Foundation. All Rights Reserved.