You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2011/05/03 15:12:50 UTC
svn commit: r1099042 - in /james/imap/trunk: ./
api/src/main/java/org/apache/james/imap/api/display/
message/src/main/java/org/apache/james/imap/encode/
message/src/main/java/org/apache/james/imap/encode/main/
message/src/main/java/org/apache/james/ima...
Author: norman
Date: Tue May 3 13:12:50 2011
New Revision: 1099042
URL: http://svn.apache.org/viewvc?rev=1099042&view=rev
Log:
Add support for AUTH=PLAIN. Part of IMAP-304
Added:
james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/AuthenticateResponseEncoder.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AuthenticateResponse.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
Modified:
james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java
james/imap/trunk/pom.xml
james/imap/trunk/processor/pom.xml
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java Tue May 3 13:12:50 2011
@@ -118,6 +118,7 @@ public class HumanReadableText {
public static final HumanReadableText UNSUPPORTED_SEARCH_CRITERIA = new HumanReadableText("org.apache.james.imap.UNSUPPORTED_CRITERIA", "failed. One or more search criteria is unsupported.");
public static final HumanReadableText UNSUPPORTED_AUTHENTICATION_MECHANISM = new HumanReadableText("org.apache.james.imap.UNSUPPORTED_AUTHENTICATION_MECHANISM", "failed. Authentication mechanism is unsupported.");
+ public static final HumanReadableText AUTHENTICATION_FAILED = new HumanReadableText("org.apache.james.imap.AUTHENTICATION_FAILED", "failed. Authentication failed.");
public static final HumanReadableText UNKNOWN_COMMAND = new HumanReadableText("org.apache.james.imap.UNKNOWN_COMMAND", "failed. Unknown command.");
Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/AuthenticateResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/AuthenticateResponseEncoder.java?rev=1099042&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/AuthenticateResponseEncoder.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/AuthenticateResponseEncoder.java Tue May 3 13:12:50 2011
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.imap.encode;
+
+import java.io.IOException;
+
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
+import org.apache.james.imap.message.response.AuthenticateResponse;
+
+public class AuthenticateResponseEncoder extends AbstractChainedImapEncoder {
+
+ public AuthenticateResponseEncoder(ImapEncoder next) {
+ super(next);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.encode.base.AbstractChainedImapEncoder#isAcceptable(org.apache.james.imap.api.ImapMessage)
+ */
+ protected boolean isAcceptable(ImapMessage message) {
+ return message instanceof AuthenticateResponse;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.encode.base.AbstractChainedImapEncoder#doEncode(org.apache.james.imap.api.ImapMessage, org.apache.james.imap.encode.ImapResponseComposer, org.apache.james.imap.api.process.ImapSession)
+ */
+ protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
+ composer.continuationResponse("");
+ }
+
+}
Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java Tue May 3 13:12:50 2011
@@ -20,6 +20,7 @@
package org.apache.james.imap.encode.main;
import org.apache.james.imap.api.display.Localizer;
+import org.apache.james.imap.encode.AuthenticateResponseEncoder;
import org.apache.james.imap.encode.CapabilityResponseEncoder;
import org.apache.james.imap.encode.ContinuationResponseEncoder;
import org.apache.james.imap.encode.ExistsResponseEncoder;
@@ -69,7 +70,9 @@ public class DefaultImapEncoderFactory i
final FlagsResponseEncoder flagsResponseEncoder = new FlagsResponseEncoder(xListResponseEncoder);
final CapabilityResponseEncoder capabilityResponseEncoder = new CapabilityResponseEncoder(flagsResponseEncoder);
final ContinuationResponseEncoder continuationResponseEncoder = new ContinuationResponseEncoder(capabilityResponseEncoder, localizer);
- return continuationResponseEncoder;
+ final AuthenticateResponseEncoder authResponseEncoder = new AuthenticateResponseEncoder(continuationResponseEncoder);
+
+ return authResponseEncoder;
}
private final Localizer localizer;
Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AuthenticateResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AuthenticateResponse.java?rev=1099042&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AuthenticateResponse.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/AuthenticateResponse.java Tue May 3 13:12:50 2011
@@ -0,0 +1,7 @@
+package org.apache.james.imap.message.response;
+
+import org.apache.james.imap.api.message.response.ImapResponseMessage;
+
+public class AuthenticateResponse implements ImapResponseMessage{
+
+}
Modified: james/imap/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/imap/trunk/pom.xml?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/pom.xml (original)
+++ james/imap/trunk/pom.xml Tue May 3 13:12:50 2011
@@ -501,8 +501,11 @@
<artifactId>commons-lang</artifactId>
<version>${version.commons-lang}</version>
</dependency>
-
-
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.5</version>
+ </dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
Modified: james/imap/trunk/processor/pom.xml
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/pom.xml?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/processor/pom.xml (original)
+++ james/imap/trunk/processor/pom.xml Tue May 3 13:12:50 2011
@@ -32,6 +32,10 @@
<groupId>org.apache.james</groupId>
<artifactId>apache-james-imap-message</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-mime4j</artifactId>
Added: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java?rev=1099042&view=auto
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java (added)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractAuthProcessor.java Tue May 3 13:12:50 2011
@@ -0,0 +1,97 @@
+/****************************************************************
+ * 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.imap.processor;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.request.ImapRequest;
+import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.mailbox.BadCredentialsException;
+import org.apache.james.mailbox.MailboxConstants;
+import org.apache.james.mailbox.MailboxException;
+import org.apache.james.mailbox.MailboxExistsException;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxPath;
+import org.apache.james.mailbox.MailboxSession;
+
+public abstract class AbstractAuthProcessor<M extends ImapRequest> extends AbstractMailboxProcessor<M>{
+
+ private static final String ATTRIBUTE_NUMBER_OF_FAILURES = "org.apache.james.imap.processor.imap4rev1.NUMBER_OF_FAILURES";
+
+ // TODO: this should be configurable
+ private static final int MAX_FAILURES = 3;
+
+ public AbstractAuthProcessor(Class<M> acceptableClass, ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+ super(acceptableClass, next, mailboxManager, factory);
+ }
+
+ protected void doAuth(String userid, String passwd, ImapSession session, String tag, ImapCommand command, Responder responder, HumanReadableText failed) {
+ try {
+ boolean authFailure = false;
+ if (userid == null) {
+ authFailure = true;
+ }
+ if (authFailure == false) {
+ final MailboxManager mailboxManager = getMailboxManager();
+ try {
+ final MailboxSession mailboxSession = mailboxManager.login(userid, passwd, session.getLog());
+ session.authenticated();
+ session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, mailboxSession);
+ final MailboxPath inboxPath = buildFullPath(session, MailboxConstants.INBOX);
+ if (mailboxManager.mailboxExists(inboxPath, mailboxSession)) {
+ session.getLog().debug("INBOX exists. No need to create it.");
+ } else {
+ try {
+ session.getLog().debug("INBOX does not exist. Creating it.");
+ mailboxManager.createMailbox(inboxPath, mailboxSession);
+ } catch (MailboxExistsException e) {
+ session.getLog().debug("Mailbox created by concurrent call. Safe to ignore this exception.");
+ }
+ }
+ okComplete(command, tag, responder);
+ } catch (BadCredentialsException e) {
+ authFailure = true;
+ }
+ }
+ if (authFailure) {
+ final Integer currentNumberOfFailures = (Integer) session.getAttribute(ATTRIBUTE_NUMBER_OF_FAILURES);
+ final int failures;
+ if (currentNumberOfFailures == null) {
+ failures = 1;
+ } else {
+ failures = currentNumberOfFailures.intValue() + 1;
+ }
+ if (failures < MAX_FAILURES) {
+ session.setAttribute(ATTRIBUTE_NUMBER_OF_FAILURES, failures);
+ no(command, tag, responder, failed);
+ } else {
+ session.getLog().info("Too many authentication failures. Closing connection.");
+ bye(responder, HumanReadableText.TOO_MANY_FAILURES);
+ session.logout();
+ }
+ }
+ } catch (MailboxException e) {
+ session.getLog().debug("Login failed", e);
+ no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+ }
+ }
+}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AuthenticateProcessor.java Tue May 3 13:12:50 2011
@@ -19,16 +19,25 @@
package org.apache.james.imap.processor;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.commons.codec.binary.Base64;
import org.apache.james.imap.api.ImapCommand;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapLineHandler;
import org.apache.james.imap.api.process.ImapProcessor;
import org.apache.james.imap.api.process.ImapSession;
import org.apache.james.imap.message.request.AuthenticateRequest;
+import org.apache.james.imap.message.response.AuthenticateResponse;
import org.apache.james.mailbox.MailboxManager;
-public class AuthenticateProcessor extends AbstractMailboxProcessor<AuthenticateRequest> {
-
+public class AuthenticateProcessor extends AbstractAuthProcessor<AuthenticateRequest> implements CapabilityImplementingProcessor{
+ private final static String PLAIN = "PLAIN";
+
public AuthenticateProcessor(final ImapProcessor next, final MailboxManager mailboxManager, final StatusResponseFactory factory) {
super(AuthenticateRequest.class, next, mailboxManager, factory);
}
@@ -43,10 +52,69 @@ public class AuthenticateProcessor exten
* org.apache.james.imap.api.ImapCommand,
* org.apache.james.imap.api.process.ImapProcessor.Responder)
*/
- protected void doProcess(AuthenticateRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
+ protected void doProcess(AuthenticateRequest request, ImapSession session, final String tag, final ImapCommand command, final Responder responder) {
final String authType = request.getAuthType();
- session.getLog().info("Unsupported authentication mechanism '" + authType + "'");
- no(command, tag, responder, HumanReadableText.UNSUPPORTED_AUTHENTICATION_MECHANISM);
+ if (authType.equalsIgnoreCase(PLAIN)) {
+ responder.respond(new AuthenticateResponse());
+ session.pushLineHandler(new ImapLineHandler() {
+
+ public void onLine(ImapSession session, byte[] data) {
+ String user = null, pass = null;
+ try {
+ // strip of the newline
+ String userpass = new String(data, 0, data.length - 2, Charset.forName("US-ASCII"));
+
+ userpass = new String(Base64.decodeBase64(userpass));
+ StringTokenizer authTokenizer = new StringTokenizer(userpass, "\0");
+ String authorize_id = authTokenizer.nextToken(); // Authorization Identity
+ user = authTokenizer.nextToken(); // Authentication Identity
+ try {
+ pass = authTokenizer.nextToken(); // Password
+ } catch (java.util.NoSuchElementException _) {
+ // If we got here, this is what happened. RFC 2595
+ // says that "the client may leave the authorization
+ // identity empty to indicate that it is the same as
+ // the authentication identity." As noted above,
+ // that would be represented as a decoded string of
+ // the form: "\0authenticate-id\0password". The
+ // first call to nextToken will skip the empty
+ // authorize-id, and give us the authenticate-id,
+ // which we would store as the authorize-id. The
+ // second call will give us the password, which we
+ // think is the authenticate-id (user). Then when
+ // we ask for the password, there are no more
+ // elements, leading to the exception we just
+ // caught. So we need to move the user to the
+ // password, and the authorize_id to the user.
+ pass = user;
+ user = authorize_id;
+ }
+
+ authTokenizer = null;
+ } catch (Exception e) {
+ // Ignored - this exception in parsing will be dealt
+ // with in the if clause below
+ }
+ // Authenticate user
+ doAuth(user, pass, session, tag, command, responder, HumanReadableText.AUTHENTICATION_FAILED);
+
+ // remove the handler now
+ session.popLineHandler();
+
+ }
+ });
+ } else {
+ session.getLog().info("Unsupported authentication mechanism '" + authType + "'");
+ no(command, tag, responder, HumanReadableText.UNSUPPORTED_AUTHENTICATION_MECHANISM);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.processor.CapabilityImplementingProcessor#getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
+ */
+ public List<String> getImplementedCapabilities(ImapSession session) {
+ return Arrays.asList("AUTH=PLAIN");
}
}
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java Tue May 3 13:12:50 2011
@@ -79,6 +79,9 @@ public class DefaultProcessorChain {
// announce the COMPRESS extension. Sew RFC4978
capabilityProcessor.addProcessor(compressProcessor);
+
+ // add to announnce AUTH=PLAIN
+ capabilityProcessor.addProcessor(authenticateProcessor);
return compressProcessor;
Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java?rev=1099042&r1=1099041&r2=1099042&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/LoginProcessor.java Tue May 3 13:12:50 2011
@@ -20,30 +20,17 @@
package org.apache.james.imap.processor;
import org.apache.james.imap.api.ImapCommand;
-import org.apache.james.imap.api.ImapSessionUtils;
import org.apache.james.imap.api.display.HumanReadableText;
import org.apache.james.imap.api.message.response.StatusResponseFactory;
import org.apache.james.imap.api.process.ImapProcessor;
import org.apache.james.imap.api.process.ImapSession;
import org.apache.james.imap.message.request.LoginRequest;
-import org.apache.james.mailbox.BadCredentialsException;
-import org.apache.james.mailbox.MailboxException;
-import org.apache.james.mailbox.MailboxExistsException;
import org.apache.james.mailbox.MailboxManager;
-import org.apache.james.mailbox.MailboxPath;
-import org.apache.james.mailbox.MailboxSession;
/**
* Processes a <code>LOGIN</code> command.
*/
-public class LoginProcessor extends AbstractMailboxProcessor<LoginRequest> {
-
- public static final String INBOX = "INBOX";
-
- private static final String ATTRIBUTE_NUMBER_OF_FAILURES = "org.apache.james.imap.processor.imap4rev1.LoginProcessor.NUMBER_OF_FAILURES";
-
- // TODO: this should be configurable
- private static final int MAX_FAILURES = 3;
+public class LoginProcessor extends AbstractAuthProcessor<LoginRequest> {
public LoginProcessor(final ImapProcessor next, final MailboxManager mailboxManager, final StatusResponseFactory factory) {
super(LoginRequest.class, next, mailboxManager, factory);
@@ -51,55 +38,12 @@ public class LoginProcessor extends Abst
/*
* (non-Javadoc)
- *
- * @see
- * org.apache.james.imap.processor.AbstractMailboxProcessor#doProcess(org
- * .apache.james.imap.api.message.request.ImapRequest,
- * org.apache.james.imap.api.process.ImapSession, java.lang.String,
- * org.apache.james.imap.api.ImapCommand,
- * org.apache.james.imap.api.process.ImapProcessor.Responder)
+ * @see org.apache.james.imap.processor.AbstractMailboxProcessor#doProcess(org.apache.james.imap.api.message.request.ImapRequest, org.apache.james.imap.api.process.ImapSession, java.lang.String, org.apache.james.imap.api.ImapCommand, org.apache.james.imap.api.process.ImapProcessor.Responder)
*/
protected void doProcess(LoginRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) {
- try {
final String userid = request.getUserid();
final String passwd = request.getPassword();
- final MailboxManager mailboxManager = getMailboxManager();
- try {
- final MailboxSession mailboxSession = mailboxManager.login(userid, passwd, session.getLog());
- session.authenticated();
- session.setAttribute(ImapSessionUtils.MAILBOX_SESSION_ATTRIBUTE_SESSION_KEY, mailboxSession);
- final MailboxPath inboxPath = buildFullPath(session, INBOX);
- if (mailboxManager.mailboxExists(inboxPath, mailboxSession)) {
- session.getLog().debug("INBOX exists. No need to create it.");
- } else {
- try {
- session.getLog().debug("INBOX does not exist. Creating it.");
- mailboxManager.createMailbox(inboxPath, mailboxSession);
- } catch (MailboxExistsException e) {
- session.getLog().debug("Mailbox created by concurrent call. Safe to ignore this exception.");
- }
- }
- okComplete(command, tag, responder);
- } catch (BadCredentialsException e) {
- final Integer currentNumberOfFailures = (Integer) session.getAttribute(ATTRIBUTE_NUMBER_OF_FAILURES);
- final int failures;
- if (currentNumberOfFailures == null) {
- failures = 1;
- } else {
- failures = currentNumberOfFailures.intValue() + 1;
- }
- if (failures < MAX_FAILURES) {
- session.setAttribute(ATTRIBUTE_NUMBER_OF_FAILURES, failures);
- no(command, tag, responder, HumanReadableText.INVALID_LOGIN);
- } else {
- session.getLog().info("Too many authentication failures. Closing connection.");
- bye(responder, HumanReadableText.TOO_MANY_FAILURES);
- session.logout();
- }
- }
- } catch (MailboxException e) {
- session.getLog().debug("Login failed", e);
- no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
- }
+
+ doAuth(userid, passwd, session, tag, command, responder, HumanReadableText.INVALID_LOGIN);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org