Repository: james-project Updated Branches: refs/heads/master 1bc25f065 -> ff3698dbc
JAMES-2548 AUTH PLAIN should strip CRLF and end of line Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ff3698db Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ff3698db Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ff3698db Branch: refs/heads/master Commit: ff3698dbc5beba67b9499169617bc2423438e743 Parents: 1bc25f0 Author: Matthieu Baechler <[email protected]> Authored: Thu Sep 13 16:55:09 2018 +0200 Committer: Matthieu Baechler <[email protected]> Committed: Thu Sep 13 16:55:48 2018 +0200 ---------------------------------------------------------------------- .../james/mpt/smtp/SmtpAuthCommandTest.java | 57 ++++++++++++++++++++ .../apache/james/smtp/scripts/authplain.test | 7 +++ .../smtp/core/esmtp/AuthCmdHandler.java | 4 +- 3 files changed, 66 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/ff3698db/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java ---------------------------------------------------------------------- diff --git a/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java new file mode 100644 index 0000000..4071696 --- /dev/null +++ b/mpt/impl/smtp/core/src/main/java/org/apache/james/mpt/smtp/SmtpAuthCommandTest.java @@ -0,0 +1,57 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ +package org.apache.james.mpt.smtp; + +import java.util.Locale; + +import org.apache.james.mpt.script.SimpleScriptedTestProtocol; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +public abstract class SmtpAuthCommandTest { + + public static final String USER = "bob"; + public static final String DOMAIN = "mydomain.tld"; + public static final String USER_AT_DOMAIN = USER + "@" + DOMAIN; + public static final String PASSWORD = "secret"; + + @Rule + public final TemporaryFolder folder = new TemporaryFolder(); + + protected abstract SmtpHostSystem createSmtpHostSystem(); + + private SmtpHostSystem hostSystem; + private SimpleScriptedTestProtocol scriptedTest; + + @Before + public void setUp() throws Exception { + hostSystem = createSmtpHostSystem(); + String scriptDir = "/org/apache/james/smtp/scripts/"; + scriptedTest = new SimpleScriptedTestProtocol(scriptDir, hostSystem) + .withLocale(Locale.US) + .withUser(USER_AT_DOMAIN, PASSWORD); + } + + @Test + public void bobShouldBeAbleToAuthPlain() throws Exception { + scriptedTest.run("authplain"); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/ff3698db/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/authplain.test ---------------------------------------------------------------------- diff --git a/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/authplain.test b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/authplain.test new file mode 100644 index 0000000..a5928c9 --- /dev/null +++ b/mpt/impl/smtp/core/src/main/resources/org/apache/james/smtp/scripts/authplain.test @@ -0,0 +1,7 @@ +S: 220 mydomain.tld smtp +C: AUTH LOGIN +S: 334 VXNlcm5hbWU6 +C: Ym9iQG15ZG9tYWluLnRsZA== +S: 334 UGFzc3dvcmQ6 +C: c2VjcmV0 +S: 235 Authentication Successful http://git-wip-us.apache.org/repos/asf/james-project/blob/ff3698db/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java ---------------------------------------------------------------------- diff --git a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java index 97f8ced..4e296d0 100644 --- a/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java +++ b/protocols/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/AuthCmdHandler.java @@ -323,7 +323,7 @@ public class AuthCmdHandler private Response doLoginAuthPass(SMTPSession session, String user) { if (user != null) { try { - user = new String(Base64.getDecoder().decode(user), StandardCharsets.UTF_8); + user = decodeBase64(user); } catch (Exception e) { // Ignored - this parse error will be // addressed in the if clause below @@ -363,7 +363,7 @@ public class AuthCmdHandler private Response doLoginAuthPassCheck(SMTPSession session, String user, String pass) { if (pass != null) { try { - pass = new String(Base64.getDecoder().decode(pass), StandardCharsets.UTF_8); + pass = decodeBase64(pass); } catch (Exception e) { // Ignored - this parse error will be // addressed in the if clause below --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
