Skip to content

Commit

Permalink
fixed some code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Oct 3, 2023
1 parent c336277 commit 3942d4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private static void notifyBruteForceAttack(String suspectedUsername, String susp
}

private static List<User> getRecipients() throws PersistenceException {
List<User> recipients = new ArrayList<User>();
List<User> recipients = new ArrayList<>();
String setting = Context.get().getProperties().getProperty("throttle.alert.recipients", "");
if (StringUtils.isNotEmpty(setting)) {
UserDAO uDao = (UserDAO) Context.get().getBean(UserDAO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
*/
public class BruteForcePanel extends AdminPanel {

private static final String RECIPIENTS = "recipients";

private static final String ATTEMPTS = "attempts";

private static final String THROTTLE_IP_WAIT = "throttle.ip.wait";
Expand Down Expand Up @@ -147,10 +149,10 @@ private void initForm(Map<String, String> params) {
// Nothing to do
}

MultiComboBoxItem recipients = ItemFactory.newMultiComboBoxItem("recipients", "alertrecipients",
MultiComboBoxItem recipients = ItemFactory.newMultiComboBoxItem(RECIPIENTS, "alertrecipients",
new UsersDS(null, false, false),
params.get(THROTTLE_ALERT_RECIPIENTS) != null && !params.get(THROTTLE_ALERT_RECIPIENTS).trim().isEmpty()
? params.get(THROTTLE_ALERT_RECIPIENTS).trim().split("[,]")
? params.get(THROTTLE_ALERT_RECIPIENTS).trim().split(",")
: null);
recipients.setValueField("username");
recipients.setDisplayField("username");
Expand Down Expand Up @@ -264,9 +266,9 @@ public void onSave() {
params[5] = new GUIParameter(THROTTLE_USERNAME_DISABLEUSER,
"yes".equals(values.get("usernamedisableuser").toString()) ? "true" : "false");

if (values.get("recipients") != null) {
if (values.get(RECIPIENTS) != null) {
@SuppressWarnings("unchecked")
ArrayList<String> usernames = (ArrayList<String>) values.get("recipients");
ArrayList<String> usernames = (ArrayList<String>) values.get(RECIPIENTS);
params[6] = new GUIParameter(THROTTLE_ALERT_RECIPIENTS,
usernames.stream().collect(Collectors.joining(",")));
} else {
Expand Down

0 comments on commit 3942d4d

Please sign in to comment.