Skip to content

Instantly share code, notes, and snippets.

@juriad
Created November 24, 2015 07:03
Show Gist options
  • Select an option

  • Save juriad/a2b17384ccdc89f2aa2a to your computer and use it in GitHub Desktop.

Select an option

Save juriad/a2b17384ccdc89f2aa2a to your computer and use it in GitHub Desktop.
public void test() throws TheDoctorException {
long currentTimeMillis = System.currentTimeMillis();
long lastTimeInMillis = getLastKnownTimestamp(currentTimeMillis);
long tamperedTimeInMillis = getTamperedTimestamp(currentTimeMillis);
// logger.debug("Last time: " + lastTimeInMillis + "; tampered time: " + tamperedTimeInMillis);
if (currentTimeMillis < lastTimeInMillis - TIME_OFFSET
|| tamperedTimeInMillis < lastTimeInMillis - TIME_OFFSET) {
block(tamperedTimeInMillis, lastTimeInMillis);
// logger.warn("Somebody played with system time.");
// logger.warn("It is now: " + currentTimeMillis);
// logger.warn("Was last time: " + lastTimeInMillis);
// logger.warn("And once it was: " + tamperedTimeInMillis);
throw new TheDoctorException("I'm the Doctor. "
+ "I'm a Time Lord. "
+ "I'm from the planet Gallifrey in the constellation of Kasterborous. "
+ "I am 903 years old and I'm the man who's gonna save your lives, and all six billion people on the planet below. "
+ "You got a problem with that?"
+ "\nIt is now: " + currentTimeMillis
+ "\nWas last time: " + lastTimeInMillis
+ "\nAnd once it was: " + tamperedTimeInMillis);
} else {
block(null, currentTimeMillis);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment