Class Token

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    UserToken

    @Entity
    public abstract class Token
    extends PersistentObject
    Abstract base class for all tokens. A UUID token will be generated on instantiation. An expiration period has to be given in constructor.
    Author:
    Daniel Koch, Nils Bühner
    See Also:
    Serialized Form
    • Constructor Detail

      • Token

        protected Token​(int expirationInMinutes)
        Constructor
        Parameters:
        expirationInMinutes - The expiration period in minutes
    • Method Detail

      • expiresWithin

        public boolean expiresWithin​(int minutes)
        Helper method that returns true, if the token is expired in the given number of minutes (starting from the current point of time).
        Parameters:
        minutes -
        Returns:
        Whether or not the token expires within the given number of minutes.
      • getToken

        public java.lang.String getToken()
        Returns:
        the token
      • getExpirationDate

        public org.joda.time.ReadableDateTime getExpirationDate()
        Returns:
        the expirationDate
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class PersistentObject
        See Also:
        According to http://stackoverflow.com/questions/27581/overriding-equals -and-hashcode-in-java it is recommended only to use getter-methods when using ORM like Hibernate
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class PersistentObject
        See Also:
        According to http://stackoverflow.com/questions/27581/overriding-equals -and-hashcode-in-java it is recommended only to use getter-methods when using ORM like Hibernate