public boolean isExpired(final TicketState ticketState) { // Ticket has been used, check maxTimeToLive (hard window) if ((System.currentTimeMillis() - ticketState.getCreationTime() >= maxTimeToLiveInMilliSeconds)) { LOGGER.debug( "Ticket is expired because the time since creation is greater than maxTimeToLiveInMilliSeconds"); return true; } // Ticket is within hard window, check timeToKill (sliding window) if ((System.currentTimeMillis() - ticketState.getLastTimeUsed() >= timeToKillInMilliSeconds)) { LOGGER.debug( "Ticket is expired because the time since last use is greater than timeToKillInMilliseconds"); return true; } return false; }
public boolean isExpired(final TicketState ticketState) { return (ticketState == null) || (System.currentTimeMillis() - ticketState.getLastTimeUsed() >= this.timeToKillInMilliSeconds); }