From 2b19bc95daeead7127ddcc9b65260c2794d18fc6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 22 Aug 2022 09:40:10 -0700 Subject: [PATCH] GUACAMOLE-990: Use translation string for "too many failed attempts" error. --- .../guacamole/auth/ban/AuthenticationFailureTracker.java | 7 ++++--- .../src/main/resources/guac-manifest.json | 4 ++++ .../src/main/resources/translations/en.json | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 extensions/guacamole-auth-ban/src/main/resources/translations/en.json diff --git a/extensions/guacamole-auth-ban/src/main/java/org/apache/guacamole/auth/ban/AuthenticationFailureTracker.java b/extensions/guacamole-auth-ban/src/main/java/org/apache/guacamole/auth/ban/AuthenticationFailureTracker.java index 4f77875fc..d30f522bd 100644 --- a/extensions/guacamole-auth-ban/src/main/java/org/apache/guacamole/auth/ban/AuthenticationFailureTracker.java +++ b/extensions/guacamole-auth-ban/src/main/java/org/apache/guacamole/auth/ban/AuthenticationFailureTracker.java @@ -22,9 +22,9 @@ package org.apache.guacamole.auth.ban; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import javax.servlet.http.HttpServletRequest; -import org.apache.guacamole.GuacamoleClientTooManyException; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleServerException; +import org.apache.guacamole.language.TranslatableGuacamoleClientTooManyException; import org.apache.guacamole.net.auth.Credentials; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -207,8 +207,9 @@ public class AuthenticationFailureTracker { // if too many failures have occurred if (status.isBlocked()) { logger.debug("Blocking authentication attempt from address \"{}\" due to number of authentication failures.", address); - throw new GuacamoleClientTooManyException("Too many failed " - + "authentication attempts. Please try again later."); + throw new TranslatableGuacamoleClientTooManyException("Too " + + "many failed authentication attempts.", + "LOGIN.ERROR_TOO_MANY_ATTEMPTS"); } // Clean up tracking of failures if the address is no longer diff --git a/extensions/guacamole-auth-ban/src/main/resources/guac-manifest.json b/extensions/guacamole-auth-ban/src/main/resources/guac-manifest.json index 87f75ea61..1e6beac22 100644 --- a/extensions/guacamole-auth-ban/src/main/resources/guac-manifest.json +++ b/extensions/guacamole-auth-ban/src/main/resources/guac-manifest.json @@ -11,6 +11,10 @@ "listeners" : [ "org.apache.guacamole.auth.ban.BanningAuthenticationListener" + ], + + "translations" : [ + "translations/en.json" ] } diff --git a/extensions/guacamole-auth-ban/src/main/resources/translations/en.json b/extensions/guacamole-auth-ban/src/main/resources/translations/en.json new file mode 100644 index 000000000..2ef8a37d7 --- /dev/null +++ b/extensions/guacamole-auth-ban/src/main/resources/translations/en.json @@ -0,0 +1,5 @@ +{ + "LOGIN": { + "ERROR_TOO_MANY_ATTEMPTS" : "Too many failed authentication attempts. Please try again later." + } +}