Class Timestamp

java.lang.Object
org.apache.wss4j.dom.message.token.Timestamp

public class Timestamp extends Object
Timestamp according to SOAP Message Security 1.0, chapter 10 / appendix A.2
  • Constructor Summary

    Constructors
    Constructor
    Description
    Timestamp(boolean milliseconds, Document doc, int ttl)
    Constructs a Timestamp object according to the defined parameters.
    Timestamp(boolean milliseconds, Document doc, WSTimeSource timeSource, int ttl)
    Constructs a Timestamp object according to the defined parameters.
    Timestamp(Element timestampElement, BSPEnforcer bspEnforcer)
    Constructs a Timestamp object and parses the wsu:Timestamp element to initialize it.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add the WSU Namespace to this T.
    boolean
    equals(Object object)
     
    Get the time of creation.
    Get the time of creation as a String
    Returns the dom element of this Timestamp object.
    Get the time of expiration.
     
    int
     
    boolean
    Return true if the current Timestamp is expired, meaning if the "Expires" value is before the current time.
    void
    Set wsu:Id attribute of this timestamp
    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, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Timestamp

      public Timestamp(Element timestampElement, BSPEnforcer bspEnforcer) 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
      bspEnforcer - a BSPEnforcer instance to enforce BSP rules
      Throws:
      WSSecurityException
    • Timestamp

      public Timestamp(boolean milliseconds, 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
    • Timestamp

      public Timestamp(boolean milliseconds, Document doc, WSTimeSource timeSource, 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 Details

    • addWSUNamespace

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

      public Element getElement()
      Returns the dom element of this Timestamp object.
      Returns:
      the wsse:UsernameToken element
    • toString

      public String toString()
      Returns the string representation of the token.
      Overrides:
      toString in class Object
      Returns:
      a XML string representation
    • getCreated

      public Instant getCreated()
      Get the time of creation.
      Returns:
      the "created" time
    • getCreatedString

      public String getCreatedString()
      Get the time of creation as a String
      Returns:
      the time of creation as a String
    • getExpires

      public Instant getExpires()
      Get the time of expiration.
      Returns:
      the "expires" time
    • setID

      public void setID(String id)
      Set wsu:Id attribute of this timestamp
      Parameters:
      id -
    • getID

      public 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
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object