You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by pp...@apache.org on 2012/02/21 22:05:03 UTC

svn commit: r1292019 [1/3] - in /james: imap/trunk/api/src/main/java/org/apache/james/imap/api/ imap/trunk/api/src/main/java/org/apache/james/imap/api/display/ imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ imap/trunk/message/src...

Author: ppalaga
Date: Tue Feb 21 21:05:02 2012
New Revision: 1292019

URL: http://svn.apache.org/viewvc?rev=1292019&view=rev
Log:
IMAP-359: Support for missing ACL commands SETACL, LISTRIGHTS, MYRIGHTS and DELETERIGHTS

Added:
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/DeleteACLCommandParser.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ListRightsCommandParser.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/MyRightsCommandParser.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListRightsResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MyRightsResponseEncoder.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/DeleteACLRequest.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/ListRightsRequest.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/MyRightsRequest.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/SetACLRequest.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListRightsResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/MyRightsResponse.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java
Modified:
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ACLResponse.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java
    james/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/MessageManager.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/acl/MailboxACLResolver.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/acl/UnionMailboxACLResolver.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/exception/UnsupportedRightException.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java
    james/mailbox/trunk/api/src/main/java/org/apache/james/mailbox/model/SimpleMailboxACL.java
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java
    james/mailbox/trunk/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
    james/protocols/trunk/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/ImapConstants.java Tue Feb 21 21:05:02 2012
