james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r645202 - in /james/server/trunk: experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/ experimental-seda-imap-function/s...
Date Sun, 06 Apr 2008 07:30:07 GMT
Author: rdonkin
Date: Sun Apr  6 00:30:03 2008
New Revision: 645202

URL: http://svn.apache.org/viewvc?rev=645202&view=rev
Log:
Issue BYE after syntax errors when unauthenticated

Added:
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BadTag.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BogusCommand.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/IllegalTag.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/JustTag.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoCommand.test
    james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoTag.test
Modified:
    james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
    james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java
    james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoder.java
    james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java

Modified: james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java?rev=645202&r1=645201&r2=645202&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/main/java/org/apache/james/experimental/imapserver/ImapRequestHandler.java
Sun Apr  6 00:30:03 2008
@@ -133,7 +133,7 @@
                                    ImapResponseComposer response,
                                    ImapSession session)
     {
-        ImapMessage message = decoder.decode(request);
+        ImapMessage message = decoder.decode(request, session);
         final ResponseEncoder responseEncoder = new ResponseEncoder(encoder, response);
         processor.process(message, responseEncoder, session);
         final boolean result;

Modified: james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java?rev=645202&r1=645201&r2=645202&view=diff
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java
(original)
+++ james/server/trunk/experimental-seda-imap-function/src/test/java/org/apache/james/test/functional/imap/AbstractTestSecurity.java
Sun Apr  6 00:30:03 2008
@@ -38,4 +38,76 @@
     public void testLoginThreeStrikesITALY() throws Exception {
         scriptTest("LoginThreeStrikes", Locale.ITALY);
     }
+    
+    public void testBadTagUS() throws Exception {
+        scriptTest("BadTag", Locale.US);
+    }
+    
+    public void testBadTagKOREA() throws Exception {
+        scriptTest("BadTag", Locale.KOREA);
+    }
+    
+    public void testBadTagITALY() throws Exception {
+        scriptTest("BadTag", Locale.ITALY);
+    }
+    
+    public void testNoTagUS() throws Exception {
+        scriptTest("NoTag", Locale.US);
+    }
+    
+    public void testNoTagKOREA() throws Exception {
+        scriptTest("NoTag", Locale.KOREA);
+    }
+    
+    public void testNoTagITALY() throws Exception {
+        scriptTest("NoTag", Locale.ITALY);
+    }
+    
+    public void testIllegalTagUS() throws Exception {
+        scriptTest("IllegalTag", Locale.US);
+    }
+    
+    public void testIllegalTagKOREA() throws Exception {
+        scriptTest("IllegalTag", Locale.KOREA);
+    }
+    
+    public void testIllegalTagITALY() throws Exception {
+        scriptTest("IllegalTag", Locale.ITALY);
+    }
+    
+    public void testJustTagUS() throws Exception {
+        scriptTest("JustTag", Locale.US);
+    }
+    
+    public void testJustTagKOREA() throws Exception {
+        scriptTest("JustTag", Locale.KOREA);
+    }
+    
+    public void testJustTagITALY() throws Exception {
+        scriptTest("JustTag", Locale.ITALY);
+    }
+    
+    public void testNoCommandUS() throws Exception {
+        scriptTest("NoCommand", Locale.US);
+    }
+    
+    public void testNoCommandKOREA() throws Exception {
+        scriptTest("NoCommand", Locale.KOREA);
+    }
+    
+    public void testNoCommandITALY() throws Exception {
+        scriptTest("NoCommand", Locale.ITALY);
+    }
+    
+    public void testBogusCommandUS() throws Exception {
+        scriptTest("BogusCommand", Locale.US);
+    }
+    
+    public void testBogusCommandKOREA() throws Exception {
+        scriptTest("BogusCommand", Locale.KOREA);
+    }
+    
+    public void testNoBogusITALY() throws Exception {
+        scriptTest("BogusCommand", Locale.ITALY);
+    }
 }

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BadTag.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BadTag.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BadTag.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BadTag.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: (((
+S: \* BYE Illegal tag.
\ No newline at end of file

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BogusCommand.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BogusCommand.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BogusCommand.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/BogusCommand.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: A88345 BOGUS
+S: \* BYE Unknown command.
\ No newline at end of file

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/IllegalTag.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/IllegalTag.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/IllegalTag.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/IllegalTag.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: +++++++++++++++++++++++++++++++++++++++++
+S: \* BYE Illegal tag.
\ No newline at end of file

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/JustTag.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/JustTag.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/JustTag.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/JustTag.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: A88345 
+S: \* BYE Unknown command.
\ No newline at end of file

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoCommand.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoCommand.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoCommand.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoCommand.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: A88345 
+S: \* BYE Unknown command.
\ No newline at end of file

Added: james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoTag.test
URL: http://svn.apache.org/viewvc/james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoTag.test?rev=645202&view=auto
==============================================================================
--- james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoTag.test
(added)
+++ james/server/trunk/experimental-seda-imap-function/src/test/resources/org/apache/james/test/functional/imap/scripts/NoTag.test
Sun Apr  6 00:30:03 2008
@@ -0,0 +1,24 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you 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.                                           #
+################################################################
+#
+# Send a bye when the tag is bad
+#
+S: \* OK IMAP4rev1 Server ready
+C: 
+S: \* BYE Illegal tag.
\ No newline at end of file

Modified: james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java?rev=645202&r1=645201&r2=645202&view=diff
==============================================================================
--- james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
(original)
+++ james/server/trunk/imap-api/src/main/java/org/apache/james/api/imap/display/HumanReadableTextKey.java
Sun Apr  6 00:30:03 2008
@@ -118,6 +118,10 @@
         = new HumanReadableTextKey("org.apache.james.imap.TOO_MANY_FAILURES",
              "Login failed too many times.");
     
+    public static final HumanReadableTextKey BYE_UNKNOWN_COMMAND
+    = new HumanReadableTextKey("org.apache.james.imap.BYE_UNKNOWN_COMMAND",
+            "Unknown command.");
+    
     private final String defaultValue;
     private final String key;
     public HumanReadableTextKey(final String key, final String defaultValue) {

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoder.java?rev=645202&r1=645201&r2=645202&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoder.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/ImapDecoder.java
Sun Apr  6 00:30:03 2008
@@ -19,7 +19,8 @@
 package org.apache.james.imapserver.codec.decode;
 
 import org.apache.james.api.imap.ImapMessage;
+import org.apache.james.api.imap.process.ImapSession;
 
 public interface ImapDecoder {
-    public ImapMessage decode(final ImapRequestLineReader request);
+    public ImapMessage decode(final ImapRequestLineReader request, ImapSession session);
 }

Modified: james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java?rev=645202&r1=645201&r2=645202&view=diff
==============================================================================
--- james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
(original)
+++ james/server/trunk/imap-codec-library/src/main/java/org/apache/james/imapserver/codec/decode/main/DefaultImapDecoder.java
Sun Apr  6 00:30:03 2008
@@ -21,8 +21,10 @@
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.api.imap.ImapMessage;
+import org.apache.james.api.imap.ImapSessionState;
 import org.apache.james.api.imap.display.HumanReadableTextKey;
 import org.apache.james.api.imap.imap4rev1.Imap4Rev1MessageFactory;
+import org.apache.james.api.imap.process.ImapSession;
 import org.apache.james.imapserver.codec.ProtocolException;
 import org.apache.james.imapserver.codec.decode.ImapCommandParser;
 import org.apache.james.imapserver.codec.decode.ImapCommandParserFactory;
@@ -49,13 +51,13 @@
         setupLogger(imapCommands);
     }
     
-    public ImapMessage decode(ImapRequestLineReader request) {
+    public ImapMessage decode(ImapRequestLineReader request, ImapSession session) {
         ImapMessage message;
         final Logger logger = getLogger(); 
         
         try {
             final String tag = AbstractImapCommandParser.tag( request );    
-            message = decodeCommandTagged(request, logger, tag);
+            message = decodeCommandTagged(request, logger, tag, session);
         }
         catch ( ProtocolException e ) {
             logger.debug("Cannot parse tag", e);
@@ -68,24 +70,37 @@
         return message;
     }
 
-    private ImapMessage decodeCommandTagged(final ImapRequestLineReader request, final Logger
logger, final String tag) {
+    private ImapMessage decodeCommandTagged(final ImapRequestLineReader request, final Logger
logger, 
+            final String tag, final ImapSession session) {
         ImapMessage message;
         if (logger.isDebugEnabled()) { 
             logger.debug( "Got <tag>: " + tag );
         }
         try {
             final String commandName = AbstractImapCommandParser.atom( request );
-            message = decodeCommandNamed(request, tag, commandName, logger);
+            message = decodeCommandNamed(request, tag, commandName, logger, session);
         }
         catch ( ProtocolException e ) {
-            logger.debug("Error during initial request parsing", e);            
+            logger.debug("Error during initial request parsing", e);    
+            message = unknownCommand(tag, session);
+        }
+        return message;
+    }
+
+    private ImapMessage unknownCommand(final String tag,
+            final ImapSession session) {
+        ImapMessage message;
+        if (session.getState() == ImapSessionState.NON_AUTHENTICATED) {
+            message = messageFactory.bye(HumanReadableTextKey.BYE_UNKNOWN_COMMAND);
+            session.logout();
+        } else {
             message = messageFactory.taggedBad(tag, null, HumanReadableTextKey.UNKNOWN_COMMAND);
         }
         return message;
     }
 
     private ImapMessage decodeCommandNamed(final ImapRequestLineReader request, 
-            final String tag, String commandName, final Logger logger) {
+            final String tag, String commandName, final Logger logger, final ImapSession
session) {
         ImapMessage message;
         if (logger.isDebugEnabled()) { 
             logger.debug( "Got <command>: " + commandName); 
@@ -93,7 +108,7 @@
         final ImapCommandParser command = imapCommands.getParser( commandName );
         if ( command == null ) {
             logger.info("Missing command implementation.");
-            message = messageFactory.taggedBad(tag, null, HumanReadableTextKey.UNKNOWN_COMMAND);
+            message = unknownCommand(tag, session);
         } else {
             message = command.parse( request, tag );
         }



---------------------------------------------------------------------
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