1 17 18 package org.apache.james.imapserver.commands; 19 20 import org.apache.james.imapserver.AccessControlException; 21 import org.apache.james.imapserver.AuthorizationException; 22 import org.apache.james.util.Assert; 23 import org.apache.james.imapserver.ACLMailbox; 24 import org.apache.james.imapserver.ImapRequest; 25 import org.apache.james.imapserver.ImapSession; 26 import org.apache.james.imapserver.ImapSessionState; 27 28 import java.util.StringTokenizer ; 29 import java.util.List ; 30 31 abstract class AbstractAclCommand extends AuthenticatedSelectedStateCommand 32 { 33 protected abstract boolean checkUsage( int arguments, ImapSession session ); 34 35 protected abstract void doAclCommand( ImapRequest request, ImapSession session, 36 ACLMailbox target, String folder ) 37 throws AccessControlException, AuthorizationException; 38 39 protected boolean doProcess( ImapRequest request, ImapSession session, List argValues ) 40 { 41 Assert.fail(); 42 return false; 43 } 44 45 public boolean process( ImapRequest request, ImapSession session ) 46 { 47 int arguments = request.arguments(); 48 StringTokenizer commandLine = request.getCommandLine(); 49 String command = request.getCommand(); 50 51 String folder; 52 ACLMailbox target = null; 53 54 checkUsage( arguments, session ); 55 56 folder = readAstring( commandLine ); 57 58 target = getMailbox( session, folder, command ); 59 if ( target == null ) return true; 60 61 try { 62 doAclCommand( request, session, target, folder ); 63 } 64 catch ( AccessControlException ace ) { 65 session.noResponse( command, "Unknown mailbox" ); 66 session.logACE( ace ); 67 return true; 68 } 69 catch ( AuthorizationException aze ) { 70 session.taggedResponse( AUTH_FAIL_MSG ); 71 session.logAZE( aze ); 72 return true; 73 } 74 if ( session.getState() == ImapSessionState.SELECTED ) { 75 session.checkSize(); 76 session.checkExpunge(); 77 } 78 return true; 79 } 80 } 81 | Popular Tags |