Examples of ImapSession


Examples of org.apache.james.imap.api.process.ImapSession

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
        logger.debug("Error while processing imap request" ,e.getCause());
       
        // logout on error not sure if that is the best way to handle it
        final ImapSession imapSession = (ImapSessionImpl) getAttachment(ctx).get(IMAP_SESSION);    
        if (imapSession != null) imapSession.logout();

        // just close the channel now!
        ctx.getChannel().close();
       
        super.exceptionCaught(ctx, e);
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

        return new Slf4jLoggerAdapter(new ProtocolSessionLogger("" + channel.getId(), new ProtocolLoggerAdapter(logger)));
    }

    @Override
    public void channelBound(final ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
        ImapSession imapsession = new NettyImapSession(ctx.getChannel(), logger, context, enabledCipherSuites, compress, plainAuthDisallowed);
        attributes.set(ctx.getChannel(), imapsession);
        super.channelBound(ctx, e);
    }
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

        InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();
        getLogger(ctx.getChannel()).info("Connection closed for " + address.getAddress().getHostAddress());

        // remove the stored attribute for the channel to free up resources
        // See JAMES-1195
        ImapSession imapSession = (ImapSession) attributes.remove(ctx.getChannel());
        if (imapSession != null)
            imapSession.logout();

        super.channelClosed(ctx, e);
    }
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

            composer.untaggedResponse(ImapConstants.BAD + " failed. Maximum command line length exceeded");
           
        } else {

            // logout on error not sure if that is the best way to handle it
            final ImapSession imapSession = (ImapSession) attributes.get(ctx.getChannel());
            if (imapSession != null)
                imapSession.logout();

            // Make sure we close the channel after all the buffers were flushed out
            Channel channel = ctx.getChannel();
            if (channel.isConnected()) {
                channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

    }

    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
       
        ImapSession session = (ImapSession) attributes.get(ctx.getChannel());
        ImapResponseComposer response = (ImapResponseComposer) ctx.getAttachment();
        ImapMessage message = (ImapMessage) e.getMessage();
        ChannelPipeline cp = ctx.getPipeline();

        try {
            if (cp.get(NettyConstants.EXECUTION_HANDLER) != null) {
                cp.addBefore(NettyConstants.EXECUTION_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);
            } else {
                cp.addBefore(NettyConstants.CORE_HANDLER, NettyConstants.HEARTBEAT_HANDLER, heartbeatHandler);

            }
            final ResponseEncoder responseEncoder = new ResponseEncoder(encoder, response, session);
            processor.process(message, responseEncoder, session);

            if (session.getState() == ImapSessionState.LOGOUT) {
                // Make sure we close the channel after all the buffers were flushed out
                Channel channel = ctx.getChannel();
                if (channel.isConnected()) {
                    channel.write(ChannelBuffers.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
                }
            }
            final IOException failure = responseEncoder.getFailure();

            if (failure != null) {
                final Logger logger = session.getLog();
                logger.info(failure.getMessage());
                if (logger.isDebugEnabled()) {
                    logger.debug("Failed to write " + message, failure);
                }
                throw failure;
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

            }
        } else {
            reader = new NettyImapRequestLineReader(channel, buffer, retry, literalSizeLimit);
        }

        ImapSession session = (ImapSession) attributes.get(channel);

        // check if the session was removed before to prevent a harmless NPE. See JAMES-1312
        // Also check if the session was logged out if so there is not need to try to decode it. See JAMES-1341
        if (session != null && session.getState() != ImapSessionState.LOGOUT) {
            try {

                ImapMessage message = decoder.decode(reader, session);

                // if size is != -1 the case was a literal. if thats the case we
View Full Code Here

Examples of org.apache.james.imap.api.process.ImapSession

    @Override
    public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) throws Exception {

        // check if the client did nothing for too long
        if (e.getState().equals(IdleState.ALL_IDLE)) {
            ImapSession session = (ImapSession) attributes.get(ctx.getChannel());
            InetSocketAddress address = (InetSocketAddress) ctx.getChannel().getRemoteAddress();

            session.getLog().info("Logout client " + address.getHostName() + " (" + address.getAddress().getHostAddress() + ") because it idled for too long...");

            // logout the client
            session.logout();

            // close the channel
            ctx.getChannel().close();

        }
View Full Code Here

Examples of org.apache.james.imapserver.ImapSession

        ByteArrayOutputStream serverResponseCollector = new ByteArrayOutputStream();
        serverResponseCollector.write( "* OK IMAP4rev1 Server XXX ready".getBytes() );
        serverResponseCollector.write( '\r' );
        serverResponseCollector.write( '\n' );

        ImapSession session = getImapSession();
        ImapRequestHandler requestHandler = new ImapRequestHandler();
        while( requestHandler.handleRequest( clientIn, serverResponseCollector, session ) ) {};

        InputStream serverInstream = new ByteArrayInputStream( serverResponseCollector.toByteArray() );
        BufferedReader serverIn = new BufferedReader( new InputStreamReader( serverInstream ) );
View Full Code Here

Examples of org.apache.james.imapserver.ImapSession

     * Provides an ImapSession to use for this test. An ImapSession is accosiated
     * with a single client connection.
     */
    private ImapSession getImapSession() throws MailboxException
    {
        ImapSession session = new ImapSessionImpl( imapHost, users, new ImapHandler(), null, null );
        return session;
    }
View Full Code Here

Examples of org.apache.james.imapserver.ImapSession

        ByteArrayOutputStream serverResponseCollector = new ByteArrayOutputStream();
        serverResponseCollector.write( "* OK IMAP4rev1 Server XXX ready".getBytes() );
        serverResponseCollector.write( '\r' );
        serverResponseCollector.write( '\n' );

        ImapSession session = getImapSession();
        ImapRequestHandler requestHandler = new ImapRequestHandler();
        while( requestHandler.handleRequest( clientIn, serverResponseCollector, session ) ) {};

        InputStream serverInstream = new ByteArrayInputStream( serverResponseCollector.toByteArray() );
        BufferedReader serverIn = new BufferedReader( new InputStreamReader( serverInstream ) );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.