Source:
<code>public UserInfo findUserByCredentials(@Nullable WebContext ctx, String user, String password) { if (Strings.isEmpty(password)) { return null; } UserInfo result = findUserByName(ctx, user); if (result == null) { auditLog.negative("AuditLog.lockedOrNonexitentUserTriedLogin").forUser(null, user).log(); return null; } U account = result.getUserObject(getUserClass()); if (account.getUserAccountData().isExternalLoginRequired() && !isWithinInterval(account.getUserAccountData() .getLogin() .getLastExternalLogin(), account.getTenant() .getValue() .getTenantData() .getExternalLoginIntervalDays())) { completeAuditLogForUser(auditLog.negative("AuditLog.externalLoginRequired"), account); throw Exceptions.createHandled().withNLSKey("UserAccount.externalLoginMustBePerformed").handle(); } LoginData loginData = account.getUserAccountData().getLogin(); <START> if (acceptApiTokens && loginData.checkApiToken(password)) { <END> completeAuditLogForUser(auditLog.neutral("AuditLog.apiTokenLogin"), account); return result; } LoginData.PasswordVerificationResult pwResult = loginData.checkPassword(user, password); if (pwResult != LoginData.PasswordVerificationResult.INVALID) { completeAuditLogForUser(auditLog.neutral("AuditLog.passwordLogin"), account); if (pwResult == LoginData.PasswordVerificationResult.VALID_NEEDS_RE_HASH) { return updatePasswordHashing(result, password); } return result; } auditLog.negative("AuditLog.loginRejected") .forTenant(String.valueOf(account.getTenant().getId()), account.getTenant().getValue().getTenantData().getName()) .log(); return null; }</code><technical_language>latter</technical_language>

Target:
public UserInfo findUserByCredentials(@Nullable WebContext ctx, String user, String password) { if (Strings.isEmpty(password)) { return null; } UserInfo result = findUserByName(ctx, user); if (result == null) { auditLog.negative("AuditLog.lockedOrNonexitentUserTriedLogin").forUser(null, user).log(); return null; } U account = result.getUserObject(getUserClass()); if (account.getUserAccountData().isExternalLoginRequired() && !isWithinInterval(account.getUserAccountData() .getLogin() .getLastExternalLogin(), account.getTenant() .getValue() .getTenantData() .getExternalLoginIntervalDays())) { completeAuditLogForUser(auditLog.negative("AuditLog.externalLoginRequired"), account); throw Exceptions.createHandled().withNLSKey("UserAccount.externalLoginMustBePerformed").handle(); } LoginData loginData = account.getUserAccountData().getLogin(); if (acceptApiTokens && checkApiToken(loginData, password)) { completeAuditLogForUser(auditLog.neutral("AuditLog.apiTokenLogin"), account); return result; } LoginData.PasswordVerificationResult pwResult = loginData.checkPassword(user, password); if (pwResult != LoginData.PasswordVerificationResult.INVALID) { completeAuditLogForUser(auditLog.neutral("AuditLog.passwordLogin"), account); if (pwResult == LoginData.PasswordVerificationResult.VALID_NEEDS_RE_HASH) { return updatePasswordHashing(result, password); } return result; } auditLog.negative("AuditLog.loginRejected") .forTenant(String.valueOf(account.getTenant().getId()), account.getTenant().getValue().getTenantData().getName()) .log(); return null; }