Author: norman Date: Tue Dec 20 13:49:01 2011 New Revision: 1221259 URL: http://svn.apache.org/viewvc?rev=1221259&view=rev Log: Expose SMTPConfiguration via SMTPSession. see PROTOCOLS-60
Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/HeloCmdHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/QuitCmdHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/EhloCmdHandler.java james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/MailSizeEsmtpExtension.java james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java (original) +++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3Session.java Tue Dec 20 13:49:01 2011 @@ -45,9 +45,9 @@ public interface POP3Session extends Pro /** * Returns POP3Handler service wide configuration * - * @return POP3HandlerConfigurationData + * @return config */ - POP3Configuration getConfigurationData(); + POP3Configuration getConfiguration(); /** * Returns the current handler state Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java (original) +++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/POP3SessionImpl.java Tue Dec 20 13:49:01 2011 @@ -41,9 +41,9 @@ public class POP3SessionImpl extends Pro } /** - * @see org.apache.james.pop3server.POP3Session#getConfigurationData() + * @see org.apache.james.pop3server.POP3Session#getConfiguration() */ - public POP3Configuration getConfigurationData() { + public POP3Configuration getConfiguration() { return configData; } Modified: james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java (original) +++ james/protocols/trunk/pop3/src/main/java/org/apache/james/protocols/pop3/core/WelcomeMessageHandler.java Tue Dec 20 13:49:01 2011 @@ -35,7 +35,7 @@ public class WelcomeMessageHandler imple StringBuilder responseBuffer = new StringBuilder(); // Initially greet the connector // Format is: Sat, 24 Jan 1998 13:16:09 -0500 - responseBuffer.append(session.getConfigurationData().getHelloName()).append(" POP3 server (").append(getProductName()).append(") ready "); + responseBuffer.append(session.getConfiguration().getHelloName()).append(" POP3 server (").append(getProductName()).append(") ready "); POP3Response response = new POP3Response(POP3Response.OK_RESPONSE, responseBuffer.toString()); return response; } Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSession.java Tue Dec 20 13:49:01 2011 @@ -39,40 +39,12 @@ public interface SMTPSession extends Pro final static String CURRENT_HELO_NAME = "CURRENT_HELO_NAME"; /** - * Returns the service wide hello name + * Returns the service wide configuration * - * @return the hello name + * @return the configuration */ - String getHelloName(); + SMTPConfiguration getConfiguration(); - /** - * Returns whether the remote server needs to send a HELO/EHLO - * of its senders. - * - * @return whether SMTP authentication is on - */ - boolean useHeloEhloEnforcement(); - - /** - * Return the SMTPGreeting which should used. - * - * @return the SMTPGreeting - */ - String getSMTPGreeting(); - - /** - * Returns the service wide maximum message size in bytes. - * - * @return the maximum message size - */ - long getMaxMessageSize(); - - /** - * Return wheter the mailserver will accept addresses without brackets enclosed. - * - * @return true or false - */ - boolean useAddressBracketsEnforcement(); /** * Returns whether Relaying is allowed or not Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/SMTPSessionImpl.java Tue Dec 20 13:49:01 2011 @@ -32,12 +32,11 @@ import org.slf4j.Logger; * {@link SMTPSession} implementation */ public class SMTPSessionImpl extends ProtocolSessionImpl implements SMTPSession { - public final static String SMTP_SESSION = "SMTP_SESSION"; private boolean relayingAllowed; - private SMTPConfiguration theConfigData; + private final SMTPConfiguration theConfigData; public SMTPSessionImpl(SMTPConfiguration theConfigData, Logger logger, ProtocolTransport transport) { super(logger, transport); @@ -83,20 +82,6 @@ public class SMTPSessionImpl extends Pro } /** - * @see org.apache.james.protocols.smtp.SMTPSession#getHelloName() - */ - public String getHelloName() { - return theConfigData.getHelloName(); - } - - /** - * @see org.apache.james.protocols.smtp.SMTPSession#getMaxMessageSize() - */ - public long getMaxMessageSize() { - return theConfigData.getMaxMessageSize(); - } - - /** * @see org.apache.james.protocols.smtp.SMTPSession#getRcptCount() */ @SuppressWarnings("unchecked") @@ -112,13 +97,6 @@ public class SMTPSessionImpl extends Pro } /** - * @see org.apache.james.protocols.smtp.SMTPSession#getSMTPGreeting() - */ - public String getSMTPGreeting() { - return theConfigData.getSMTPGreeting(); - } - - /** * @see org.apache.james.protocols.smtp.SMTPSession#isAuthSupported() */ public boolean isAuthSupported() { @@ -133,20 +111,6 @@ public class SMTPSessionImpl extends Pro } /** - * @see org.apache.james.protocols.smtp.SMTPSession#useAddressBracketsEnforcement() - */ - public boolean useAddressBracketsEnforcement() { - return theConfigData.useAddressBracketsEnforcement(); - } - - /** - * @see org.apache.james.protocols.smtp.SMTPSession#useHeloEhloEnforcement() - */ - public boolean useHeloEhloEnforcement() { - return theConfigData.useHeloEhloEnforcement(); - } - - /** * @see * org.apache.james.protocols.smtp.SMTPSession#getPushedLineHandlerCount() */ @@ -161,4 +125,9 @@ public class SMTPSessionImpl extends Pro public Response newFatalErrorResponse() { return new SMTPResponse(SMTPRetCode.LOCAL_ERROR, "Unable to process request"); } + + @Override + public SMTPConfiguration getConfiguration() { + return theConfigData; + } } Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/HeloCmdHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/HeloCmdHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/HeloCmdHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/HeloCmdHandler.java Tue Dec 20 13:49:01 2011 @@ -58,7 +58,7 @@ public class HeloCmdHandler extends Abst session.getConnectionState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME); StringBuilder response = new StringBuilder(); - response.append(session.getHelloName()).append( + response.append(session.getConfiguration().getHelloName()).append( " Hello ").append(parameters).append(" [").append( session.getRemoteAddress().getAddress().getHostAddress()).append("])"); return new SMTPResponse(SMTPRetCode.MAIL_OK, response); Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/MailCmdHandler.java Tue Dec 20 13:49:01 2011 @@ -135,7 +135,7 @@ public class MailCmdHandler extends Abst + " Sender already specified"); } else if (!session.getConnectionState().containsKey( SMTPSession.CURRENT_HELO_MODE) - && session.useHeloEhloEnforcement()) { + && session.getConfiguration().useHeloEhloEnforcement()) { return new SMTPResponse(SMTPRetCode.BAD_SEQUENCE, DSNStatus .getStatus(DSNStatus.PERMANENT, DSNStatus.DELIVERY_OTHER) + " Need HELO or EHLO before MAIL"); @@ -195,7 +195,7 @@ public class MailCmdHandler extends Abst } } } - if (session.useAddressBracketsEnforcement() + if (session.getConfiguration().useAddressBracketsEnforcement() && (!sender.startsWith("<") || !sender.endsWith(">"))) { if (session.getLogger().isInfoEnabled()) { StringBuilder errorBuffer = new StringBuilder(128).append( @@ -210,7 +210,7 @@ public class MailCmdHandler extends Abst } MailAddress senderAddress = null; - if (session.useAddressBracketsEnforcement() + if (session.getConfiguration().useAddressBracketsEnforcement() || (sender.startsWith("<") && sender.endsWith(">"))) { // Remove < and > sender = sender.substring(1, sender.length() - 1); Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/QuitCmdHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/QuitCmdHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/QuitCmdHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/QuitCmdHandler.java Tue Dec 20 13:49:01 2011 @@ -57,7 +57,7 @@ public class QuitCmdHandler extends Abst response.append( DSNStatus.getStatus(DSNStatus.SUCCESS, DSNStatus.UNDEFINED_STATUS)).append(" ").append( - session.getHelloName()).append( + session.getConfiguration().getHelloName()).append( " Service closing transmission channel"); ret = new SMTPResponse(SMTPRetCode.SYSTEM_QUIT, response); } else { Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/RcptCmdHandler.java Tue Dec 20 13:49:01 2011 @@ -121,7 +121,7 @@ public class RcptCmdHandler extends Abst // Remove the options from the recipient recipient = recipient.substring(0, lastChar + 1); } - if (session.useAddressBracketsEnforcement() + if (session.getConfiguration().useAddressBracketsEnforcement() && (!recipient.startsWith("<") || !recipient.endsWith(">"))) { if (session.getLogger().isInfoEnabled()) { StringBuilder errorBuffer = new StringBuilder(192).append( @@ -137,7 +137,7 @@ public class RcptCmdHandler extends Abst } MailAddress recipientAddress = null; // Remove < and > - if (session.useAddressBracketsEnforcement() + if (session.getConfiguration().useAddressBracketsEnforcement() || (recipient.startsWith("<") && recipient.endsWith(">"))) { recipient = recipient.substring(1, recipient.length() - 1); } Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/ReceivedDataLineFilter.java Tue Dec 20 13:49:01 2011 @@ -88,7 +88,7 @@ public class ReceivedDataLineFilter impl } headerLineBuffer.delete(0, headerLineBuffer.length()); - headerLineBuffer.append(" by ").append(session.getHelloName()).append(" (").append(getProductName()).append(") with ").append(getServiceType(session, heloMode)); + headerLineBuffer.append(" by ").append(session.getConfiguration().getHelloName()).append(" (").append(getProductName()).append(") with ").append(getServiceType(session, heloMode)); headerLineBuffer.append(" ID ").append(session.getSessionID()); Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/WelcomeMessageHandler.java Tue Dec 20 13:49:01 2011 @@ -38,16 +38,15 @@ public class WelcomeMessageHandler imple * @see org.apache.james.protocols.api.handler.ConnectHandler#onConnect(org.apache.james.protocols.api.ProtocolSession) */ public Response onConnect(SMTPSession session) { - String smtpGreeting = session.getSMTPGreeting(); + String smtpGreeting = session.getConfiguration().getSMTPGreeting(); SMTPResponse welcomeResponse; // if no greeting was configured use a default if (smtpGreeting == null) { // Initially greet the connector - // Format is: Sat, 24 Jan 1998 13:16:09 -0500 welcomeResponse = new SMTPResponse(SMTPRetCode.SERVICE_READY, new StringBuilder(256) - .append(session.getHelloName()) + .append(session.getConfiguration().getHelloName()) .append(" SMTP Server (") .append(getProductName()) .append(") ready")); Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/EhloCmdHandler.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/EhloCmdHandler.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/EhloCmdHandler.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/EhloCmdHandler.java Tue Dec 20 13:49:01 2011 @@ -58,7 +58,7 @@ public class EhloCmdHandler extends Abst * the argument passed in with the command by the SMTP client */ private Response doEHLO(SMTPSession session, String argument) { - SMTPResponse resp = new SMTPResponse(SMTPRetCode.MAIL_OK, new StringBuilder(session.getHelloName()).append(" Hello ").append(argument) + SMTPResponse resp = new SMTPResponse(SMTPRetCode.MAIL_OK, new StringBuilder(session.getConfiguration().getHelloName()).append(" Hello ").append(argument) .append(" [") .append(session.getRemoteAddress().getAddress().getHostAddress()).append("])")); Modified: james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/MailSizeEsmtpExtension.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/MailSizeEsmtpExtension.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/MailSizeEsmtpExtension.java (original) +++ james/protocols/trunk/smtp/src/main/java/org/apache/james/protocols/smtp/core/esmtp/MailSizeEsmtpExtension.java Tue Dec 20 13:49:01 2011 @@ -69,7 +69,7 @@ public class MailSizeEsmtpExtension impl @SuppressWarnings("unchecked") public List<String> getImplementedEsmtpFeatures(SMTPSession session) { // Extension defined in RFC 1870 - long maxMessageSize = session.getMaxMessageSize(); + long maxMessageSize = session.getConfiguration().getMaxMessageSize(); if (maxMessageSize > 0) { return Arrays.asList("SIZE " + maxMessageSize); } else { @@ -111,7 +111,7 @@ public class MailSizeEsmtpExtension impl size).append("."); session.getLogger().debug(debugBuffer.toString()); } - long maxMessageSize = session.getMaxMessageSize(); + long maxMessageSize = session.getConfiguration().getMaxMessageSize(); if ((maxMessageSize > 0) && (size > maxMessageSize)) { // Let the client know that the size limit has been hit. StringBuilder errorBuffer = new StringBuilder(256).append( @@ -159,7 +159,7 @@ public class MailSizeEsmtpExtension impl newSize = Long.valueOf(currentSize.intValue()+line.length); } - if (session.getMaxMessageSize() > 0 && newSize.intValue() > session.getMaxMessageSize()) { + if (session.getConfiguration().getMaxMessageSize() > 0 && newSize.intValue() > session.getConfiguration().getMaxMessageSize()) { // Add an item to the state to suppress // logging of extra lines of data // that are sent after the size limit has @@ -193,7 +193,7 @@ public class MailSizeEsmtpExtension impl .append(" from ").append(session.getRemoteAddress().getAddress().getHostAddress()) .append(" exceeding system maximum message size of ") .append( - session.getMaxMessageSize()); + session.getConfiguration().getMaxMessageSize()); session.getLogger().error(errorBuffer.toString()); return response; } else { Modified: james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java URL: http://svn.apache.org/viewvc/james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java?rev=1221259&r1=1221258&r2=1221259&view=diff ============================================================================== --- james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java (original) +++ james/protocols/trunk/smtp/src/test/java/org/apache/james/protocols/smtp/BaseFakeSMTPSession.java Tue Dec 20 13:49:01 2011 @@ -40,13 +40,6 @@ public class BaseFakeSMTPSession impleme private static final Logger log = LoggerFactory.getLogger(BaseFakeSMTPSession.class); /** - * @see org.apache.james.protocols.smtp.SMTPSession#getConfigurationData() - */ - public SMTPConfiguration getConfigurationData() { - throw new UnsupportedOperationException("Unimplemented Stub Method"); - } - - /** * @see org.apache.james.protocols.smtp.SMTPSession#getConnectionState() */ public Map<String, Object> getConnectionState() { @@ -146,40 +139,6 @@ public class BaseFakeSMTPSession impleme } /** - * @see org.apache.james.api.protocol.LogEnabledSession#writeResponse(org.apache.james.api.protocol.Response) - */ - public void writeResponse(Response response) { - throw new UnsupportedOperationException("Unimplemented Stub Method"); - } - - /** - * @see org.apache.james.protocols.smtp.SMTPSession#sleep(long) - */ - public void sleep(long ms) { - throw new UnsupportedOperationException("Unimplemented Stub Method"); - } - - public String getHelloName() { - return getConfigurationData().getHelloName(); - } - - public long getMaxMessageSize() { - return getConfigurationData().getMaxMessageSize(); - } - - public String getSMTPGreeting() { - return getConfigurationData().getSMTPGreeting(); - } - - public boolean useAddressBracketsEnforcement() { - return getConfigurationData().useAddressBracketsEnforcement(); - } - - public boolean useHeloEhloEnforcement() { - return getConfigurationData().useAddressBracketsEnforcement(); - } - - /** * @see org.apache.james.protocols.smtp.SMTPSession#getLogger() */ public Logger getLogger() { @@ -233,4 +192,9 @@ public class BaseFakeSMTPSession impleme } + @Override + public SMTPConfiguration getConfiguration() { + throw new UnsupportedOperationException("Unimplemented Stub Method"); + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org