Package edu.drexel.cs544.mcmuc.util

Examples of edu.drexel.cs544.mcmuc.util.Certificate


     * correct type. Errors are display if the message does not have an action or the
     * type is not supported (not message, presence, or poll-presence).
     */
    @Override
    public void handleNewMessage(JSONObject jo) {
        Action action;
        String actionString = "";

        try {
            actionString = jo.getString("action");
        } catch (JSONException e) {
            System.err.println("Message does not have action.");
            e.printStackTrace();
        }

        if (actionString.equalsIgnoreCase(Message.action)) {
            action = new Message(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Presence.action)) {
            try {
                action = new Presence(jo);
                action.process(this);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (actionString.equalsIgnoreCase(PollPresence.action)) {
            action = new PollPresence(jo);
            action.process(this);
        } else {
            System.err.println("Message action type not supported: " + actionString);
        }
    }
View Full Code Here


     * correct type. Errors are display if the message does not have an action or the
     * type is not supported (not list-rooms, use-rooms, timeout, and preserve).
     */
    @Override
    public void handleNewMessage(JSONObject jo) {
        Action action;
        String actionString = "";
        try {
            actionString = jo.getString("action");
        } catch (JSONException e) {
            System.err.println("Message does not have action.");
            e.printStackTrace();
        }
        if (actionString.equalsIgnoreCase(UseRooms.action)) {
            action = new UseRooms(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(ListRooms.action)) {
            action = new ListRooms(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Timeout.action)) {
            action = new Timeout(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Preserve.action)) {
            action = new Preserve(jo);
            action.process(this);
        } else {
            System.err.println("Message action type not supported: " + actionString);
        }
    }
View Full Code Here

     * @param port int port to use (will always be CONTROL_PORT)
     */
    private Controller(int port) {
        super(port);
        channels.put(port, this);
        this.send(new ListRooms());
    }
View Full Code Here

        }
        if (actionString.equalsIgnoreCase(UseRooms.action)) {
            action = new UseRooms(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(ListRooms.action)) {
            action = new ListRooms(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Timeout.action)) {
            action = new Timeout(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Preserve.action)) {
View Full Code Here

            System.err.println("Message does not have action.");
            e.printStackTrace();
        }

        if (actionString.equalsIgnoreCase(Message.action)) {
            action = new Message(jo);
            action.process(this);
        } else if (actionString.equalsIgnoreCase(Presence.action)) {
            try {
                action = new Presence(jo);
                action.process(this);
View Full Code Here

                        System.err.println("Unknown status");
                        continue;
                    }
                    controller.setRoomStatus(command.getArg(0), s);
                } else if (command.getCommand() == CLICommand.Command.MESSAGE) {
                    controller.messageRoom(command.getArg(0), new Message(controller.getUserName(command.getArg(0)), command.getArg(1)));
                } else if (command.getCommand() == CLICommand.Command.PVTMESSAGE) {
                    controller.messageRoom(command.getArg(1), new Message(controller.getUserName(command.getArg(1)), command.getArg(2), command.getArg(0)));
                } else if (command.getCommand() == CLICommand.Command.ADDKEY) {
                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(1));
                    byte publicKey[] = new byte[(int) publicKeyFile.available()];
                    publicKeyFile.read(publicKey);

                    FileInputStream privateKeyFile = new FileInputStream(command.getArg(2));
                    byte privateKey[] = new byte[(int) privateKeyFile.available()];
                    privateKeyFile.read(privateKey);

                    controller.addKeyPair(command.getArg(0), new Certificate("X.509", publicKey), new Certificate("X.509", privateKey));
                } else if (command.getCommand() == CLICommand.Command.REMOVEKEY) {
                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(1));
                    byte publicKey[] = new byte[(int) publicKeyFile.available()];
                    publicKeyFile.read(publicKey);

                    controller.removeKeyPair(command.getArg(0), new Certificate("X.509", publicKey));

                } else if (command.getCommand() == CLICommand.Command.SECUREMESSAGE) {
                    FileInputStream publicKeyFile = new FileInputStream(command.getArg(0));
                    byte publicKey[] = new byte[(int) publicKeyFile.available()];
                    publicKeyFile.read(publicKey);

                    Certificate cert = new Certificate("X.509", publicKey);
                    controller.messageRoom(command.getArg(2), new Message(controller.getUserName(command.getArg(2)), command.getArg(3), command.getArg(1), cert));
                }
            } catch (RoomDoesNotExistException e) {
                cli.alert(e.getMessage());
            } catch (FileNotFoundException e) {
                e.printStackTrace();
View Full Code Here

        this.userName = userName;
        this.keyPairs = new HashMap<Certificate, Certificate>();

        // Send the necessary initial messages
        setStatus(Status.Online);
        this.send(new PollPresence());
    }
View Full Code Here

                action.process(this);
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (actionString.equalsIgnoreCase(PollPresence.action)) {
            action = new PollPresence(jo);
            action.process(this);
        } else {
            System.err.println("Message action type not supported: " + actionString);
        }
    }
View Full Code Here

     * @param roomPort the port
     */
    public void startForwarder(int roomPort) {
        Forwarder fwd = new Forwarder(roomPort);
        channels.put(roomPort, fwd);
        fwd.send(new PollPresence());
    }
View Full Code Here

    /**
     * Sends the user's per-room status out to the Room channel
     */
    private void sendStatus() {
        if (this.keyPairs.keySet().isEmpty()) {
            this.send(new Presence(this.getUserName(), roomPresence));
        } else {
            this.send(new Presence(this.getUserName(), roomPresence, new ArrayList<Certificate>(keyPairs.keySet())));
        }
    }
View Full Code Here

TOP

Related Classes of edu.drexel.cs544.mcmuc.util.Certificate

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.