Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions PasswordLockoutRequirement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
public class PasswordLockoutRequirement extends Requirement {
private static final int FAILED_MAX = 5;
private static final int BEFORE_FAILING = 0;
private Integer failedAttempts;
private String uname;

public PasswordLockoutRequirement(String uname) {
super("Requirement 2: System must lock account after " + FAILED_MAX + " failed attempts.");
this.failedAttempts = BEFORE_FAILING;
this.uname = uname;
}

public void recordFailedAttempt() {
failedAttempts += 1;
}

public void resetFailedAttempts() {
failedAttempts = BEFORE_FAILING;
}

private boolean isMaxFailedAttemptsReached() {
return failedAttempts >= FAILED_MAX;
}

@Override
public Checkable.CheckStatus check() {
if (uname == null || failedAttempts == null) {
return CheckStatus.INCOMPLETE;
}

boolean failedAttemptsCheck = isMaxFailedAttemptsReached();

System.out.println("2: Amount of failed attempts exceeds " + FAILED_MAX + " - " + (failedAttemptsCheck ? "PASS" : "FAIL"));

return failedAttemptsCheck ? CheckStatus.PASS : CheckStatus.FAIL;
}
}
2 changes: 0 additions & 2 deletions PasswordMinimumLength.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

import rqcode.concepts.Requirement;

public class PasswordMinimumLength extends Requirement {
private static final int MIN_LENGTH = 8;
private static final int MAX_LENGTH = 64;
Expand Down
3 changes: 0 additions & 3 deletions PasswordPolicy.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
package rqcode.tutorial.tutorial_new;
import rqcode.concepts.CombinedRequirements;
import rqcode.concepts.Requirement;
import java.util.Arrays;
import java.util.List;

Expand Down