@@ -235,6 +235,10 @@ public interface ImapConstants {
 
     public static final String ACL_RESPONSE_NAME = "ACL";
 
+    public static final String LISTRIGHTS_RESPONSE_NAME = "LISTRIGHTS";
+    
+    public static final String MYRIGHTS_RESPONSE_NAME = "MYRIGHTS";
+
     public static final String NAME_ATTRIBUTE_NOINFERIORS = "\\Noinferiors";
 
     public static final String NAME_ATTRIBUTE_NOSELECT = "\\Noselect";

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java (original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/display/HumanReadableText.java Tue Feb 21 21:05:02 2012
@@ -156,9 +156,12 @@ public class HumanReadableText {
     public static final HumanReadableText QRESYNC_CLOSED = new HumanReadableText("org.apache.james.imap.QRESYNC_CLOSED", "");
     public static final HumanReadableText QRESYNC_VANISHED_WITHOUT_CHANGEDSINCE = new HumanReadableText("org.apache.james.imap.QRESYNC_VANISHED_WITHOUT_CHANGEDSINCE", "VANISHED used without CHANGEDSINCE");
 
+    public static final String UNSUFFICIENT_RIGHTS_DEFAULT_VALUE = "You need the {0} right to perform command {1} on mailbox {2}.";
     public static final String UNSUFFICIENT_RIGHTS_KEY = "org.apache.james.imap.UNSUFFICIENT_RIGHTS";
-    public static final String UNSUFFICIENT_RIGHTS_DEFAULT_VALUE = "You need the ''{0}'' right to perform command ''{1}'' on mailbox ''{2}''.";
-    
+
+    public static final String UNSUPPORTED_RIGHT_KEY = "org.apache.james.imap.UNSUPPORTED_RIGHT";
+    public static final String UNSUPPORTED_RIGHT_DEFAULT_VALUE = "The {0} right is not supported.";
+
     private final String defaultValue;
 
     private final String key;

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/DeleteACLCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/DeleteACLCommandParser.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/DeleteACLCommandParser.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/DeleteACLCommandParser.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.decode.parser;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.decode.DecodingException;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.decode.base.AbstractImapCommandParser;
+import org.apache.james.imap.message.request.DeleteACLRequest;
+
+/**
+ * DELETEACL Parser
+ * 
+ * @author Peter Palaga
+ */
+public class DeleteACLCommandParser extends AbstractImapCommandParser {
+
+    public DeleteACLCommandParser() {
+        super(ImapCommand.authenticatedStateCommand(ImapConstants.DELETEACL_COMMAND_NAME));
+    }
+
+    @Override
+    protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException {
+        final String mailboxName = request.mailbox();
+        final String identifier = request.astring();
+        request.eol();
+        return new DeleteACLRequest(tag, command, mailboxName, identifier);
+    }
+
+}

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ImapParserFactory.java Tue Feb 21 21:05:02 2012
@@ -74,10 +74,10 @@ public class ImapParserFactory implement
 
         // RFC4314 GETACL, SETACL, DELETEACL, LISTRIGHTS, MYRIGHTS
         _imapCommands.put(ImapConstants.GETACL_COMMAND_NAME, GetACLCommandParser.class );
-        // _imapCommands.put( "SETACL", SetAclCommand.class );
-        // _imapCommands.put( "DELETEACL", DeleteAclCommand.class );
-        // _imapCommands.put( "LISTRIGHTS", ListRightsCommand.class );
-        // _imapCommands.put( "MYRIGHTS", MyRightsCommand.class );
+        _imapCommands.put(ImapConstants.SETACL_COMMAND_NAME, SetACLCommandParser.class );
+        _imapCommands.put(ImapConstants.DELETEACL_COMMAND_NAME, DeleteACLCommandParser.class );
+        _imapCommands.put(ImapConstants.LISTRIGHTS_COMMAND_NAME, ListRightsCommandParser.class );
+        _imapCommands.put(ImapConstants.MYRIGHTS_COMMAND_NAME, MyRightsCommandParser.class );
 
         // Commands only valid in SELECTED state.
         // CHECK, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY, UID and IDLE

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ListRightsCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ListRightsCommandParser.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ListRightsCommandParser.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/ListRightsCommandParser.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.decode.parser;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.decode.DecodingException;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.decode.base.AbstractImapCommandParser;
+import org.apache.james.imap.message.request.ListRightsRequest;
+
+/**
+ * LISTRIGHTS Parser
+ * 
+ * @author Peter Palaga
+ */
+public class ListRightsCommandParser extends AbstractImapCommandParser {
+
+    public ListRightsCommandParser() {
+        super(ImapCommand.authenticatedStateCommand(ImapConstants.LISTRIGHTS_COMMAND_NAME));
+    }
+
+    @Override
+    protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException {
+        final String mailboxName = request.mailbox();
+        final String identifier = request.astring();
+        request.eol();
+        return new ListRightsRequest(tag, command, mailboxName, identifier);
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/MyRightsCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/MyRightsCommandParser.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/MyRightsCommandParser.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/MyRightsCommandParser.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,49 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.decode.parser;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.decode.DecodingException;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.decode.base.AbstractImapCommandParser;
+import org.apache.james.imap.message.request.MyRightsRequest;
+
+/**
+ * MYRIGHTS Parser
+ * 
+ * @author Peter Palaga
+ */
+public class MyRightsCommandParser extends AbstractImapCommandParser {
+
+    public MyRightsCommandParser() {
+        super(ImapCommand.authenticatedStateCommand(ImapConstants.MYRIGHTS_COMMAND_NAME));
+    }
+
+    @Override
+    protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException {
+        final String mailboxName = request.mailbox();
+        request.eol();
+        return new MyRightsRequest(tag, command, mailboxName);
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/SetACLCommandParser.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.decode.parser;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.decode.DecodingException;
+import org.apache.james.imap.decode.ImapRequestLineReader;
+import org.apache.james.imap.decode.base.AbstractImapCommandParser;
+import org.apache.james.imap.message.request.SetACLRequest;
+
+/**
+ * SETACL Parser
+ * 
+ * @author Peter Palaga
+ */
+public class SetACLCommandParser extends AbstractImapCommandParser {
+
+    public SetACLCommandParser() {
+        super(ImapCommand.authenticatedStateCommand(ImapConstants.SETACL_COMMAND_NAME));
+    }
+
+    @Override
+    protected ImapMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, ImapSession session) throws DecodingException {
+        final String mailboxName = request.mailbox();
+        final String identifier = request.astring();
+        final String rights = request.astring();
+        request.eol();
+        return new SetACLRequest(tag, command, mailboxName, identifier, rights);
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListRightsResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListRightsResponseEncoder.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListRightsResponseEncoder.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/ListRightsResponseEncoder.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.encode;
+
+import java.io.IOException;
+
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
+import org.apache.james.imap.message.response.ListRightsResponse;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+
+/**
+ * ACL Response Encoder.
+ * 
+ * @author Peter Palaga
+ */
+public class ListRightsResponseEncoder extends AbstractChainedImapEncoder {
+
+    public ListRightsResponseEncoder(ImapEncoder next) {
+        super(next);
+    }
+
+    /** 
+     * @see
+     * org.apache.james.imap.encode.base.AbstractChainedImapEncoder#doEncode
+     * (org.apache.james.imap.api.ImapMessage,
+     * org.apache.james.imap.encode.ImapResponseComposer,
+     * org.apache.james.imap.api.process.ImapSession)
+     */
+    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
+        final ListRightsResponse listRightsResponse = (ListRightsResponse) acceptableMessage;
+        composer.untagged();
+        composer.commandName(ImapConstants.LISTRIGHTS_RESPONSE_NAME);
+        
+        String mailboxName = listRightsResponse.getMailboxName();
+        composer.mailbox(mailboxName == null ? "" : mailboxName);
+        
+        String identifier = listRightsResponse.getIdentifier();
+        composer.quote(identifier);
+        
+        MailboxACLRights[] rights = listRightsResponse.getRights();
+        
+        for (MailboxACLRights entry : rights) {
+            composer.quote(entry.serialize());
+       }
+        composer.end();
+    }
+
+    /** 
+     * @see
+     * org.apache.james.imap.encode.base.AbstractChainedImapEncoder#isAcceptable
+     * (org.apache.james.imap.api.ImapMessage)
+     */
+    public boolean isAcceptable(ImapMessage message) {
+        return message instanceof ListRightsResponse;
+    }
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MyRightsResponseEncoder.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MyRightsResponseEncoder.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MyRightsResponseEncoder.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/MyRightsResponseEncoder.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.encode;
+
+import java.io.IOException;
+
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapMessage;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.encode.base.AbstractChainedImapEncoder;
+import org.apache.james.imap.message.response.MyRightsResponse;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+
+/**
+ * MYRIGHTS Response Encoder.
+ * 
+ * @author Peter Palaga
+ */
+public class MyRightsResponseEncoder extends AbstractChainedImapEncoder {
+
+    public MyRightsResponseEncoder(ImapEncoder next) {
+        super(next);
+    }
+
+    /** 
+     * @see
+     * org.apache.james.imap.encode.base.AbstractChainedImapEncoder#doEncode
+     * (org.apache.james.imap.api.ImapMessage,
+     * org.apache.james.imap.encode.ImapResponseComposer,
+     * org.apache.james.imap.api.process.ImapSession)
+     */
+    protected void doEncode(ImapMessage acceptableMessage, ImapResponseComposer composer, ImapSession session) throws IOException {
+        final MyRightsResponse aclResponse = (MyRightsResponse) acceptableMessage;
+        final MailboxACLRights myRights = aclResponse.getMyRights();
+        composer.untagged();
+        composer.commandName(ImapConstants.MYRIGHTS_RESPONSE_NAME);
+        
+        String mailboxName = aclResponse.getMailboxName();
+        composer.mailbox(mailboxName == null ? "" : mailboxName);
+        composer.quote(myRights == null ? "" : myRights.serialize());
+        composer.end();
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.james.imap.encode.base.AbstractChainedImapEncoder#isAcceptable
+     * (org.apache.james.imap.api.ImapMessage)
+     */
+    public boolean isAcceptable(ImapMessage message) {
+        return message instanceof MyRightsResponse;
+    }
+}

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/encode/main/DefaultImapEncoderFactory.java Tue Feb 21 21:05:02 2012
@@ -34,6 +34,8 @@ import org.apache.james.imap.encode.Imap
 import org.apache.james.imap.encode.ImapEncoderFactory;
 import org.apache.james.imap.encode.LSubResponseEncoder;
 import org.apache.james.imap.encode.ListResponseEncoder;
+import org.apache.james.imap.encode.ListRightsResponseEncoder;
+import org.apache.james.imap.encode.MyRightsResponseEncoder;
 import org.apache.james.imap.encode.NamespaceResponseEncoder;
 import org.apache.james.imap.encode.RecentResponseEncoder;
 import org.apache.james.imap.encode.MailboxStatusResponseEncoder;
@@ -61,7 +63,9 @@ public class DefaultImapEncoderFactory i
     public static final ImapEncoder createDefaultEncoder(final Localizer localizer, final boolean neverAddBodyStructureExtensions) {
         final EndImapEncoder endImapEncoder = new EndImapEncoder();
         
-        final ACLResponseEncoder aclResponseEncoder = new ACLResponseEncoder(endImapEncoder); 
+        final MyRightsResponseEncoder myRightsResponseEncoder = new MyRightsResponseEncoder(endImapEncoder); 
+        final ListRightsResponseEncoder listRightsResponseEncoder = new ListRightsResponseEncoder(myRightsResponseEncoder); 
+        final ACLResponseEncoder aclResponseEncoder = new ACLResponseEncoder(listRightsResponseEncoder); 
         final NamespaceResponseEncoder namespaceEncoder = new NamespaceResponseEncoder(aclResponseEncoder);
         final StatusResponseEncoder statusResponseEncoder = new StatusResponseEncoder(namespaceEncoder, localizer);
         final RecentResponseEncoder recentResponseEncoder = new RecentResponseEncoder(statusResponseEncoder);

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/DeleteACLRequest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/DeleteACLRequest.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/DeleteACLRequest.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/DeleteACLRequest.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * DELETEACL Request.
+ * 
+ * @author Peter Palaga
+ */
+public class DeleteACLRequest extends AbstractImapRequest {
+    private final String identifier;
+    private final String mailboxName;
+
+    public DeleteACLRequest(String tag, ImapCommand command, String mailboxName, String identifier) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+        this.identifier = identifier;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/ListRightsRequest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/ListRightsRequest.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/ListRightsRequest.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/ListRightsRequest.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * LISTRIGHTS Request.
+ * 
+ * @author Peter Palaga
+ */
+public class ListRightsRequest extends AbstractImapRequest {
+    private final String identifier;
+    private final String mailboxName;
+
+    public ListRightsRequest(String tag, ImapCommand command, String mailboxName, String identifier) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+        this.identifier = identifier;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/MyRightsRequest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/MyRightsRequest.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/MyRightsRequest.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/MyRightsRequest.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * MYRIGHTS Request.
+ * 
+ * @author Peter Palaga
+ */
+public class MyRightsRequest extends AbstractImapRequest {
+    private final String mailboxName;
+
+    public MyRightsRequest(String tag, ImapCommand command, String mailboxName) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/SetACLRequest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/SetACLRequest.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/SetACLRequest.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/request/SetACLRequest.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.request;
+
+import org.apache.james.imap.api.ImapCommand;
+
+/**
+ * SETACL Request.
+ * 
+ * @author Peter Palaga
+ */
+public class SetACLRequest extends AbstractImapRequest {
+    private final String identifier;
+    private final String mailboxName;
+    private final String rights;
+
+    public SetACLRequest(String tag, ImapCommand command, String mailboxName, String identifier, String rights) {
+        super(tag, command);
+        this.mailboxName = mailboxName;
+        this.identifier = identifier;
+        this.rights = rights;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+    public String getRights() {
+        return rights;
+    }
+
+}

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ACLResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ACLResponse.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ACLResponse.java (original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ACLResponse.java Tue Feb 21 21:05:02 2012
@@ -46,8 +46,8 @@ public final class ACLResponse implement
     public boolean equals(Object o) {
         if (o instanceof ACLResponse) {
             ACLResponse other = (ACLResponse) o;
-            return this.acl == other.acl || (this.acl != null && this.acl.equals(other.acl))
-                    && this.mailboxName == other.mailboxName || (this.mailboxName != null && this.mailboxName.equals(other.mailboxName))
+            return (this.acl == other.acl || (this.acl != null && this.acl.equals(other.acl)))
+                    && (this.mailboxName == other.mailboxName || (this.mailboxName != null && this.mailboxName.equals(other.mailboxName)))
                     ;
         }
         return false;

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListRightsResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListRightsResponse.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListRightsResponse.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ListRightsResponse.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.response;
+
+import java.util.Arrays;
+
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.message.response.ImapResponseMessage;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+
+/**
+ * LISTRIGHTS Response.
+ * 
+ * @author Peter Palaga
+ */
+public final class ListRightsResponse implements ImapResponseMessage {
+
+    private final String identifier;
+    private final String mailboxName;
+    private final MailboxACLRights[] rights;
+
+    public ListRightsResponse(String mailboxName, String identifier, MailboxACLRights[] rights) {
+        super();
+        this.mailboxName = mailboxName;
+        this.identifier = identifier;
+        this.rights = rights;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof ListRightsResponse) {
+            ListRightsResponse other = (ListRightsResponse) o;
+            return (this.mailboxName == other.mailboxName || (this.mailboxName != null && this.mailboxName.equals(other.mailboxName))) && (this.identifier == other.identifier || (this.identifier != null && this.identifier.equals(other.identifier))) && Arrays.equals(this.rights, other.rights);
+        }
+        return false;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+    public MailboxACLRights[] getRights() {
+        return rights;
+    }
+
+    @Override
+    public int hashCode() {
+        final int PRIME = 31;
+        int hashCode = (mailboxName == null ? 0 : mailboxName.hashCode());
+        hashCode = PRIME * hashCode + (identifier == null ? 0 : identifier.hashCode());
+        hashCode = PRIME * hashCode + (rights == null ? 0 : Arrays.hashCode(rights));
+
+        return hashCode;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder result = new StringBuilder().append(ImapConstants.LISTRIGHTS_RESPONSE_NAME).append(' ').append(mailboxName).append(' ').append(identifier);
+
+        for (MailboxACLRights optionalRightsGroup : rights) {
+            result.append(' ').append(optionalRightsGroup.toString());
+        }
+
+        return result.toString();
+    };
+
+}

Added: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/MyRightsResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/MyRightsResponse.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/MyRightsResponse.java (added)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/MyRightsResponse.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.message.response;
+
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.message.response.ImapResponseMessage;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+
+/**
+ * MYRIGHTS Response.
+ * 
+ * @author Peter Palaga
+ */
+public final class MyRightsResponse implements ImapResponseMessage {
+    private final String mailboxName;
+    private final MailboxACLRights myRights;
+
+    public MyRightsResponse(String mailboxName, MailboxACLRights myRights) {
+        super();
+        this.mailboxName = mailboxName;
+        this.myRights = myRights;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (o instanceof MyRightsResponse) {
+            MyRightsResponse other = (MyRightsResponse) o;
+            return (this.myRights == other.myRights || (this.myRights != null && this.myRights.equals(other.myRights)))
+                    && (this.mailboxName == other.mailboxName || (this.mailboxName != null && this.mailboxName.equals(other.mailboxName)))
+                    ;
+        }
+        return false;
+    }
+
+    public String getMailboxName() {
+        return mailboxName;
+    }
+
+    public MailboxACLRights getMyRights() {
+        return myRights;
+    }
+
+    @Override
+    public int hashCode() {
+        final int PRIME = 31;
+        return PRIME * myRights.hashCode() + mailboxName.hashCode();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder result = new StringBuilder()
+        .append(ImapConstants.ACL_RESPONSE_NAME)
+        .append(' ')
+        .append(mailboxName)
+        .append(' ')
+        .append(myRights.toString());
+        
+        return result.toString();
+    };
+
+}

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java?rev=1292019&r1=1292018&r2=1292019&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java (original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DefaultProcessorChain.java Tue Feb 21 21:05:02 2012
@@ -86,8 +86,12 @@ public class DefaultProcessorChain {
         final CompressProcessor compressProcessor = new CompressProcessor(unselectProcessor, statusResponseFactory);
         
         final GetACLProcessor getACLProcessor = new GetACLProcessor(compressProcessor, mailboxManager, statusResponseFactory);
+        final SetACLProcessor setACLProcessor = new SetACLProcessor(getACLProcessor, mailboxManager, statusResponseFactory);
+        final DeleteACLProcessor deleteACLProcessor = new DeleteACLProcessor(setACLProcessor, mailboxManager, statusResponseFactory);
+        final ListRightsProcessor listRightsProcessor = new ListRightsProcessor(deleteACLProcessor, mailboxManager, statusResponseFactory);
+        final MyRightsProcessor myRightsProcessor = new MyRightsProcessor(listRightsProcessor, mailboxManager, statusResponseFactory);
         
-        final EnableProcessor enableProcessor = new EnableProcessor(getACLProcessor, mailboxManager, statusResponseFactory);
+        final EnableProcessor enableProcessor = new EnableProcessor(myRightsProcessor, mailboxManager, statusResponseFactory);
         
         // add for QRESYNC
         enableProcessor.addProcessor(selectProcessor);

Added: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java (added)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,143 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.processor;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.message.request.DeleteACLRequest;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.exception.UnsupportedRightException;
+import org.apache.james.mailbox.model.MailboxACL.EditMode;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
+import org.slf4j.Logger;
+
+/**
+ * DELETEACL Processor.
+ * 
+ * @author Peter Palaga
+ */
+public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLRequest> implements CapabilityImplementingProcessor {
+
+    private static final List<String> CAPABILITIES = Collections.singletonList(ImapConstants.SUPPORTS_ACL);
+
+    public DeleteACLProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+        super(DeleteACLRequest.class, next, mailboxManager, factory);
+    }
+
+    @Override
+    protected void doProcess(DeleteACLRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {
+
+        final MailboxManager mailboxManager = getMailboxManager();
+        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final String mailboxName = message.getMailboxName();
+        final String identifier = message.getIdentifier();
+        try {
+            
+            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+
+            /*
+             * RFC 4314 section 6.
+             * An implementation MUST make sure the ACL commands themselves do
+             * not give information about mailboxes with appropriately
+             * restricted ACLs. For example, when a user agent executes a GETACL
+             * command on a mailbox that the user has no permission to LIST, the
+             * server would respond to that request with the same error that
+             * would be used if the mailbox did not exist, thus revealing no
+             * existence information, much less the mailbox’s ACL.
+             */
+            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+                no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+            }
+            /* RFC 4314 section 4. */
+            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+                Object[] params = new Object[] {
+                        Rfc4314Rights.a_Administer_RIGHT.toString(),
+                        command.getName(),
+                        mailboxName
+                };
+                HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params);
+                no(command, tag, responder, text);
+            }
+            else {
+                
+                MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier);
+                
+                // FIXME check if identifier is a valid user or group
+                // FIXME Servers, when processing a command that has an identifier as a
+                // parameter (i.e., any of SETACL, DELETEACL, and LISTRIGHTS commands),
+                // SHOULD first prepare the received identifier using "SASLprep" profile
+                // [SASLprep] of the "stringprep" algorithm [Stringprep].  If the
+                // preparation of the identifier fails or results in an empty string,
+                // the server MUST refuse to perform the command with a BAD response.
+                // Note that Section 6 recommends additional identifier’s verification
+                // steps.
+                
+                messageManager.setRights(key, EditMode.REPLACE, null);
+                okComplete(command, tag, responder);
+                // FIXME should we send unsolicited responses here?
+                // unsolicitedResponses(session, responder, false);
+            }
+        } catch (UnsupportedRightException e) {
+            /*
+             * RFc 4314, section 3.1
+             * Note that an unrecognized right MUST cause the command to return the
+             * BAD response.  In particular, the server MUST NOT silently ignore
+             * unrecognized rights.
+             * */
+            Object[] params = new Object[] {e.getUnsupportedRight()};
+            HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params);
+            taggedBad(command, tag, responder, text);
+        } catch (MailboxNotFoundException e) {
+            no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+        } catch (MailboxException e) {
+            Logger log = session.getLog();
+            if (log.isInfoEnabled()) {
+                log.info(command.getName() +" failed for mailbox " + mailboxName, e);
+            }
+            no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.imap.processor.CapabilityImplementingProcessor#
+     * getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
+     */
+    public List<String> getImplementedCapabilities(ImapSession session) {
+        return CAPABILITIES;
+    }
+
+}

Added: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java (added)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,135 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.processor;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.message.request.ListRightsRequest;
+import org.apache.james.imap.message.response.ListRightsResponse;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
+import org.slf4j.Logger;
+
+/**
+ * LISTRIGHTS Processor.
+ * 
+ * @author Peter Palaga
+ */
+public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequest> implements CapabilityImplementingProcessor {
+
+    private static final List<String> CAPABILITIES = Collections.singletonList(ImapConstants.SUPPORTS_ACL);
+
+    public ListRightsProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+        super(ListRightsRequest.class, next, mailboxManager, factory);
+    }
+
+    @Override
+    protected void doProcess(ListRightsRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {
+
+        final MailboxManager mailboxManager = getMailboxManager();
+        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final String mailboxName = message.getMailboxName();
+        final String identifier = message.getIdentifier();
+        try {
+
+            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+
+            /*
+             * RFC 4314 section 6.
+             * An implementation MUST make sure the ACL commands themselves do
+             * not give information about mailboxes with appropriately
+             * restricted ACLs. For example, when a user agent executes a GETACL
+             * command on a mailbox that the user has no permission to LIST, the
+             * server would respond to that request with the same error that
+             * would be used if the mailbox did not exist, thus revealing no
+             * existence information, much less the mailbox’s ACL.
+             */
+            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+                no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+            }
+            /* RFC 4314 section 4. */
+            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+                Object[] params = new Object[] {
+                        Rfc4314Rights.a_Administer_RIGHT.toString(),
+                        command.getName(),
+                        mailboxName
+                };
+                HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params);
+                no(command, tag, responder, text);
+            }
+            else {
+                
+                MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier);
+                
+                // FIXME check if identifier is a valid user or group
+                // FIXME Servers, when processing a command that has an identifier as a
+                // parameter (i.e., any of SETACL, DELETEACL, and LISTRIGHTS commands),
+                // SHOULD first prepare the received identifier using "SASLprep" profile
+                // [SASLprep] of the "stringprep" algorithm [Stringprep].  If the
+                // preparation of the identifier fails or results in an empty string,
+                // the server MUST refuse to perform the command with a BAD response.
+                // Note that Section 6 recommends additional identifier’s verification
+                // steps.
+                
+                MailboxACLRights[] rights = messageManager.listRigths(key, mailboxSession);
+                ListRightsResponse aclResponse = new ListRightsResponse(mailboxName, identifier, rights);
+                responder.respond(aclResponse);
+                okComplete(command, tag, responder);
+                // FIXME should we send unsolicited responses here?
+                // unsolicitedResponses(session, responder, false);
+            }
+        } catch (MailboxNotFoundException e) {
+            no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+        } catch (MailboxException e) {
+            Logger log = session.getLog();
+            if (log.isInfoEnabled()) {
+                log.info(command.getName() +" failed for mailbox " + mailboxName, e);
+            }
+            no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.imap.processor.CapabilityImplementingProcessor#
+     * getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
+     */
+    public List<String> getImplementedCapabilities(ImapSession session) {
+        return CAPABILITIES;
+    }
+
+}

Added: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java (added)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,114 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.processor;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.message.request.MyRightsRequest;
+import org.apache.james.imap.message.response.MyRightsResponse;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
+import org.slf4j.Logger;
+
+/**
+ * MYRIGHTS Processor.
+ * 
+ * @author Peter Palaga
+ */
+public class MyRightsProcessor extends AbstractMailboxProcessor<MyRightsRequest> implements CapabilityImplementingProcessor {
+
+    private static final List<String> CAPABILITIES = Collections.singletonList(ImapConstants.SUPPORTS_ACL);
+
+    public MyRightsProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+        super(MyRightsRequest.class, next, mailboxManager, factory);
+    }
+
+    @Override
+    protected void doProcess(MyRightsRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {
+
+        final MailboxManager mailboxManager = getMailboxManager();
+        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final String mailboxName = message.getMailboxName();
+        try {
+
+            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+            MailboxACLRights myRights = messageManager.myRights(mailboxSession);
+
+            /*
+             * RFC 4314 section 6. An implementation MUST make sure the ACL
+             * commands themselves do not give information about mailboxes with
+             * appropriately restricted ACLs. For example, when a user agent
+             * executes a GETACL command on a mailbox that the user has no
+             * permission to LIST, the server would respond to that request with
+             * the same error that would be used if the mailbox did not exist,
+             * thus revealing no existence information, much less the mailbox’s
+             * ACL.
+             * 
+             * RFC 4314 section 4. * MYRIGHTS - any of the following rights is
+             * required to perform the operation: "l", "r", "i", "k", "x", "a".
+             */
+            if (!myRights.contains(Rfc4314Rights.l_Lookup_RIGHT)
+                    && !myRights.contains(Rfc4314Rights.r_Read_RIGHT)
+                    && !myRights.contains(Rfc4314Rights.i_Insert_RIGHT)
+                    && !myRights.contains(Rfc4314Rights.k_CreateMailbox_RIGHT)
+                    && !myRights.contains(Rfc4314Rights.x_DeleteMailbox_RIGHT)
+                    && !myRights.contains(Rfc4314Rights.a_Administer_RIGHT)) {
+                no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+            } else {
+                MyRightsResponse myRightsResponse = new MyRightsResponse(mailboxName, myRights);
+                responder.respond(myRightsResponse);
+                okComplete(command, tag, responder);
+                // FIXME should we send unsolicited responses here?
+                // unsolicitedResponses(session, responder, false);
+            }
+        } catch (MailboxNotFoundException e) {
+            no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+        } catch (MailboxException e) {
+            Logger log = session.getLog();
+            if (log.isInfoEnabled()) {
+                log.info(command.getName() + " failed for mailbox " + mailboxName, e);
+            }
+            no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+        }
+
+    }
+
+    /**
+     * @see org.apache.james.imap.processor.CapabilityImplementingProcessor#
+     * getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
+     */
+    public List<String> getImplementedCapabilities(ImapSession session) {
+        return CAPABILITIES;
+    }
+
+}

Added: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java?rev=1292019&view=auto
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java (added)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java Tue Feb 21 21:05:02 2012
@@ -0,0 +1,162 @@
+/****************************************************************
+ * 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.                                           *
+ ****************************************************************/
+
+package org.apache.james.imap.processor;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.imap.api.ImapCommand;
+import org.apache.james.imap.api.ImapConstants;
+import org.apache.james.imap.api.ImapSessionUtils;
+import org.apache.james.imap.api.display.HumanReadableText;
+import org.apache.james.imap.api.message.response.StatusResponseFactory;
+import org.apache.james.imap.api.process.ImapProcessor;
+import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.message.request.SetACLRequest;
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.exception.UnsupportedRightException;
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxACL.EditMode;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
+import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
+import org.slf4j.Logger;
+
+/**
+ * SETACL Processor.
+ * 
+ * @author Peter Palaga
+ */
+public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> implements CapabilityImplementingProcessor {
+
+    private static final List<String> CAPABILITIES = Collections.singletonList(ImapConstants.SUPPORTS_ACL);
+
+    public SetACLProcessor(ImapProcessor next, MailboxManager mailboxManager, StatusResponseFactory factory) {
+        super(SetACLRequest.class, next, mailboxManager, factory);
+    }
+
+    @Override
+    protected void doProcess(SetACLRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) {
+
+        final MailboxManager mailboxManager = getMailboxManager();
+        final MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session);
+        final String mailboxName = message.getMailboxName();
+        final String identifier = message.getIdentifier();
+        try {
+            
+            /* parsing the rights is the the cheapest thing to begin with */
+            EditMode editMode = MailboxACL.EditMode.REPLACE;
+            String rights = message.getRights();
+            if (rights != null && rights.length() > 0) {
+                switch (rights.charAt(0)) {
+                case MailboxACL.ADD_RIGHTS_MARKER:
+                    editMode = MailboxACL.EditMode.ADD;
+                    rights = rights.substring(1);
+                    break;
+                case MailboxACL.REMOVE_RIGHTS_MARKER:
+                    editMode = MailboxACL.EditMode.REMOVE;
+                    rights = rights.substring(1);
+                    break;
+                }
+            }
+            MailboxACLRights mailboxAclRights = new Rfc4314Rights(rights);
+
+            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+
+            /*
+             * RFC 4314 section 6.
+             * An implementation MUST make sure the ACL commands themselves do
+             * not give information about mailboxes with appropriately
+             * restricted ACLs. For example, when a user agent executes a GETACL
+             * command on a mailbox that the user has no permission to LIST, the
+             * server would respond to that request with the same error that
+             * would be used if the mailbox did not exist, thus revealing no
+             * existence information, much less the mailbox’s ACL.
+             */
+            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+                no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+            }
+            /* RFC 4314 section 4. */
+            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+                Object[] params = new Object[] {
+                        Rfc4314Rights.a_Administer_RIGHT.toString(),
+                        command.getName(),
+                        mailboxName
+                };
+                HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUFFICIENT_RIGHTS_KEY, HumanReadableText.UNSUFFICIENT_RIGHTS_DEFAULT_VALUE, params);
+                no(command, tag, responder, text);
+            }
+            else {
+                
+                MailboxACLEntryKey key = new SimpleMailboxACLEntryKey(identifier);
+                
+                // FIXME check if identifier is a valid user or group
+                // FIXME Servers, when processing a command that has an identifier as a
+                // parameter (i.e., any of SETACL, DELETEACL, and LISTRIGHTS commands),
+                // SHOULD first prepare the received identifier using "SASLprep" profile
+                // [SASLprep] of the "stringprep" algorithm [Stringprep].  If the
+                // preparation of the identifier fails or results in an empty string,
+                // the server MUST refuse to perform the command with a BAD response.
+                // Note that Section 6 recommends additional identifier’s verification
+                // steps.
+                
+                messageManager.setRights(key, editMode, mailboxAclRights);
+                okComplete(command, tag, responder);
+                // FIXME should we send unsolicited responses here?
+                // unsolicitedResponses(session, responder, false);
+            }
+        } catch (UnsupportedRightException e) {
+            /*
+             * RFc 4314, section 3.1
+             * Note that an unrecognized right MUST cause the command to return the
+             * BAD response.  In particular, the server MUST NOT silently ignore
+             * unrecognized rights.
+             * */
+            Object[] params = new Object[] {e.getUnsupportedRight()};
+            HumanReadableText text = new HumanReadableText(HumanReadableText.UNSUPPORTED_RIGHT_KEY, HumanReadableText.UNSUPPORTED_RIGHT_DEFAULT_VALUE, params);
+            taggedBad(command, tag, responder, text);
+        } catch (MailboxNotFoundException e) {
+            no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
+        } catch (MailboxException e) {
+            Logger log = session.getLog();
+            if (log.isInfoEnabled()) {
+                log.info(command.getName() +" failed for mailbox " + mailboxName, e);
+            }
+            no(command, tag, responder, HumanReadableText.GENERIC_FAILURE_DURING_PROCESSING);
+        }
+
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.james.imap.processor.CapabilityImplementingProcessor#
+     * getImplementedCapabilities(org.apache.james.imap.api.process.ImapSession)
+     */
+    public List<String> getImplementedCapabilities(ImapSession session) {
+        return CAPABILITIES;
+    }
+
+}



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