james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r492460 - in /james/server/sandbox/handlerapi-experiment: ./ src/java/org/apache/james/smtpserver/core/
Date Thu, 04 Jan 2007 08:51:03 GMT
Author: norman
Date: Thu Jan  4 00:50:59 2007
New Revision: 492460

URL: http://svn.apache.org/viewvc?view=rev&rev=492460
Log:
Add HookResultHook to hook to AuthCmdHandler
Add javadocs


Modified:
    james/server/sandbox/handlerapi-experiment/TODO
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
    james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java

Modified: james/server/sandbox/handlerapi-experiment/TODO
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/TODO?view=diff&rev=492460&r1=492459&r2=492460
==============================================================================
--- james/server/sandbox/handlerapi-experiment/TODO (original)
+++ james/server/sandbox/handlerapi-experiment/TODO Thu Jan  4 00:50:59 2007
@@ -9,4 +9,3 @@
 - SenderAuthIdentifyVerificationRcptHook use session.getConfigurationData().isVerifyIdentity()
to decide wether to enable itself or not: isn't it better to add the handler to the config
and commenting/uncommenting the handler already do the trick? If so we shoudl simply remove
that configuration and remove the check in the code.
 - I would like to Merge HeloHook and EhloHook to a single hook. They are alternative and
I think there is no need for both in the high-level api. less is more ;-)
   (currently we have a single handler implementing both hook and doing the same thing for
both).
-- Let AuthCmdHandler and EhloCmdHandler handler HookResultHook too
\ No newline at end of file

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java?view=diff&rev=492460&r1=492459&r2=492460
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
(original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
Thu Jan  4 00:50:59 2007
@@ -35,7 +35,6 @@
 /**
  * Abstract class which Handle hooks.
  * 
- * TODO: Maybe we should take care of relaying etc here ?
  */
 public abstract class AbstractHookableCmdHandler extends AbstractLogEnabled
         implements CommandHandler, ExtensibleHandler {
@@ -197,7 +196,9 @@
     }
 
     /**
-     * @return
+     * Return the interface which hooks need to implement to hook in
+     * 
+     * @return interface
      */
     protected abstract Class getHookInterface();
 

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java?view=diff&rev=492460&r1=492459&r2=492460
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
(original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/AuthCmdHandler.java
Thu Jan  4 00:50:59 2007
@@ -30,6 +30,7 @@
 import org.apache.james.smtpserver.WiringException;
 import org.apache.james.smtpserver.hook.AuthHook;
 import org.apache.james.smtpserver.hook.HookResult;
+import org.apache.james.smtpserver.hook.HookResultHook;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.util.Base64;
 import org.apache.james.util.mail.SMTPRetCode;
@@ -91,6 +92,8 @@
      */
     private List hooks;
     
+    private List rHooks;
+    
     /**
      * handles AUTH command
      *
@@ -290,14 +293,25 @@
         SMTPResponse res = null;
         
         List hooks = getHooks();
-
+        
         if (hooks != null) {
-            getLogger().debug("executing  hooks");
             int count = hooks.size();
             for (int i = 0; i < count; i++) {
                 Object rawHook = hooks.get(i);
-                res = calcDefaultSMTPResponse(((AuthHook) rawHook).doAuth(session,
-                        user, pass));
+                getLogger().debug("executing  hook " + rawHook);
+                
+                HookResult hRes = ((AuthHook) rawHook).doAuth(session, user, pass);
+                
+                if (rHooks != null) {
+                    for (int i2 = 0; i2 < rHooks.size(); i2++) {
+                        Object rHook = rHooks.get(i2);
+                        getLogger().debug("executing  hook " + rHook);
+                    
+                        hRes = ((HookResultHook) rHook).onHookResult(session, hRes, rHook);
+                    }
+                }
+                
+                res = calcDefaultSMTPResponse(hRes);
                 
                 if (res != null) {
                     if (SMTPRetCode.AUTH_FAILED.equals(res.getRetCode())) {
@@ -321,7 +335,10 @@
 
 
     /**
-     * @param result
+     * Calculate the SMTPResponse for the given result
+     * 
+     * @param result the HookResult which should converted to SMTPResponse
+     * @return the calculated SMTPResponse for the given HookReslut
      */
     protected SMTPResponse calcDefaultSMTPResponse(HookResult result) {
         if (result != null) {
@@ -424,6 +441,8 @@
             if (hooks == null || hooks.size() == 0) {
                 throw new WiringException("AuthCmdHandler used without AuthHooks");
             }
+        } else if (HookResultHook.class.equals(interfaceName)) {
+            this.rHooks = extension;
         }
     }
     

Modified: james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java?view=diff&rev=492460&r1=492459&r2=492460
==============================================================================
--- james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
(original)
+++ james/server/sandbox/handlerapi-experiment/src/java/org/apache/james/smtpserver/core/EhloCmdHandler.java
Thu Jan  4 00:50:59 2007
@@ -44,6 +44,7 @@
 
     private List ehloExtensions;
 
+    
     /**
      * Handler method called upon receipt of a EHLO command. Responds with a
      * greeting and informs the client whether client authentication is
@@ -114,7 +115,10 @@
     }
 
     /**
-     * @param session
+     * Process the ehloExtensions
+     * 
+     * @param session SMTPSession 
+     * @param resp SMTPResponse
      */
     private void processExtensions(SMTPSession session, SMTPResponse resp) {
         if (ehloExtensions != null) {
@@ -166,13 +170,11 @@
     protected Class getHookInterface() {
         return EhloHook.class;
     }
-
-    /*
-     * (non-Javadoc)
+    
+    /**
      * @see org.apache.james.smtpserver.core.AbstractHookableCmdHandler#callHook(java.lang.Object,
org.apache.james.smtpserver.SMTPSession, java.lang.String)
      */
     protected HookResult callHook(Object rawHook, SMTPSession session, String parameters)
{
         return ((EhloHook) rawHook).doEhlo(session, parameters);
     }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message