This is an automated email from the ASF dual-hosted git repository.

quantranhong1999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 690f6b6195d8f0f62f2519b89d240ddf12af89e8
Author: Felix Auringer <[email protected]>
AuthorDate: Wed May 20 09:57:10 2026 +0200

    fix(imap): use consistens error message in code and test for bad credentials
---
 examples/custom-imap/README.md                                    | 2 +-
 .../org/apache/james/imap/scripts/AuthenticatePlain.test          | 4 ++--
 .../src/main/resources/org/apache/james/imap/scripts/Login.test   | 4 ++--
 .../org/apache/james/imap/scripts/LoginThreeStrikes.test          | 4 ++--
 .../java/org/apache/james/imap/api/display/HumanReadableText.java | 2 +-
 .../org/apache/james/imap/processor/AbstractAuthProcessor.java    | 4 ++--
 third-party/crowdsec/sample-configuration/parsers/james-auth.yaml | 8 ++++----
 .../crowdsec/src/test/resources/crowdsec/parsers/james-auth.yaml  | 8 ++++----
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/examples/custom-imap/README.md b/examples/custom-imap/README.md
index 1ca468c25c..7d0eee0325 100644
--- a/examples/custom-imap/README.md
+++ b/examples/custom-imap/README.md
@@ -50,7 +50,7 @@ Connected to localhost.
 Escape character is '^]'.
 * OK JAMES IMAP4rev1 Server james.local is ready.
 a01 LOGIN bob secret
-a01 NO LOGIN failed. Invalid login/password.
+a01 NO LOGIN failed. Invalid credentials.
 a02 LOGIN bob@localhost secret
 a02 OK LOGIN completed.
 A03 PING
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/AuthenticatePlain.test
 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/AuthenticatePlain.test
index b5ca18a5c6..ffe42f2f18 100644
--- 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/AuthenticatePlain.test
+++ 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/AuthenticatePlain.test
@@ -85,7 +85,7 @@ REINIT
 C: 0005 AUTHENTICATE "PLAIN" {28+}
 # \0imapuser\0badpassword
 C: AGltYXB1c2VyAGJhZHBhc3N3b3Jk
-S: 0005 NO AUTHENTICATE failed. Authentication failed.
+S: 0005 NO AUTHENTICATE failed. Invalid credentials.
 
 REINIT
 
@@ -93,7 +93,7 @@ REINIT
 C: 0006 AUTHENTICATE "PLAIN" {24+}
 # \0baduser\0password
 C: AGJhZHVzZXIAcGFzc3dvcmQ=
-S: 0006 NO AUTHENTICATE failed. Authentication failed.
+S: 0006 NO AUTHENTICATE failed. Invalid credentials.
 
 REINIT
 
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Login.test
 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Login.test
index 84c8d7b740..500d2a310e 100644
--- 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Login.test
+++ 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Login.test
@@ -27,10 +27,10 @@ C: a002a LOGIN imapuser password extra
 S: a002a BAD LOGIN failed. Illegal arguments.
 
 C: a003 LOGIN invaliduser password
-S: a003 NO LOGIN failed. Invalid login/password.
+S: a003 NO LOGIN failed. Invalid credentials.
 
 C: a004 LOGIN imapuser invalid
-S: a004 NO LOGIN failed. Invalid login/password.
+S: a004 NO LOGIN failed. Invalid credentials.
 
 C: a005 LOGIN imapuser password
 S: a005 OK LOGIN completed.
\ No newline at end of file
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/LoginThreeStrikes.test
 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/LoginThreeStrikes.test
index 231f4a2079..c73fb9321c 100644
--- 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/LoginThreeStrikes.test
+++ 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/LoginThreeStrikes.test
@@ -21,10 +21,10 @@
 #
 S: \* OK IMAP4rev1 Server ready
 C: a003 LOGIN invaliduser password
-S: a003 NO LOGIN failed. Invalid login/password.
+S: a003 NO LOGIN failed. Invalid credentials.
 
 C: a004 LOGIN imapuser invalid
-S: a004 NO LOGIN failed. Invalid login/password.
+S: a004 NO LOGIN failed. Invalid credentials.
 
 C: a005 LOGIN imapuser bogus
 S: \* BYE Login failed too many times.
