public AccountLock checkForAccountLock(String username, String realmName) throws SecurityErrorException,
AccountLockedException {
// Get the user lockout policy
int maxLogonAttemptsBeforeLock = 0;
int lockDuration = 0;
Realm realm;
try {
realm = UserDatabaseManager.getInstance().getRealm(realmName);
} catch (Exception e1) {
throw new SecurityErrorException(SecurityErrorException.INTERNAL_ERROR, e1, "Failed to determine the realm name " + realmName + ".");
}
try {
maxLogonAttemptsBeforeLock = Property.getPropertyInt(new RealmKey("security.maxLogonAttemptsBeforeLock",
realm.getResourceId()));
lockDuration = Property.getPropertyInt(new RealmKey("security.lockDuration", realm.getResourceId()));
} catch (Exception e) {
throw new SecurityErrorException(SecurityErrorException.INTERNAL_ERROR, e, "Failed to determine password lockout policy.");
}
// Get the current lock (if any)
AccountLock lock = "true".equals(SystemProperties.get("adito.recoveryMode", "false")) ? null