Author: noel Date: Sun Apr 16 10:22:35 2006 New Revision: 394514 URL: http://svn.apache.org/viewcvs?rev=394514&view=rev Log: Fix JAMES-479, so that RSET no longer invalidates HELO/EHLO check. Also fix line endings in SMTPSession.java
Modified: james/server/trunk/src/java/org/apache/james/smtpserver/EhloCmdHandler.java james/server/trunk/src/java/org/apache/james/smtpserver/HeloCmdHandler.java james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java Modified: james/server/trunk/src/java/org/apache/james/smtpserver/EhloCmdHandler.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/EhloCmdHandler.java?rev=394514&r1=394513&r2=394514&view=diff ============================================================================== --- james/server/trunk/src/java/org/apache/james/smtpserver/EhloCmdHandler.java (original) +++ james/server/trunk/src/java/org/apache/james/smtpserver/EhloCmdHandler.java Sun Apr 16 10:22:35 2006 @@ -92,6 +92,7 @@ session.writeResponse(responseString); } else if (badEhlo == false){ session.resetState(); + session.setHeloEhloSend(true); session.getState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME); ArrayList esmtpextensions = new ArrayList(); Modified: james/server/trunk/src/java/org/apache/james/smtpserver/HeloCmdHandler.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/HeloCmdHandler.java?rev=394514&r1=394513&r2=394514&view=diff ============================================================================== --- james/server/trunk/src/java/org/apache/james/smtpserver/HeloCmdHandler.java (original) +++ james/server/trunk/src/java/org/apache/james/smtpserver/HeloCmdHandler.java Sun Apr 16 10:22:35 2006 @@ -93,6 +93,7 @@ getLogger().info(responseString); } else if (badHelo == false) { session.resetState(); + session.setHeloEhloSend(true); session.getState().put(SMTPSession.CURRENT_HELO_MODE, COMMAND_NAME); session.getResponseBuffer().append("250 ") .append(session.getConfigurationData().getHelloName()) Modified: james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java?rev=394514&r1=394513&r2=394514&view=diff ============================================================================== --- james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java (original) +++ james/server/trunk/src/java/org/apache/james/smtpserver/MailCmdHandler.java Sun Apr 16 10:22:35 2006 @@ -105,7 +105,7 @@ if (session.getState().containsKey(SMTPSession.SENDER)) { responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Sender already specified"; session.writeResponse(responseString); - } else if (!session.getState().containsKey(SMTPSession.CURRENT_HELO_MODE) && session.useHeloEhloEnforcement()) { + } else if (!session.isHeloEhloSend() && session.useHeloEhloEnforcement()) { responseString = "503 "+DSNStatus.getStatus(DSNStatus.PERMANENT,DSNStatus.DELIVERY_OTHER)+" Need HELO or EHLO before MAIL"; session.writeResponse(responseString); } else if (argument == null || !argument.toUpperCase(Locale.US).equals("FROM") Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java?rev=394514&r1=394513&r2=394514&view=diff ============================================================================== --- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java (original) +++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandler.java Sun Apr 16 10:22:35 2006 @@ -168,6 +168,11 @@ private boolean heloEhloEnforcement; /** + * Whether the remote Server has send HELO/EHLO + */ + private boolean heloEhloSend; + + /** * TEMPORARY: is the sending address blocklisted */ private boolean blocklisted; @@ -709,6 +714,21 @@ public boolean useHeloEhloEnforcement() { return heloEhloEnforcement; } + + /** + * @see org.apache.james.smtpserver.SMTPSession#isHeloEhloSend() + */ + public boolean isHeloEhloSend() { + return heloEhloSend; + } + + /** + * @see org.apache.james.smtpserver.SMTPSession#setHeloEhloSend() + */ + public void setHeloEhloSend(boolean heloEhloSend ) { + this.heloEhloSend = heloEhloSend; + } + /** * @see org.apache.james.smtpserver.SMTPSession#getUser() */ Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java URL: http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java?rev=394514&r1=394513&r2=394514&view=diff ============================================================================== --- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java (original) +++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPSession.java Sun Apr 16 10:22:35 2006 @@ -1,224 +1,236 @@ -/*********************************************************************** - * Copyright (c) 1999-2006 The Apache Software Foundation. * - * All rights reserved. * - * ------------------------------------------------------------------- * - * Licensed 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.smtpserver; - - -import org.apache.james.util.watchdog.Watchdog; -import org.apache.mailet.Mail; - -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; - -/** - * All the handlers access this interface to communicate with - * SMTPHandler object - */ - -public interface SMTPSession { - - // Keys used to store/lookup data in the internal state hash map - public final static String MESG_FAILED = "MESG_FAILED"; // Message failed flag - public final static String SENDER = "SENDER_ADDRESS"; // Sender's email address - public final static String RCPT_LIST = "RCPT_LIST"; // The message recipients - public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO - - /** - * Writes response string to the client - * - * @param respString String that needs to send to the client - */ - void writeResponse(String respString); - - /** - * Reads a line of characters off the command line. - * - * @return the trimmed input line - * @throws IOException if an exception is generated reading in the input characters - */ - String readCommandLine() throws IOException; - - - /** - * Returns ResponseBuffer, this optimizes the unecessary creation of resources - * by each handler object - * - * @return responseBuffer - */ - StringBuffer getResponseBuffer(); - - /** - * Clears the response buffer, returning the String of characters in the buffer. - * - * @return the data in the response buffer - */ - String clearResponseBuffer(); - - /** - * Returns Inputstream for handling messages and commands - * - * @return InputStream object - */ - InputStream getInputStream(); - - /** - * Returns currently process command name - * - * @return current command name - */ - String getCommandName(); - - /** - * Returns currently process command argument - * - * @return current command argument - */ - String getCommandArgument(); - - /** - * Returns Mail object for message handlers to process - * - * @return Mail object - */ - Mail getMail(); - - /** - * Sets the MailImpl object for further processing - * - * @param mail MailImpl object - */ - void setMail(Mail mail); - - /** - * Returns host name of the client - * - * @return hostname of the client - */ - String getRemoteHost(); - - /** - * Returns host ip address of the client - * - * @return host ip address of the client - */ - String getRemoteIPAddress(); - - /** - * this makes the message to be dropped inprotocol - * - */ - void abortMessage(); - - /** - * this makes the session to close - * - */ - void endSession(); - - /** - * Returns the session status - * - * @return if the session is open or closed - */ - boolean isSessionEnded(); - - /** - * Returns Map that consists of the state of the SMTPSession - * - * @return map of the current SMTPSession state - */ - HashMap getState(); - - /** - * Resets message-specific, but not authenticated user, state. - * - */ - void resetState(); - - /** - * Returns SMTPHandler service wide configuration - * - * @return SMTPHandlerConfigurationData - */ - SMTPHandlerConfigurationData getConfigurationData(); - - /** - * Sets the blocklisted value - * - * @param blocklisted - */ - void setBlockListed(boolean blocklisted); - - /** - * Returns the blocklisted status - * - * @return blocklisted - */ - boolean isBlockListed(); - - /** - * Returns whether Relaying is allowed or not - * - * @return the relaying status - */ - boolean isRelayingAllowed(); - - /** - * Returns whether Authentication is required or not - * - * @return authentication required or not - */ - boolean isAuthRequired(); - - /** - * Returns whether remote server needs to send HELO/EHLO - * - * @return HELO/EHLO required or not - */ - boolean useHeloEhloEnforcement(); - - /** - * Returns the user name associated with this SMTP interaction. - * - * @return the user name - */ - String getUser(); - - /** - * Sets the user name associated with this SMTP interaction. - * - * @param userID the user name - */ - void setUser(String user); - - /** - * Returns Watchdog object used for handling timeout - * - * @return Watchdog object - */ - Watchdog getWatchdog(); - - /** - * Returns the SMTP session id - * - * @return SMTP session id - */ - String getSessionID(); - -} - +/*********************************************************************** + * Copyright (c) 1999-2006 The Apache Software Foundation. * + * All rights reserved. * + * ------------------------------------------------------------------- * + * Licensed 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.smtpserver; + + +import org.apache.james.util.watchdog.Watchdog; +import org.apache.mailet.Mail; + +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; + +/** + * All the handlers access this interface to communicate with + * SMTPHandler object + */ + +public interface SMTPSession { + + // Keys used to store/lookup data in the internal state hash map + public final static String MESG_FAILED = "MESG_FAILED"; // Message failed flag + public final static String SENDER = "SENDER_ADDRESS"; // Sender's email address + public final static String RCPT_LIST = "RCPT_LIST"; // The message recipients + public final static String CURRENT_HELO_MODE = "CURRENT_HELO_MODE"; // HELO or EHLO + + /** + * Writes response string to the client + * + * @param respString String that needs to send to the client + */ + void writeResponse(String respString); + + /** + * Reads a line of characters off the command line. + * + * @return the trimmed input line + * @throws IOException if an exception is generated reading in the input characters + */ + String readCommandLine() throws IOException; + + + /** + * Returns ResponseBuffer, this optimizes the unecessary creation of resources + * by each handler object + * + * @return responseBuffer + */ + StringBuffer getResponseBuffer(); + + /** + * Clears the response buffer, returning the String of characters in the buffer. + * + * @return the data in the response buffer + */ + String clearResponseBuffer(); + + /** + * Returns Inputstream for handling messages and commands + * + * @return InputStream object + */ + InputStream getInputStream(); + + /** + * Returns currently process command name + * + * @return current command name + */ + String getCommandName(); + + /** + * Returns currently process command argument + * + * @return current command argument + */ + String getCommandArgument(); + + /** + * Returns Mail object for message handlers to process + * + * @return Mail object + */ + Mail getMail(); + + /** + * Sets the MailImpl object for further processing + * + * @param mail MailImpl object + */ + void setMail(Mail mail); + + /** + * Returns host name of the client + * + * @return hostname of the client + */ + String getRemoteHost(); + + /** + * Returns host ip address of the client + * + * @return host ip address of the client + */ + String getRemoteIPAddress(); + + /** + * this makes the message to be dropped inprotocol + * + */ + void abortMessage(); + + /** + * this makes the session to close + * + */ + void endSession(); + + /** + * Returns the session status + * + * @return if the session is open or closed + */ + boolean isSessionEnded(); + + /** + * Returns Map that consists of the state of the SMTPSession + * + * @return map of the current SMTPSession state + */ + HashMap getState(); + + /** + * Resets message-specific, but not authenticated user, state. + * + */ + void resetState(); + + /** + * Returns SMTPHandler service wide configuration + * + * @return SMTPHandlerConfigurationData + */ + SMTPHandlerConfigurationData getConfigurationData(); + + /** + * Sets the blocklisted value + * + * @param blocklisted + */ + void setBlockListed(boolean blocklisted); + + /** + * Returns the blocklisted status + * + * @return blocklisted + */ + boolean isBlockListed(); + + /** + * Returns whether Relaying is allowed or not + * + * @return the relaying status + */ + boolean isRelayingAllowed(); + + /** + * Returns whether Authentication is required or not + * + * @return authentication required or not + */ + boolean isAuthRequired(); + + /** + * Returns whether remote server needs to send HELO/EHLO + * + * @return HELO/EHLO required or not + */ + boolean useHeloEhloEnforcement(); + + /** + * Identify if a HELO/EHLO was send in this session + * + * @return HELO/EHLO was send + */ + boolean isHeloEhloSend(); + + /** + * Get called if HELO/EHLO was send + */ + void setHeloEhloSend(boolean heloEhloSend); + + /** + * Returns the user name associated with this SMTP interaction. + * + * @return the user name + */ + String getUser(); + + /** + * Sets the user name associated with this SMTP interaction. + * + * @param userID the user name + */ + void setUser(String user); + + /** + * Returns Watchdog object used for handling timeout + * + * @return Watchdog object + */ + Watchdog getWatchdog(); + + /** + * Returns the SMTP session id + * + * @return SMTP session id + */ + String getSessionID(); + +} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]