\ No newline at end of file
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
index 9746c5ca85..7b170d0526 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
@@ -141,7 +141,7 @@ public class HumanReadableText {
     public static final HumanReadableText COMPLETED = new 
HumanReadableText("org.apache.james.imap.COMPLETED", "completed.");
     public static final HumanReadableText REPLACE_READY = new 
HumanReadableText("org.apache.james.imap.REPLACE", "Replacement Message ready");
 
-    public static final HumanReadableText INVALID_LOGIN = new 
HumanReadableText("org.apache.james.imap.INVALID_LOGIN", "failed. Invalid 
login/password.");
+    public static final HumanReadableText INVALID_CREDENTIALS = new 
HumanReadableText("org.apache.james.imap.INVALID_CREDENTIALS", "failed. Invalid 
credentials.");
 
     public static final HumanReadableText DISABLED_LOGIN = new 
HumanReadableText("org.apache.james.imap.DISABLED_LOGIN", "failed. Plain login 
/ authentication are disabled.");
 
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
index f6a97dfb6b..8786a6ec94 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
@@ -95,7 +95,7 @@ public abstract class AbstractAuthProcessor<R extends 
ImapRequest> extends Abstr
                 ).withoutDelegation();
                 authSuccess(session, mailboxSession, request, responder, 
"Password authentication succeeded.");
             } catch (BadCredentialsException e) {
-                authFailure(session, request, responder, 
HumanReadableText.INVALID_LOGIN,
+                authFailure(session, request, responder, 
HumanReadableText.INVALID_CREDENTIALS,
                     Optional.of(authenticationAttempt.getAuthenticationId()),
                     Optional.empty(),
                     "Password authentication failed because of bad 
credentials."
@@ -143,7 +143,7 @@ public abstract class AbstractAuthProcessor<R extends 
ImapRequest> extends Abstr
         try {
             authSuccess(session, mailboxSessionSupplier.get(), request, 
responder, "Authentication with delegation succeeded.");
         } catch (BadCredentialsException e) {
-            authFailure(session, request, responder, 
HumanReadableText.INVALID_LOGIN, Optional.of(authenticateUser),
+            authFailure(session, request, responder, 
HumanReadableText.INVALID_CREDENTIALS, Optional.of(authenticateUser),
                 Optional.of(delegatorUser), "Password authentication with 
delegation failed because of bad credentials.");
         } catch (UserDoesNotExistException e) {
             authFailure(session, request, responder, 
HumanReadableText.USER_DOES_NOT_EXIST, Optional.of(authenticateUser),
diff --git a/third-party/crowdsec/sample-configuration/parsers/james-auth.yaml 
b/third-party/crowdsec/sample-configuration/parsers/james-auth.yaml
index 20254c21d2..5196d92f39 100644
--- a/third-party/crowdsec/sample-configuration/parsers/james-auth.yaml
+++ b/third-party/crowdsec/sample-configuration/parsers/james-auth.yaml
@@ -5,10 +5,10 @@ name: linagora/james-auth
 description: "Parser for James IMAP and SMTP authentication "
 
 pattern_syntax:
-  IMAP_AUTH_FAIL_BAD_CREDENTIALS: 'IMAP Authentication 
failed%{DATA:data}because of bad credentials.'
-  IMAP_AUTH_FAIL_DELEGATION_BAD_CREDENTIALS: 'IMAP Authentication with 
delegation failed%{DATA:data}because of bad credentials.'
-  IMAP_AUTH_FAIL_NO_EXISTING_DELEGATION: 'IMAP Authentication with delegation 
failed%{DATA:data}because of non existing delegation.'
-  SMTP_AUTH_FAIL: 'SMTP Authentication%{DATA:data}failed.'
+  IMAP_AUTH_FAIL_BAD_CREDENTIALS: 'Password authentication failed because of 
bad credentials%{DATA:data}'
+  IMAP_AUTH_FAIL_DELEGATION_BAD_CREDENTIALS: 'Password authentication with 
delegation failed because of bad credentials%{DATA:data}'
+  IMAP_AUTH_FAIL_NO_EXISTING_DELEGATION: 'Delegation target user does not 
exist%{DATA:data}'
+  SMTP_AUTH_FAIL: 'SMTP Authentication failed%{DATA:data}'
   POP3_AUTH_FAIL: 'Bad credential supplied for %{DATA:user} with remote 
address %{IP:source_ip}'
 nodes:
   - grok:
diff --git 
a/third-party/crowdsec/src/test/resources/crowdsec/parsers/james-auth.yaml 
b/third-party/crowdsec/src/test/resources/crowdsec/parsers/james-auth.yaml
index 20254c21d2..5196d92f39 100644
--- a/third-party/crowdsec/src/test/resources/crowdsec/parsers/james-auth.yaml
+++ b/third-party/crowdsec/src/test/resources/crowdsec/parsers/james-auth.yaml
@@ -5,10 +5,10 @@ name: linagora/james-auth
 description: "Parser for James IMAP and SMTP authentication "
 
 pattern_syntax:
-  IMAP_AUTH_FAIL_BAD_CREDENTIALS: 'IMAP Authentication 
failed%{DATA:data}because of bad credentials.'
-  IMAP_AUTH_FAIL_DELEGATION_BAD_CREDENTIALS: 'IMAP Authentication with 
delegation failed%{DATA:data}because of bad credentials.'
-  IMAP_AUTH_FAIL_NO_EXISTING_DELEGATION: 'IMAP Authentication with delegation 
failed%{DATA:data}because of non existing delegation.'
-  SMTP_AUTH_FAIL: 'SMTP Authentication%{DATA:data}failed.'
+  IMAP_AUTH_FAIL_BAD_CREDENTIALS: 'Password authentication failed because of 
bad credentials%{DATA:data}'
+  IMAP_AUTH_FAIL_DELEGATION_BAD_CREDENTIALS: 'Password authentication with 
delegation failed because of bad credentials%{DATA:data}'
+  IMAP_AUTH_FAIL_NO_EXISTING_DELEGATION: 'Delegation target user does not 
exist%{DATA:data}'
+  SMTP_AUTH_FAIL: 'SMTP Authentication failed%{DATA:data}'
   POP3_AUTH_FAIL: 'Bad credential supplied for %{DATA:user} with remote 
address %{IP:source_ip}'
 nodes:
   - grok:


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to