Package org.apache.james.protocols.api

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


    public final Response onLine(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) {
        if (session.getAttachment(HEADERS_COMPLETE, State.Transaction) == null) {
            if (line.remaining() == 2 ) {
                if (line.get() == '\r' && line.get() == '\n') {
                    line.rewind();
                    Response response = onSeparatorLine(session, line, next);
                    session.setAttachment(HEADERS_COMPLETE, Boolean.TRUE, State.Transaction);
                    return response;
                }
                line.rewind();
            }
View Full Code Here


     * @param line
     * @param next
     * @return response
     */
    private Response addHeaders(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) {
        Response response;
        for (Header header: headers(session)) {
            response = header.transferTo(session, next);
            if (response != null) {
                return response;
            }
View Full Code Here

    /**
     * @see org.apache.james.protocols.smtp.core.DataLineFilter#onLine(SMTPSession, byte[], LineHandler)
     */
    public Response onLine(SMTPSession session, ByteBuffer line, LineHandler<SMTPSession> next) {
        Response response = null;
      Boolean failed = (Boolean) session.getAttachment(MESG_FAILED, State.Transaction);
        // If we already defined we failed and sent a reply we should simply
        // wait for a CRLF.CRLF to be sent by the client.
        if (failed != null && failed.booleanValue()) {
            // TODO
View Full Code Here

         */
        public Response transferTo(SMTPSession session, LineHandler<SMTPSession> handler) {
            String charset = session.getCharset().name();

            try {
                Response response = null;
                for (int i = 0; i < values.size(); i++) {
                    String line;
                    if (i == 0) {
                        line = name + ": " + values.get(i);
                    } else {
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

     * 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

      
        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

         * (non-Javadoc)
         * @see org.apache.james.protocols.api.handler.LineHandler#onLine(org.apache.james.protocols.api.ProtocolSession, java.nio.ByteBuffer)
         */
        public Response onLine(SMTPSession session, ByteBuffer line) {
            line.rewind();
            Response r = filter.onLine(session, line, next);
            return r;
        }
View Full Code Here

        this.manager = manager;
    }

    @Override
    public Response onCommand(POP3Session session, Request request) {
        Response response =  super.onCommand(session, request);
        if (POP3Response.OK_RESPONSE.equals(response.getRetCode())) {
            POP3BeforeSMTPHelper.addIPAddress(session.getRemoteAddress().getAddress().getHostAddress());
        }
        return response;
    }
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.