⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singlethreadedconnectionhandler.java

📁 java 开发的邮件服务器平台。支持以下协议。 协议可以修改为自己的专门标识
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        // Start with commands that are valid in any state        // CAPABILITY, NOOP, LOGOUT                // Commands only valid in NON_AUTHENTICATED state        // AUTHENTICATE, LOGIN        // Commands valid in both Authenticated and Selected states        // NAMESPACE, GETACL, SETACL, DELETEACL, LISTRIGHTS, MYRIGHTS, SELECT                // Commands valid only in Authenticated State        // None        // Commands valid only in Selected state        // CHECK CLOSE COPY EXPUNGE FETCH STORE UID                ImapCommand cmd = getImapCommand( command );                if ( ! cmd.validForState( state ) ) {            badResponse( command + " not valid in this state" );            return true;        }        return cmd.process( request, this );    }    public ImapCommand getImapCommand( String command )    {        return _imapCommands.getCommand( command );    }    private void invalidStateResponse( String command )    {        badResponse( command + " not valid in this state" );    }    public void okResponse( String command )    {        taggedResponse( OK + SP + command + " completed" );    }    public void noResponse( String command )    {        noResponse( command, "failed" );    }    public void noResponse( String command, String msg )    {        taggedResponse( NO + SP + command + SP + msg );    }    public void badResponse( String badMsg )    {        taggedResponse( BAD + SP + badMsg );    }    public void notImplementedResponse( String command )    {        badResponse( command + " not implemented." );    }    public void taggedResponse( String msg )    {        _session.getOut().println( tag + SP + msg );    }    public void untaggedResponse( String msg )    {        _session.getOut().println( UNTAGGED + SP + msg );    }    public void dispose()    {        // todo        getLogger().error( "Stop IMAPHandler" );    }    public void receiveEvent( MailboxEvent me )    {        if ( _session.getState() == ImapSessionState.SELECTED ) {            checkMailboxFlag = true;        }    }//    public ACLMailbox getBox( String user, String mailboxName ) throws MailboxException, AccessControlException//    {//        return//        ACLMailbox tempMailbox = null;//        try {//            tempMailbox = getImapHost().getMailbox( user, mailboxName );//        }//        catch ( MailboxException me ) {//            if ( me.isRemote() ) {//                _session.getOut().println( tag + SP + NO + SP + "[REFERRAL " + me.getRemoteServer() + "]" + SP + "Remote mailbox" );//            }//            else {//                _session.noResponse(//                _session.getOut().println( tag + SP + NO + SP + "Unknown mailbox" );//                getLogger().info( "MailboxException in method getBox for user: "//                                  + user + " mailboxName: " + mailboxName + " was "//                                  + me.getMessage() );//            }////        }//        catch ( AccessControlException e ) {//            _session.getOut().println( tag + SP + NO + SP + "Unknown mailbox" );//        }//        return tempMailbox;//    }    public void logACE( AccessControlException ace )    {        getSecurityLogger().error( "AccessControlException by user " + _session.getCurrentUser()                                   + " from " + getRemoteHost() + "(" + getRemoteIP()                                   + ") with " + commandRaw + " was "                                   + ace.getMessage() );    }    public void logAZE( AuthorizationException aze )    {        getSecurityLogger().error( "AuthorizationException by user " + _session.getCurrentUser()                                   + " from " + getRemoteHost() + "(" + getRemoteIP()                                   + ") with " + commandRaw + " was "                                   + aze.getMessage() );    }    public PrintWriter getPrintWriter()    {        return _session.getOut();    }    public OutputStream getOutputStream()    {        return outs;    }    public String getUser()    {        return _session.getCurrentUser();    }    public void checkSize()    {        int newExists = getCurrentMailbox().getExists();        if ( newExists != exists ) {            _session.getOut().println( UNTAGGED + SP + newExists + " EXISTS" );            exists = newExists;        }        int newRecent = getCurrentMailbox().getRecent();        if ( newRecent != recent ) {            _session.getOut().println( UNTAGGED + SP + newRecent + " RECENT" );            recent = newRecent;        }        return;    }    public void checkExpunge()    {        List newList = getCurrentMailbox().listUIDs( _session.getCurrentUser() );        for ( int k = 0; k < newList.size(); k++ ) {            getLogger().debug( "New List msn " + (k + 1) + " is uid " + newList.get( k ) );        }        for ( int i = sequence.size() - 1; i > -1; i-- ) {            Integer j = (Integer) sequence.get( i );            getLogger().debug( "Looking for old msn " + (i + 1) + " was uid " + j );            if ( !newList.contains( (Integer) sequence.get( i ) ) ) {                _session.getOut().println( UNTAGGED + SP + (i + 1) + " EXPUNGE" );            }        }        sequence = newList;        //newList = null;        return;    }    public ImapSessionState getState()    {        return state;    }    public void setState( ImapSessionState state )    {        this.state = state;        exists = -1;        recent = -1;    }    public BufferedReader getIn()    {        return in;    }    public void setIn( BufferedReader in )    {        this.in = in;    }    public PrintWriter getOut()    {        return out;    }    public void setOut( PrintWriter out )    {        this.out = out;    }    public String getRemoteHost()    {        return remoteHost;    }    public String getRemoteIP()    {        return remoteIP;    }    public Logger getDebugLogger()    {        return getLogger();    }    public Logger getSecurityLogger()    {        return securityLogger;    }    public UsersRepository getUsers()    {        return users;    }    public IMAPSystem getImapSystem()    {        return imapSystem;    }    public Host getImapHost()    {        return imapHost;    }    public String getCurrentNamespace()    {        return currentNamespace;    }    public void setCurrentNamespace( String currentNamespace )    {        this.currentNamespace = currentNamespace;    }    public String getCurrentSeperator()    {        return currentSeperator;    }    public void setCurrentSeperator( String currentSeperator )    {        this.currentSeperator = currentSeperator;    }    public String getCurrentFolder()    {        return currentFolder;    }    public void setCurrentFolder( String currentFolder )    {        this.currentFolder = currentFolder;    }    public ACLMailbox getCurrentMailbox()    {        return currentMailbox;    }    public void setCurrentMailbox( ACLMailbox currentMailbox )    {        this.currentMailbox = currentMailbox;    }    public boolean isCurrentIsReadOnly()    {        return currentIsReadOnly;    }    public void setCurrentIsReadOnly( boolean currentIsReadOnly )    {        this.currentIsReadOnly = currentIsReadOnly;    }    public boolean isConnectionClosed()    {        return connectionClosed;    }    public void setConnectionClosed( boolean connectionClosed )    {        this.connectionClosed = connectionClosed;    }    public String getCurrentUser()    {        return user;    }    public void setCurrentUser( String user )    {        this.user = user;    }    public void setSequence( List sequence )    {        this.sequence = sequence;    }    public List decodeSet( String rawSet, int exists ) throws IllegalArgumentException    {        return super.decodeSet( rawSet, exists );    }        public void setCanParseCommand(boolean canParseCommand) {        this.canParseCommand = canParseCommand;    }    public boolean getCanParseCommand() {        return this.canParseCommand;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -