From 3942d4d6cc794a915b17459e27d4888df1d33f73 Mon Sep 17 00:00:00 2001 From: car031 Date: Tue, 3 Oct 2023 08:27:04 +0200 Subject: [PATCH] fixed some code smells --- .../com/logicaldoc/core/security/LoginThrottle.java | 2 +- .../gui/frontend/client/security/BruteForcePanel.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/logicaldoc-core/src/main/java/com/logicaldoc/core/security/LoginThrottle.java b/logicaldoc-core/src/main/java/com/logicaldoc/core/security/LoginThrottle.java index d98852e7f..7f6e26baf 100644 --- a/logicaldoc-core/src/main/java/com/logicaldoc/core/security/LoginThrottle.java +++ b/logicaldoc-core/src/main/java/com/logicaldoc/core/security/LoginThrottle.java @@ -288,7 +288,7 @@ private static void notifyBruteForceAttack(String suspectedUsername, String susp } private static List getRecipients() throws PersistenceException { - List recipients = new ArrayList(); + List recipients = new ArrayList<>(); String setting = Context.get().getProperties().getProperty("throttle.alert.recipients", ""); if (StringUtils.isNotEmpty(setting)) { UserDAO uDao = (UserDAO) Context.get().getBean(UserDAO.class); diff --git a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/security/BruteForcePanel.java b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/security/BruteForcePanel.java index 8109bbc71..4ff12c01c 100644 --- a/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/security/BruteForcePanel.java +++ b/logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/security/BruteForcePanel.java @@ -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"; @@ -147,10 +149,10 @@ private void initForm(Map 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"); @@ -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 usernames = (ArrayList) values.get("recipients"); + ArrayList usernames = (ArrayList) values.get(RECIPIENTS); params[6] = new GUIParameter(THROTTLE_ALERT_RECIPIENTS, usernames.stream().collect(Collectors.joining(","))); } else {