Package org.apache.james.remotemanager

Examples of org.apache.james.remotemanager.RemoteManagerResponse


                if (state == LOGIN_SUPPLIED) {
                    session.getState().put(USERNAME, line);
                    session.getState().put(AUTHORIZATION_STATE, PASSWORD_SUPPLIED);

                    session.writeResponse(new RemoteManagerResponse("Password:"));
                } else if (state == PASSWORD_SUPPLIED) {
                    String password = line;
                    String username = (String) session.getState().get(USERNAME);

                    if (!password.equals(session.getAdministrativeAccountData().get(username)) || password.length() == 0) {
                        final String message = "Login failed for " + username;
                        session.writeResponse(new RemoteManagerResponse(message));
                        session.writeResponse(new RemoteManagerResponse("Login id:"));

                        // we need to handle the next line as login again
                        session.getState().put(AUTHORIZATION_STATE, LOGIN_SUPPLIED);

                    } else {
                        StringBuilder messageBuffer = new StringBuilder(64).append("Welcome ").append(username).append(". HELP for a list of commands");
                        session.writeResponse(new RemoteManagerResponse(messageBuffer.toString()));
                        if (session.getLogger().isInfoEnabled()) {
                            StringBuilder infoBuffer = new StringBuilder(128).append("Login for ").append(username).append(" successful");
                            session.getLogger().info(infoBuffer.toString());
                        }
                        session.popLineHandler();
View Full Code Here


    /*
     * (non-Javadoc)
     * @see org.apache.james.protocols.api.CommandHandler#onCommand(org.apache.james.protocols.api.ProtocolSession, org.apache.james.protocols.api.Request)
     */
    public Response onCommand(RemoteManagerSession session, Request request) {
        RemoteManagerResponse response = new RemoteManagerResponse("Bye");
        response.setEndSession(true);
       
        return response;
    }
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.apache.james.protocols.api.CommandHandler#onCommand(org.apache.james.protocols.api.ProtocolSession, org.apache.james.protocols.api.Request)
     */
    public Response onCommand(RemoteManagerSession session, Request request) {
        RemoteManagerResponse response;
        String parameters = request.getArgument();
        String[] args = null;

        if (parameters != null)
            args = parameters.split(" ");

        // check if the command was called correct
        if (parameters == null || parameters.trim().equals("") || args.length != 2) {
            response = new RemoteManagerResponse("Usage: " + help.getSyntax());
        } else {
            try {
                response = new RemoteManagerResponse("Removing mapping successful: " + mappingAction(args, REMOVE_MAPPING_ACTION));
            } catch (IllegalArgumentException e) {
                session.getLogger().error("Error on  removing mapping: " + e);
                response = new RemoteManagerResponse("Error on removing mapping: " + e);
            }
        }
        return response;
    }
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.apache.james.protocols.api.CommandHandler#onCommand(org.apache.james.protocols.api.ProtocolSession, org.apache.james.protocols.api.Request)
     */
    public Response onCommand(RemoteManagerSession session, Request request) {
        RemoteManagerResponse response = new RemoteManagerResponse("Current memory statistics:");
        response.appendLine("\tFree Memory: " + Runtime.getRuntime().freeMemory());
        response.appendLine("\tTotal Memory: " + Runtime.getRuntime().totalMemory());
        response.appendLine("\tMax Memory: " + Runtime.getRuntime().maxMemory());

        if ("-gc".equalsIgnoreCase(request.getArgument())) {
            System.gc();
            response.appendLine("And after System.gc():");
            response.appendLine("\tFree Memory: " + Runtime.getRuntime().freeMemory());
            response.appendLine("\tTotal Memory: " + Runtime.getRuntime().totalMemory());
            response.appendLine("\tMax Memory: " + Runtime.getRuntime().maxMemory());
        }

        return response;
    }
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.apache.james.protocols.api.CommandHandler#onCommand(org.apache.james.protocols.api.ProtocolSession, org.apache.james.protocols.api.Request)
     */
    public Response onCommand(RemoteManagerSession session, Request request) {
        RemoteManagerResponse response = null;
        for (int i = 0; i < extensions.size(); i++) {
            CommandHandler cmd = extensions.get(i);
            CommandHelp help = cmd.getHelp();
            if (help != null) {
                if (response == null) {
                    response = new RemoteManagerResponse(help.getSyntax() + "\t" + help.getDescription());
                } else {
                    response.appendLine(help.getSyntax() + "\t" + help.getDescription());
                }
            }
        }
        return response;
    }
View Full Code Here

TOP

Related Classes of org.apache.james.remotemanager.RemoteManagerResponse

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.