@Test public void lockoutsWillBeAudited() { for(int i = 0; i < 11; i ++) { loginLimitManager.recordFailedAttempt("test-user", "a.b.c.d"); } verify(securityAuditManager, times(10)).logEvent("test-user", "Failed admin console login attempt", "A failed login attempt to the admin console was made from address a.b.c.d. "); verify(securityAuditManager, times(1)).logEvent("test-user", "Failed admin console login attempt", "A failed login attempt to the admin console was made from address a.b.c.d. Future login attempts from this address will be temporarily locked out. Future login attempts for this user will be temporarily locked out. "); }
public void recordFailedAttempt(String username, String address) { Log.warn("Failed admin console login attempt by "+username+" from "+address); Long cnt = (long)0; if (attemptsPerIP.get(address) != null) { cnt = attemptsPerIP.get(address); } cnt++; attemptsPerIP.put(address, cnt); final StringBuilder sb = new StringBuilder(); if (cnt > maxAttemptsPerIP) { Log.warn("Login attempt limit breached for address "+address); sb.append("Future login attempts from this address will be temporarily locked out. "); } cnt = (long)0; if (attemptsPerUsername.get(username) != null) { cnt = attemptsPerUsername.get(username); } cnt++; attemptsPerUsername.put(username, cnt); if (cnt > maxAttemptsPerUsername) { Log.warn("Login attempt limit breached for username "+username); sb.append("Future login attempts for this user will be temporarily locked out. "); } securityAuditManager.logEvent(username, "Failed admin console login attempt", "A failed login attempt to the admin console was made from address " + address + ". " + sb); }
LoginLimitManager { public void recordFailedAttempt(String username, String address) { Log.warn("Failed admin console login attempt by "+username+" from "+address); Long cnt = (long)0; if (attemptsPerIP.get(address) != null) { cnt = attemptsPerIP.get(address); } cnt++; attemptsPerIP.put(address, cnt); final StringBuilder sb = new StringBuilder(); if (cnt > maxAttemptsPerIP) { Log.warn("Login attempt limit breached for address "+address); sb.append("Future login attempts from this address will be temporarily locked out. "); } cnt = (long)0; if (attemptsPerUsername.get(username) != null) { cnt = attemptsPerUsername.get(username); } cnt++; attemptsPerUsername.put(username, cnt); if (cnt > maxAttemptsPerUsername) { Log.warn("Login attempt limit breached for username "+username); sb.append("Future login attempts for this user will be temporarily locked out. "); } securityAuditManager.logEvent(username, "Failed admin console login attempt", "A failed login attempt to the admin console was made from address " + address + ". " + sb); } }
LoginLimitManager { public void recordFailedAttempt(String username, String address) { Log.warn("Failed admin console login attempt by "+username+" from "+address); Long cnt = (long)0; if (attemptsPerIP.get(address) != null) { cnt = attemptsPerIP.get(address); } cnt++; attemptsPerIP.put(address, cnt); final StringBuilder sb = new StringBuilder(); if (cnt > maxAttemptsPerIP) { Log.warn("Login attempt limit breached for address "+address); sb.append("Future login attempts from this address will be temporarily locked out. "); } cnt = (long)0; if (attemptsPerUsername.get(username) != null) { cnt = attemptsPerUsername.get(username); } cnt++; attemptsPerUsername.put(username, cnt); if (cnt > maxAttemptsPerUsername) { Log.warn("Login attempt limit breached for username "+username); sb.append("Future login attempts for this user will be temporarily locked out. "); } securityAuditManager.logEvent(username, "Failed admin console login attempt", "A failed login attempt to the admin console was made from address " + address + ". " + sb); } private  LoginLimitManager();   LoginLimitManager(final SecurityAuditManager securityAuditManager, final TaskEngine taskEngine); }
LoginLimitManager { public void recordFailedAttempt(String username, String address) { Log.warn("Failed admin console login attempt by "+username+" from "+address); Long cnt = (long)0; if (attemptsPerIP.get(address) != null) { cnt = attemptsPerIP.get(address); } cnt++; attemptsPerIP.put(address, cnt); final StringBuilder sb = new StringBuilder(); if (cnt > maxAttemptsPerIP) { Log.warn("Login attempt limit breached for address "+address); sb.append("Future login attempts from this address will be temporarily locked out. "); } cnt = (long)0; if (attemptsPerUsername.get(username) != null) { cnt = attemptsPerUsername.get(username); } cnt++; attemptsPerUsername.put(username, cnt); if (cnt > maxAttemptsPerUsername) { Log.warn("Login attempt limit breached for username "+username); sb.append("Future login attempts for this user will be temporarily locked out. "); } securityAuditManager.logEvent(username, "Failed admin console login attempt", "A failed login attempt to the admin console was made from address " + address + ". " + sb); } private  LoginLimitManager();   LoginLimitManager(final SecurityAuditManager securityAuditManager, final TaskEngine taskEngine); static LoginLimitManager getInstance(); boolean hasHitConnectionLimit(String username, String address); void recordFailedAttempt(String username, String address); void recordSuccessfulAttempt(String username, String address); }
LoginLimitManager { public void recordFailedAttempt(String username, String address) { Log.warn("Failed admin console login attempt by "+username+" from "+address); Long cnt = (long)0; if (attemptsPerIP.get(address) != null) { cnt = attemptsPerIP.get(address); } cnt++; attemptsPerIP.put(address, cnt); final StringBuilder sb = new StringBuilder(); if (cnt > maxAttemptsPerIP) { Log.warn("Login attempt limit breached for address "+address); sb.append("Future login attempts from this address will be temporarily locked out. "); } cnt = (long)0; if (attemptsPerUsername.get(username) != null) { cnt = attemptsPerUsername.get(username); } cnt++; attemptsPerUsername.put(username, cnt); if (cnt > maxAttemptsPerUsername) { Log.warn("Login attempt limit breached for username "+username); sb.append("Future login attempts for this user will be temporarily locked out. "); } securityAuditManager.logEvent(username, "Failed admin console login attempt", "A failed login attempt to the admin console was made from address " + address + ". " + sb); } private  LoginLimitManager();   LoginLimitManager(final SecurityAuditManager securityAuditManager, final TaskEngine taskEngine); static LoginLimitManager getInstance(); boolean hasHitConnectionLimit(String username, String address); void recordFailedAttempt(String username, String address); void recordSuccessfulAttempt(String username, String address);  }