Author: norman
Date: Tue Nov 22 09:33:25 2011
New Revision: 1204877
URL: http://svn.apache.org/viewvc?rev=1204877&view=rev
Log:
Better check if the AuthCmdHandler must be added
Modified:
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPProtocolHandlerChain.java
Modified:
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPProtocolHandlerChain.java
URL:
http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPProtocolHandlerChain.java?rev=1204877&r1=1204876&r2=1204877&view=diff
==============================================================================
---
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPProtocolHandlerChain.java
(original)
+++
james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPProtocolHandlerChain.java
Tue Nov 22 09:33:25 2011
@@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.apache.james.protocols.api.handler.ExtensibleHandler;
import org.apache.james.protocols.api.handler.ProtocolHandler;
import org.apache.james.protocols.api.handler.ProtocolHandlerChain;
import org.apache.james.protocols.api.handler.ProtocolHandlerChainImpl;
@@ -60,7 +61,6 @@ import org.apache.james.protocols.smtp.h
*
*/
public class SMTPProtocolHandlerChain extends ProtocolHandlerChainImpl {
- private volatile boolean authHandler = false;
public SMTPProtocolHandlerChain() {
this(true);
@@ -109,17 +109,22 @@ public class SMTPProtocolHandlerChain ex
defaultHandlers.add(new StartTlsCmdHandler());
return defaultHandlers;
}
-
- private boolean checkForAuth(ProtocolHandler handler) {
+ private synchronized boolean checkForAuth(ProtocolHandler handler) {
if (isReadyOnly()) {
throw new UnsupportedOperationException("Read-Only");
}
- if (handler instanceof AuthHook && !authHandler) {
+ if (handler instanceof AuthHook) {
+ // check if we need to add the AuthCmdHandler
+ List<ExtensibleHandler> handlers =
getHandlers(ExtensibleHandler.class);
+ for (ExtensibleHandler h: handlers) {
+ if (h.getMarkerInterfaces().contains(AuthHook.class)) {
+ return true;
+ }
+ }
if (!add(new AuthCmdHandler())) {
return false;
}
- authHandler = true;
}
return true;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]