Skip to content

Commit

Permalink
CB-4617 NPE fix (#2349)
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenia Bezborodova <[email protected]>
  • Loading branch information
serge-rider and EvgeniaBzzz authored Feb 5, 2024
1 parent b7ab8b1 commit f8e74f9
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1410,10 +1410,12 @@ private String createNewAuthAttempt(
String authAttemptId = UUID.randomUUID().toString();
try (Connection dbCon = database.openConnection()) {
try (JDBCTransaction txn = new JDBCTransaction(dbCon)) {
if (smConfig.isCheckBruteforce()
&& this.getAuthProvider(authProviderId).getInstance() instanceof SMBruteForceProtected bruteforceProtected) {
BruteForceUtils.checkBruteforce(smConfig,
getLatestUserLogins(dbCon, authProviderId, bruteforceProtected.getInputUsername(authData).toString()));
if (smConfig.isCheckBruteforce() && this.getAuthProvider(authProviderId).getInstance() instanceof SMBruteForceProtected bruteforceProtected) {
Object inputUsername = bruteforceProtected.getInputUsername(authData);
if (inputUsername != null) {
BruteForceUtils.checkBruteforce(smConfig,
getLatestUserLogins(dbCon, authProviderId, inputUsername.toString()));
}
}
try (PreparedStatement dbStat = dbCon.prepareStatement(
database.normalizeTableNames(
Expand All @@ -1435,7 +1437,12 @@ private String createNewAuthAttempt(
}
dbStat.setString(7, isMainSession ? CHAR_BOOL_TRUE : CHAR_BOOL_FALSE);
if (this.getAuthProvider(authProviderId).getInstance() instanceof SMBruteForceProtected bruteforceProtected) {
dbStat.setString(8, bruteforceProtected.getInputUsername(authData).toString());
Object inputUsername = bruteforceProtected.getInputUsername(authData);
if (inputUsername != null) {
dbStat.setString(8, inputUsername.toString());
} else {
dbStat.setString(8, null);
}
} else {
dbStat.setString(8, null);
}
Expand Down

0 comments on commit f8e74f9

Please sign in to comment.