Package org.apache.james.protocols.api

Examples of org.apache.james.protocols.api.Response


    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
        Channel channel = ctx.getChannel();
        ProtocolSession session = (ProtocolSession) ctx.getAttachment();
        if (e.getCause() instanceof TooLongFrameException && session != null) {
            Response r = session.newLineTooLongResponse();
            ProtocolTransport transport = ((ProtocolSessionImpl)session).getProtocolTransport();
            if (r != null)  {
                transport.writeResponse(r, session);
            }
        } else {
            if (channel.isConnected() && session != null) {
                ProtocolTransport transport = ((ProtocolSessionImpl)session).getProtocolTransport();

                Response r = session.newFatalErrorResponse();
                if (r != null) {
                    transport.writeResponse(r, session);
                }
                transport.writeResponse(Response.DISCONNECT, session);
            }
View Full Code Here


            Iterator<CommandHandler<Session>> handlers = commandHandlers.iterator();
           
            while (handlers.hasNext()) {
                final long start = System.currentTimeMillis();
                CommandHandler<Session> cHandler = handlers.next();
                Response response = cHandler.onCommand(session, request);
                if (response != null) {
                    long executionTime = System.currentTimeMillis() - start;

                    // now process the result handlers
                    for (int a = 0; a < rHandlers.size(); a++) {
View Full Code Here

     * process DATA command
     *
     */
    public Response onCommand(SMTPSession session, Request request) {
        String parameters = request.getArgument();
        Response response = doDATAFilter(session,parameters);
       
        if (response == null) {
            return doDATA(session, parameters);
        } else {
            return response;
View Full Code Here

            // copy the ChannelBuffer to a byte array to process the LineHandler
            line = new byte[buf.readableBytes()];
            buf.getBytes(0, line);
        }

        Response response = handler.onLine(session, line);
        if (response != null) {
            // TODO: This kind of sucks but I was able to come up with something more elegant here
            ((ProtocolSessionImpl)session).getProtocolTransport().writeResponse(response, session);
        }
    }
View Full Code Here

        catch (Exception e) {
            // Ignored - this exception in parsing will be dealt
            // with in the if clause below
        }
        // Authenticate user
        Response response = doAuthTest(session, user, pass, "PLAIN");
       
        session.popLineHandler();

        return response;
    }
View Full Code Here

      
        session.popLineHandler();

       
        // Authenticate user
        Response response = doAuthTest(session, user, pass, "LOGIN");
      
        return response;
    }
View Full Code Here

    protected Response doAuthTest(SMTPSession session, String user, String pass, String authType) {
        if ((user == null) || (pass == null)) {
            return new SMTPResponse(SMTPRetCode.SYNTAX_ERROR_ARGUMENTS,"Could not decode parameters for AUTH "+authType);
        }

        Response res = null;
       
        List<AuthHook> hooks = getHooks();
       
        if (hooks != null) {
            int count = hooks.size();
            for (int i = 0; i < count; i++) {
                AuthHook rawHook = hooks.get(i);
                session.getLogger().debug("executing  hook " + rawHook);
               

                long start = System.currentTimeMillis();
                HookResult hRes = rawHook.doAuth(session, user, pass);
                long executionTime = System.currentTimeMillis() - start;

                if (rHooks != null) {
                    for (int i2 = 0; i2 < rHooks.size(); i2++) {
                        Object rHook = rHooks.get(i2);
                        session.getLogger().debug("executing  hook " + rHook);
                   
                        hRes = ((HookResultHook) rHook).onHookResult(session, hRes, executionTime, rawHook);
                    }
                }
               
                res = calcDefaultSMTPResponse(hRes);
               
                if (res != null) {
                    if (SMTPRetCode.AUTH_FAILED.equals(res.getRetCode())) {
                        session.getLogger().info("AUTH method "+authType+" failed");
                    } else if (SMTPRetCode.AUTH_OK.equals(res.getRetCode())) {
                        if (session.getLogger().isDebugEnabled()) {
                            // TODO: Make this string a more useful debug message
                            session.getLogger().debug("AUTH method "+authType+" succeeded");
                        }
                    }
View Full Code Here

            // Stream terminated
            if (line.length == 3 && line[0] == 46) {
                out.flush();
                out.close();
               
                Response response = processExtensions(session, env);
                session.popLineHandler();
                session.resetState();
                return response;
               
            // DotStuffing.
View Full Code Here

     * #onCommand(org.apache.james.protocols.api.ProtocolSession, Request)
     */
    public Response onCommand(SMTPSession session, Request request) {
        String command = request.getCommand();
        String parameters = request.getArgument();
        Response response = doFilterChecks(session, command, parameters);

        if (response == null) {

            response = processHooks(session, command, parameters);
            if (response == null) {
View Full Code Here

                    }
                }
               
                // call the core cmd if we receive a ok return code of the hook so no other hooks are executed
                if ((hRes.getResult() & HookReturnCode.OK) == HookReturnCode.OK) {
                    final Response response = doCoreCmd(session, command, parameters);
                    if ((hRes.getResult() & HookReturnCode.DISCONNECT) == HookReturnCode.DISCONNECT) {
                        return new Response() {
                           
                            /*
                             * (non-Javadoc)
                             * @see org.apache.james.protocols.api.Response#isEndSession()
                             */
                            public boolean isEndSession() {
                                return true;
                            }
                           
                            /*
                             * (non-Javadoc)
                             * @see org.apache.james.protocols.api.Response#getRetCode()
                             */
                            public String getRetCode() {
                                return response.getRetCode();
                            }
                           
                            /*
                             * (non-Javadoc)
                             * @see org.apache.james.protocols.api.Response#getLines()
                             */
                            public List<CharSequence> getLines() {
                                return response.getLines();
                            }
                        };
                    }
                    return response;
                } else {
View Full Code Here

TOP

Related Classes of org.apache.james.protocols.api.Response

Copyright © 2018 www.massapicom. 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.