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
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public void windowClosing(WindowEvent e) {
});

pack();

// Message can be several lines, grow to fit
passwordTextArea.setSize(passwordTextArea.getWidth(), Short.MAX_VALUE);
passwordPane.setPreferredSize(new Dimension(passwordPane.getWidth(), passwordTextArea.getPreferredSize().height));
pack();

Dimension dlgSize = getPreferredSize();
Dimension frmSize = parent.getSize();
Point loc = parent.getLocation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,27 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s
LoginStatus loginStatus = null;

if (authorized) {
// If password expiration is enabled, do checks now
if (passwordRequirements.getExpiration() > 0) {
long passwordTime = credentials.getPasswordDate().getTimeInMillis();
long currentTime = System.currentTimeMillis();
String changeReason = null;

// If password expiration is enabled, do checks now
if ((passwordRequirements.getExpiration() > 0)
&& loginRequirementsChecker.isPasswordExpired(credentials.getPasswordDate().getTimeInMillis(), currentTime)) {
changeReason = "Your password has expired.";
} else {
// Check if it meets the current requirements
List<String> requirementFailures = PasswordRequirementsChecker.getInstance().doesPasswordMeetRequirements(null, plainPassword, passwordRequirements);

// If the password is expired, do grace period checks
if (loginRequirementsChecker.isPasswordExpired(passwordTime, currentTime)) {
if (requirementFailures != null) {
changeReason = "Your password does not meet requirements: " + StringUtils.join(requirementFailures, "; ") + ".";
}
}

// If a change is required, handle grace period checks
if (changeReason != null) {
// Let 0 be infinite grace period, -1 be no grace period
if (passwordRequirements.getGracePeriod() == 0) {
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. Please change your password now.", validUser.getUsername());
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, changeReason + " Please change your password now.", validUser.getUsername());
} else if (passwordRequirements.getGracePeriod() > 0) {
// If there has never been a grace time, start it now
long gracePeriodStartTime;
Expand All @@ -360,13 +371,13 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s

long graceTimeRemaining = loginRequirementsChecker.getGraceTimeRemaining(gracePeriodStartTime, currentTime);
if (graceTimeRemaining > 0) {
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, "Your password has expired. You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".", validUser.getUsername());
loginStatus = new LoginStatus(LoginStatus.Status.SUCCESS_GRACE_PERIOD, changeReason + " You are required to change your password in the next " + loginRequirementsChecker.getPrintableGraceTimeRemaining(graceTimeRemaining) + ".", validUser.getUsername());
}
}

// If there is no grace period or it has passed, FAIL_EXPIRED
if (loginStatus == null) {
loginStatus = new LoginStatus(LoginStatus.Status.FAIL_EXPIRED, "Your password has expired. Please contact an administrator to have your password reset.");
loginStatus = new LoginStatus(LoginStatus.Status.FAIL_EXPIRED, changeReason + " Please contact an administrator to have your password reset.");
}

/*
Expand All @@ -378,7 +389,6 @@ public LoginStatus authorizeUser(String username, String plainPassword, String s
SqlConfig.getInstance().getSqlSessionManager().update("User.clearGracePeriod", validUser.getId());
}
}
}
// End of password expiration and grace period checks

// If nothing failed (loginStatus != null), set SUCCESS now
Expand Down
Loading