You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Andrew Sykes <an...@sykesdevelopment.com> on 2006/01/23 14:47:46 UTC

JAMES-437

Stefano,

Were you looking for something like this?

I've added this to JIRA (JAMES-437) too.

Index: src/java/org/apache/james/smtpserver/RcptCmdHandler.java
===================================================================
--- src/java/org/apache/james/smtpserver/RcptCmdHandler.java
(revision 370873)
+++ src/java/org/apache/james/smtpserver/RcptCmdHandler.java    (working
copy)
@@ -149,7 +149,7 @@
                     if (!session.getConfigurationData().getMailServer
().isLocalServer(toDomain)) {
                         responseString = "530 "+DSNStatus.getStatus
(DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Authentication
Required";
                         session.writeResponse(responseString);
-                        getLogger().error("Rejected message -
authentication is required for mail request");
+                        getLogger().error("Rejected message to: " +
recipientAddress.toInternetAddress().getAddress() + " - authentication
is required for mail request");
                         return;
                     }
                 } else {



-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd


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


Eclipse

Posted by Andrew Sykes <an...@sykesdevelopment.com>.
It would be good if a .classpath could be added to the repository to aid
importing into Eclipse.

-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd
http://www.sykesdevelopment.com


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


Re: Command Pattern Generalisation

Posted by Stefano Bagnara <ap...@bago.org>.
Andrew Sykes wrote:
> Stefano,
> 
>> A more advanced task could be to generalize the Command Pattern used by 
>> the SMTPHandle so that we can use it for all ours telnet/command based 
>> protocols like POP3 and possibly as a base for IMAP too.
>> The command patter is easy to adopt and it allow for more flexibility 
>> extensibility and a cleaner approach to the service creation/deploy.
> 
> Can you give an example of the type of generalisation you had in mind?

STMPHandler could be refactored to be protocol indipendend by moving the 
"mode" to the SMTPSession (or its SMTPSessions.State HashMap) and 
refactoring the loop inside the handleConnection.

POP3Handler could be refactored to use the same code of the SMTPHandler 
but using a different session/state/cmdhandlers.

Stefano

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


Command Pattern Generalisation

Posted by Andrew Sykes <an...@sykesdevelopment.com>.
Stefano,

> A more advanced task could be to generalize the Command Pattern used by 
> the SMTPHandle so that we can use it for all ours telnet/command based 
> protocols like POP3 and possibly as a base for IMAP too.
> The command patter is easy to adopt and it allow for more flexibility 
> extensibility and a cleaner approach to the service creation/deploy.

Can you give an example of the type of generalisation you had in mind?

-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd
http://www.sykesdevelopment.com


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


Re: JAMES-437

Posted by Stefano Bagnara <ap...@bago.org>.
Andrew Sykes wrote:
> Stefano,
> 
> Thanks for that.

A more advanced task could be to generalize the Command Pattern used by 
the SMTPHandle so that we can use it for all ours telnet/command based 
protocols like POP3 and possibly as a base for IMAP too.
The command patter is easy to adopt and it allow for more flexibility 
extensibility and a cleaner approach to the service creation/deploy.

Stefano

> On Mon, 2006-01-23 at 16:50 +0100, Stefano Bagnara wrote:
>> Andrew Sykes wrote:
>>> Stefano,
>>>
>>> This may seem like a silly question, but what is the "state map"? Can
>>> you elaborate a bit please?
>>
>> With the new CmdHandler architecture introduced in James 2.3.0 the state 
>> of the session is stored in the SMTPSession object. The single commands 
>> behaviour depends on the current session state and they alter the 
>> session state. For flexibility the SMTPSession contains a state HashMap 
>> that can be used by commands to store arbitrary key-values pair.
>> [...]


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


Re: JAMES-437

Posted by Andrew Sykes <an...@sykesdevelopment.com>.
Stefano,

Thanks for that.

On Mon, 2006-01-23 at 16:50 +0100, Stefano Bagnara wrote:
> Andrew Sykes wrote:
> > Stefano,
> > 
> > This may seem like a silly question, but what is the "state map"? Can
> > you elaborate a bit please?
> 
> 
> With the new CmdHandler architecture introduced in James 2.3.0 the state 
> of the session is stored in the SMTPSession object. The single commands 
> behaviour depends on the current session state and they alter the 
> session state. For flexibility the SMTPSession contains a state HashMap 
> that can be used by commands to store arbitrary key-values pair.
> 
> E.g:
> the current sender is stored in the map with the key "SENDER_ADDRESS" by 
> the MailCmdHandler and used by the following commands.
> 
> 
> Stefano
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 
-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd
http://www.sykesdevelopment.com


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


Re: JAMES-437

Posted by Stefano Bagnara <ap...@bago.org>.
Andrew Sykes wrote:
> Stefano,
> 
> This may seem like a silly question, but what is the "state map"? Can
> you elaborate a bit please?


With the new CmdHandler architecture introduced in James 2.3.0 the state 
of the session is stored in the SMTPSession object. The single commands 
behaviour depends on the current session state and they alter the 
session state. For flexibility the SMTPSession contains a state HashMap 
that can be used by commands to store arbitrary key-values pair.

E.g:
the current sender is stored in the map with the key "SENDER_ADDRESS" by 
the MailCmdHandler and used by the following commands.


Stefano

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


Re: JAMES-437

Posted by Andrew Sykes <an...@sykesdevelopment.com>.
Stefano,

This may seem like a silly question, but what is the "state map"? Can
you elaborate a bit please?

On Mon, 2006-01-23 at 16:19 +0100, Stefano Bagnara wrote:
> Andrew Sykes wrote:
> > Stefano,
> > 
> > Were you looking for something like this?
> 
> Yes, but extended to all the messages (ideally).
> 
> Probably more error logs contains uncomplete messages and could be 
> enhanced like this.
> 
> The bug report point to that specific log as an example but also refer 
> to a general approach to the logging.
> 
> In that specific log you could add the log of sender and recipient, in 
> many other calls to the logger we could add more contextual informations.
> 
> Please keep in mind that the CmdHandlers are now modular so when you get 
> a value from the state map you always have to check for null.
> 
> Stefano
> 
> 
> > I've added this to JIRA (JAMES-437) too.
> > 
> > Index: src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> > ===================================================================
> > --- src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> > (revision 370873)
> > +++ src/java/org/apache/james/smtpserver/RcptCmdHandler.java    (working
> > copy)
> > @@ -149,7 +149,7 @@
> >                      if (!session.getConfigurationData().getMailServer
> > ().isLocalServer(toDomain)) {
> >                          responseString = "530 "+DSNStatus.getStatus
> > (DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Authentication
> > Required";
> >                          session.writeResponse(responseString);
> > -                        getLogger().error("Rejected message -
> > authentication is required for mail request");
> > +                        getLogger().error("Rejected message to: " +
> > recipientAddress.toInternetAddress().getAddress() + " - authentication
> > is required for mail request");
> >                          return;
> >                      }
> >                  } else {
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
> 
-- 
Kind Regards
Andrew Sykes <an...@sykesdevelopment.com>
Sykes Development Ltd


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


Re: JAMES-437

Posted by Stefano Bagnara <ap...@bago.org>.
Andrew Sykes wrote:
> Stefano,
> 
> Were you looking for something like this?

Yes, but extended to all the messages (ideally).

Probably more error logs contains uncomplete messages and could be 
enhanced like this.

The bug report point to that specific log as an example but also refer 
to a general approach to the logging.

In that specific log you could add the log of sender and recipient, in 
many other calls to the logger we could add more contextual informations.

Please keep in mind that the CmdHandlers are now modular so when you get 
a value from the state map you always have to check for null.

Stefano


> I've added this to JIRA (JAMES-437) too.
> 
> Index: src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> ===================================================================
> --- src/java/org/apache/james/smtpserver/RcptCmdHandler.java
> (revision 370873)
> +++ src/java/org/apache/james/smtpserver/RcptCmdHandler.java    (working
> copy)
> @@ -149,7 +149,7 @@
>                      if (!session.getConfigurationData().getMailServer
> ().isLocalServer(toDomain)) {
>                          responseString = "530 "+DSNStatus.getStatus
> (DSNStatus.PERMANENT,DSNStatus.SECURITY_AUTH)+" Authentication
> Required";
>                          session.writeResponse(responseString);
> -                        getLogger().error("Rejected message -
> authentication is required for mail request");
> +                        getLogger().error("Rejected message to: " +
> recipientAddress.toInternetAddress().getAddress() + " - authentication
> is required for mail request");
>                          return;
>                      }
>                  } else {
> 
> 
> 


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