public boolean verifyTimeoutCode(String timeoutCode,int pastIntervals,int futureIntervals) throws GeneralSecurityException {
  long currentInterval=clock.getCurrentInterval();
  String expectedResponse=generateResponseCode(currentInterval);
  if (expectedResponse.equals(timeoutCode)) {
    return true;
  }
  for (int i=1; i <= pastIntervals; i++) {
    String pastResponse=generateResponseCode(currentInterval - i);
    if (pastResponse.equals(timeoutCode)) {
      return true;
    }
  }
  for (int i=1; i <= futureIntervals; i++) {
    String futureResponse=generateResponseCode(currentInterval + i);
    if (futureResponse.equals(timeoutCode)) {
      return true;
    }
  }
  return false;
}

public boolean verifyTimeoutCode ( String timeoutCode , int pastIntervals , int futureIntervals ) throws GeneralSecurityException { long currentInterval = clock . getCurrentInterval ( ) ; String expectedResponse = generateResponseCode ( currentInterval ) ; if ( expectedResponse . equals ( timeoutCode ) ) { return true ; } for ( int i = 1 ; i <= pastIntervals ; i ++ ) { String pastResponse = generateResponseCode ( currentInterval - i ) ; if ( pastResponse . equals ( timeoutCode ) ) { return true ; } } for ( int i = 1 ; i <= futureIntervals ; i ++ ) { String futureResponse = generateResponseCode ( currentInterval + i ) ; if ( futureResponse . equals ( timeoutCode ) ) { return true ; } } return false ; }
verify a timeout code . the timeout code will be valid for a time determined by the interval period and the number of adjacent intervals checked .
