com.preemptive.instrumentation
Class Token

java.lang.Object
  extended by com.preemptive.instrumentation.Token

public final class Token
extends Object

The token that defines either an absolute or relative expiration date with or without a warning period. It can also be used to hold String properties that are available at runtime.


Field Summary
static boolean DEBUG
          This can be used to produce debug output to System.err when testing applications.
 
Method Summary
 int getDaysTillExpiration()
          Get the number of days until the expiration date will be reached.
 Date getExpirationDate()
          Get the expiration date stored in the token.
 String getID()
          Get the Shelf Life ID used to create the token.
 Properties getProperties()
          Get the properties stored in the token.
static Token getToken(Date startDate, File file)
          Read a token that uses a relative dates from a file.
static Token getToken(Date startDate, Reader reader)
          Read a token.
static Token getToken(Date startDate, String encoded)
          Read a token stored in a string.
static Token getToken(File file)
          Read a token that has been stored in a file.
static Token getToken(Reader reader)
          Read a token.
static Token getToken(String encoded)
          Read a token stored in a string.
 Date getWarningDate()
          Get the warning date stored in the token.
 boolean hasWarningDate()
          Does the token have a warning date set?
 boolean isExpired()
          Has the token expired?
 boolean isInWarning()
          Is the current time after the warning date?
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
This can be used to produce debug output to System.err when testing applications. It should not be used in production releases.

Method Detail

hasWarningDate

public boolean hasWarningDate()
Does the token have a warning date set?

Returns:
true if the token has a warning date set

getWarningDate

public Date getWarningDate()
Get the warning date stored in the token.

Returns:
the warning date or null if none has been set

getExpirationDate

public Date getExpirationDate()
Get the expiration date stored in the token.

Returns:
the expiration date

isInWarning

public boolean isInWarning()
Is the current time after the warning date?

Returns:
true if the current time is after the warning date. If the token does not contain a warning date the false is returned.

isExpired

public boolean isExpired()
Has the token expired?

Returns:
true if the token has an expiration data set and the current time is after the expiration date.

getID

public String getID()
Get the Shelf Life ID used to create the token.

Returns:
The Shelf Life ID used to create the token.

getDaysTillExpiration

public int getDaysTillExpiration()
Get the number of days until the expiration date will be reached.

Returns:
the number of days before the expiration date will be reached.

getProperties

public Properties getProperties()
Get the properties stored in the token.

Returns:
the properties stored in the token.

getToken

public static Token getToken(File file)
Read a token that has been stored in a file. This cannot be used with token that contain relative dates, use getToken(Date, File).

Parameters:
file - the file that contains the token encoded as a base64 string.
Returns:
the token or null if token cannot be read from the file.

getToken

public static Token getToken(Date startDate,
                             File file)
Read a token that uses a relative dates from a file.

Parameters:
startDate - the starting data for the relative dates.
file - the file that contains the token encoded as a base64 string.
Returns:
the token or null if token cannot be read from the file.
See Also:
getToken(File)

getToken

public static Token getToken(Reader reader)
Read a token. This cannot be used with token that contain relative dates, use getToken(Date, Reader).

Parameters:
reader - contains the token encoded as a base64 string. This is closed at the end of this method.
Returns:
the extracted token or null on any error.

getToken

public static Token getToken(Date startDate,
                             Reader reader)
Read a token.

Parameters:
reader - contains the token encoded as a base64 string. This is closed at the end of this method.
Returns:
the extracted token or null on any error.
See Also:
getToken(Reader)

getToken

public static Token getToken(String encoded)
Read a token stored in a string. This cannot be used with token that contain relative dates, use getToken(Date, String).

Parameters:
encoded - a token encoded as a base64 string.
Returns:
the extracted token or null on any error.

getToken

public static Token getToken(Date startDate,
                             String encoded)
Read a token stored in a string.

Parameters:
encoded - a token encoded as a base64 string
Returns:
the extracted token or null on any error.
See Also:
getToken(String)


Copyright © 2013 PreEmptive Solutions, LLC. All Rights Reserved.