From c668abdc6c26fe89da731b3d40f40d66c0074a8e Mon Sep 17 00:00:00 2001 From: Ikechukwu Ezugworie Date: Wed, 12 Feb 2025 10:31:03 +0300 Subject: [PATCH 1/2] chore: implemented passwordLockRequirement class to --- PasswordLockoutRequirement.java | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 PasswordLockoutRequirement.java diff --git a/PasswordLockoutRequirement.java b/PasswordLockoutRequirement.java new file mode 100644 index 0000000..b2009b0 --- /dev/null +++ b/PasswordLockoutRequirement.java @@ -0,0 +1,48 @@ +package rqcode.tutorial.tutorial_new; + + +public class PasswordLockoutRequirement extends Requirement { + /** + * TODO Track and increment the count of failed login attempts for a specific user. + * TODO Determine whether an account is locked after 5 consecutive failed login attempts. + * TODO Provide a way to reset failed login attempts after a successful login or manual reset. + * TODO Evaluate whether the lockout condition has been met and return the appropriate status using the check() method. + */ + + + private int failedAttempts; + private boolean isLocked; + + public PasswordLockoutRequirement(String username) { + super(username); + failedAttempts = 0; + isLocked = false; + } + + @Override + public CheckStatus check() { + + if (this.getStatement() == null) { //check that the username is not null and was properly initialized. + return CheckStatus.INCOMPLETE; + } + + + if (!isLocked && failedAttempts < 5) { //check that the account is locked and there have been 5 consecutive failed attempts + return CheckStatus.PASS; + } + return CheckStatus.FAIL; + } + + + public void resetFailedAttempts() { + failedAttempts = 0; //reset failed login attempts + } + + + public void recordFailedAttempt() { + failedAttempts += 1; + } + + + +} From b002a03a7b3f2513782feaa2d4f0ba099cad23b4 Mon Sep 17 00:00:00 2001 From: Ikechukwu Ezugworie Date: Wed, 12 Feb 2025 11:05:35 +0300 Subject: [PATCH 2/2] fix: removed package --- PasswordLockoutRequirement.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/PasswordLockoutRequirement.java b/PasswordLockoutRequirement.java index b2009b0..6d92367 100644 --- a/PasswordLockoutRequirement.java +++ b/PasswordLockoutRequirement.java @@ -1,6 +1,3 @@ -package rqcode.tutorial.tutorial_new; - - public class PasswordLockoutRequirement extends Requirement { /** * TODO Track and increment the count of failed login attempts for a specific user.