@Test public void testIsBlocked_yes() { FailedLogin failedLogin = new FailedLogin(Integer.valueOf(5), System.currentTimeMillis()); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } assertTrue(failedLogin.isLoginBlocked(Long.valueOf(1))); try { Thread.sleep(60000); } catch (InterruptedException e) { e.printStackTrace(); } assertFalse(failedLogin.isLoginBlocked(Long.valueOf(1))); }
public boolean isLoginBlocked(Long blockingTimeMin) { if (blockedTimestamp == null) { return false; } Long elapsedTimeMills = System.currentTimeMillis() - blockedTimestamp.longValue(); if (elapsedTimeMills <= blockingTimeMin * 60000) { return true; } return false; }
FailedLogin implements Serializable { public boolean isLoginBlocked(Long blockingTimeMin) { if (blockedTimestamp == null) { return false; } Long elapsedTimeMills = System.currentTimeMillis() - blockedTimestamp.longValue(); if (elapsedTimeMills <= blockingTimeMin * 60000) { return true; } return false; } }
FailedLogin implements Serializable { public boolean isLoginBlocked(Long blockingTimeMin) { if (blockedTimestamp == null) { return false; } Long elapsedTimeMills = System.currentTimeMillis() - blockedTimestamp.longValue(); if (elapsedTimeMills <= blockingTimeMin * 60000) { return true; } return false; } FailedLogin(Integer numAttempts_, Long blockedTimestamp_); }
FailedLogin implements Serializable { public boolean isLoginBlocked(Long blockingTimeMin) { if (blockedTimestamp == null) { return false; } Long elapsedTimeMills = System.currentTimeMillis() - blockedTimestamp.longValue(); if (elapsedTimeMills <= blockingTimeMin * 60000) { return true; } return false; } FailedLogin(Integer numAttempts_, Long blockedTimestamp_); boolean isTooManyAttempts(int attackPreventionMaxAttempts); Integer getNumAttempts(); void setNumAttempts(Integer numAttempts); boolean isLoginBlocked(Long blockingTimeMin); void setBlockedTimestamp(Long blockedTimestamp); }
FailedLogin implements Serializable { public boolean isLoginBlocked(Long blockingTimeMin) { if (blockedTimestamp == null) { return false; } Long elapsedTimeMills = System.currentTimeMillis() - blockedTimestamp.longValue(); if (elapsedTimeMills <= blockingTimeMin * 60000) { return true; } return false; } FailedLogin(Integer numAttempts_, Long blockedTimestamp_); boolean isTooManyAttempts(int attackPreventionMaxAttempts); Integer getNumAttempts(); void setNumAttempts(Integer numAttempts); boolean isLoginBlocked(Long blockingTimeMin); void setBlockedTimestamp(Long blockedTimestamp);  }