private boolean checkRequestedKeyAge(String keyEntry) throws NumberFormatException {
  long requestedTokenKeyTS=Long.parseLong(keyEntry);
  long now=System.currentTimeMillis();
  long diff=now - requestedTokenKeyTS;
  if (diff > (2 * _keyRotationIntervalInMsecs)) {
    _log.debug("Requested key is older than twice the rotation intervale: {}",keyEntry);
    return false;
  }
  long youngestKey=Long.parseLong(_cachedTokenKeysBundle.getCurrentKeyEntry());
  if (youngestKey < Long.parseLong(keyEntry)) {
    _log.debug("Requested key is newer than the most recent cached key: {}",keyEntry);
    return false;
  }
  return true;
}

private boolean checkRequestedKeyAge ( String keyEntry ) throws NumberFormatException { long requestedTokenKeyTS = Long . parseLong ( keyEntry ) ; long now = System . currentTimeMillis ( ) ; long diff = now - requestedTokenKeyTS ; if ( diff > ( 2 * _keyRotationIntervalInMsecs ) ) { _log . debug ( "Requested key is older than twice the rotation intervale: {}" , keyEntry ) ; return false ; } long youngestKey = Long . parseLong ( _cachedTokenKeysBundle . getCurrentKeyEntry ( ) ) ; if ( youngestKey < Long . parseLong ( keyEntry ) ) { _log . debug ( "Requested key is newer than the most recent cached key: {}" , keyEntry ) ; return false ; } return true ; }
- if a key we are being requested is really old ( 2 * rotation time ) , we should not even look it up in our cache . because it could be there if our cache is old and we don ' t want to honor that key . - if a key is newer than our current key , we should udpate our cache
