Skip to content
Snippets Groups Projects
Commit e31f54b6 authored by Chang Che Hao's avatar Chang Che Hao
Browse files

remove unnecessary printouts

parent c4976e7d
Branches
No related tags found
No related merge requests found
......@@ -142,7 +142,7 @@ public class ChatScreen {
IChatController chatController = client.getChatController();
try
{
System.out.println("Send button pressed");
// System.out.println("Send button pressed");
String toUser = sendMessageToComboBox.getSelectedItem().toString();
SealedObject messageSealed = EncryptDecrypt.encryptString(message,client.getEncryptionUpdate().getSharedSecretKey());
......@@ -164,7 +164,7 @@ public class ChatScreen {
}
else if (e.getSource() == exitThisRoomButton)
{
System.out.println("Exit room button pressed by: " + client.getUserName());
// System.out.println("Exit room button pressed by: " + client.getUserName());
client.getApplicationMain().closeWindow();
}
else if (e.getSource() == kickOutButton)
......@@ -173,7 +173,7 @@ public class ChatScreen {
String toUser = kickUserComboBox.getSelectedItem().toString();
try {
System.out.println("Kick out button pressed");
// System.out.println("Kick out button pressed");
clientController.kickUser(client.getUserName(), toUser);
}
catch (RemoteException ex) {
......@@ -190,7 +190,7 @@ public class ChatScreen {
String toUser = kickUserComboBox.getSelectedItem().toString();
try {
System.out.println("Promote to manager button pressed");
// System.out.println("Promote to manager button pressed");
clientController.assignAdmin(client.getUserName(), toUser);
}
catch (RemoteException ex) {
......
......@@ -157,15 +157,15 @@ public class Client
// New connection
setUserName(userName);
setServerAddress(serverAddress);
System.out.println("Server address:" + serverAddress);
System.out.println(java.time.LocalTime.now() + " " + "Server address:" + serverAddress);
registryServer = LocateRegistry.getRegistry(serverAddress);
chatController = (IChatController) registryServer.lookup("ChatController");
clientController = (IClientController) registryServer.lookup("ClientController");
drawingController = (IDrawingController) registryServer.lookup("DrawingController");
System.out.println("User name:" + getUserName());
System.out.println("Password: " + password);
System.out.println(java.time.LocalTime.now() + " " + "User name:" + getUserName());
System.out.println(java.time.LocalTime.now() + " " + "Password: " + password);
if (clientController.setSharedKey(this.encryptionUpdate)) {
SealedObject sealedPassword = EncryptDecrypt.encryptString(password, this.encryptionUpdate.getSharedSecretKey());
......
......@@ -28,12 +28,12 @@ public class ClientUpdate extends UnicastRemoteObject implements IClientUpdate,
// for debuggins purposes
private void printUserList(String[] users)
{
System.out.print("Currently connected users: ");
// System.out.print("Currently connected users: ");
for( String s : users )
{
System.out.print(s + " ");
// System.out.print(s + " ");
}
System.out.println();
// System.out.println();
}
@Override
......
......@@ -24,10 +24,10 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
}
public boolean notifyUserIsDrawing(String fromClient) throws RemoteException {
System.out.println("Adding name of user to the list of drawing users");
// System.out.println("Adding name of user to the list of drawing users");
DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel();
if(temp.contains(fromClient)){
System.out.println("Already in the list");
// System.out.println("Already in the list");
}
else {
temp.addElement(fromClient);
......@@ -93,7 +93,7 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
g2.draw(drawing);
break;
default:
System.out.println("Erased");
// System.out.println("Erased");
}
g2 = (Graphics2D) client.getApplicationMain().getPaintGUI().getDrawingArea().getImage().getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
......@@ -131,7 +131,7 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel();
if(temp.contains(fromClient)){
System.out.println("Already in the list");
// System.out.println("Already in the list");
}
else {
temp.addElement(fromClient);
......
......@@ -32,7 +32,7 @@ public class EncryptionUpdate extends UnicastRemoteObject implements IEncryption
Cipher cipher = Cipher.getInstance("RSA", "SunJCE");
cipher.init(Cipher.DECRYPT_MODE, priv);
sharedSecretKey = new SecretKeySpec(cipher.doFinal(encryptedSharedSecretKey), "AES");
System.out.println("Client holds this shared key: "+sharedSecretKey);
// System.out.println("Client holds this shared key: "+sharedSecretKey);
} catch (NoSuchAlgorithmException e) {
......
package remote;
import GUI.StartScreen;
import javax.crypto.*;
import java.io.IOException;
import java.security.InvalidKeyException;
......@@ -16,19 +18,26 @@ public class EncryptDecrypt {
nonSealedString = (String)sealedObject.getObject(cipher);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (BadPaddingException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
}
return nonSealedString;
......@@ -42,15 +51,20 @@ public class EncryptDecrypt {
cipher.init(Cipher.ENCRYPT_MODE,key);
sealedObject = new SealedObject(string,cipher);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (NoSuchPaddingException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (IllegalBlockSizeException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
} catch (InvalidKeyException e) {
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Shared key error");
// e.printStackTrace();
}
return sealedObject;
......
......@@ -21,7 +21,7 @@ public class ChatController extends UnicastRemoteObject implements IChatControll
@Override
public boolean broadcastMessage(String fromClient, SealedObject messageSealed) throws RemoteException
{
System.out.print("Broadcasting message to everyone...");
// System.out.print("Broadcasting message to everyone...");
int fromClientIndex = server.clientController.getUserIndex(fromClient);
String message = EncryptDecrypt.decryptString(messageSealed,server.users.get(fromClientIndex).getSharedSecretKey());
......@@ -31,14 +31,14 @@ public class ChatController extends UnicastRemoteObject implements IChatControll
u.getIChatUpdate().notifyChat(fromClient, messageSealedTo, false);
}
System.out.print("...DONE\n");
// System.out.print("...DONE\n");
return true;
}
@Override
public boolean broadcastMessageUserLogin(String fromClient) throws RemoteException {
System.out.print("Broadcasting message to everyone...");
// System.out.print("Broadcasting message to everyone...");
IChatUpdate client;
......@@ -48,15 +48,15 @@ public class ChatController extends UnicastRemoteObject implements IChatControll
client.notifyUserLogin(fromClient);
}
System.out.print("...DONE\n");
System.out.println(fromClient + " has joined the room.");
// System.out.print("...DONE\n");
System.out.println(java.time.LocalTime.now() + " " + fromClient + " has joined the room.");
return true;
}
@Override
public boolean broadcastMessageUserLogout(String fromClient) throws RemoteException {
System.out.print("Broadcasting message to everyone...");
// System.out.print("Broadcasting message to everyone...");
IChatUpdate client;
......@@ -66,8 +66,8 @@ public class ChatController extends UnicastRemoteObject implements IChatControll
client.notifyUserLogout(fromClient);
}
System.out.print("...DONE\n");
System.out.println(fromClient + " has left the room.");
// System.out.print("...DONE\n");
System.out.println(java.time.LocalTime.now() + " " + fromClient + " has left the room.");
return true;
}
......
......@@ -75,10 +75,10 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
// for debuggins purposes
private void printUserList()
{
System.out.print("Currently connected users: ");
// System.out.print("Currently connected users: ");
for( User u : server.users )
{
System.out.print(u.getUserName() + " ");
// System.out.print(u.getUserName() + " ");
}
System.out.println();
}
......@@ -149,9 +149,9 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
for( User u : server.users )
{
System.out.print(u.getUserName() + " being notified");
// System.out.print(u.getUserName() + " being notified");
u.getIClientUpdate().updateUserList(connectedUsers);
System.out.println("...DONE");
// System.out.println("...DONE");
}
}
......@@ -170,7 +170,7 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
@Override
public boolean broadcastManagerMessage(String toClient, Action action) throws RemoteException {
System.out.print("Broadcasting message to everyone...");
// System.out.print("Broadcasting message to everyone...");
IClientUpdate client;
switch (action){
......@@ -181,8 +181,8 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
client.notifyManagerActions(toClient, remote.IClientUpdate.Action.KICKOUT);
}
System.out.print("...DONE\n");
System.out.println(toClient + " has been kicked out the room.");
// System.out.print("...DONE\n");
System.out.println(java.time.LocalTime.now() + " " + toClient + " has been kicked out the room.");
break;
case ASSIGNADMIN:
......@@ -193,8 +193,8 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
client.setVisibility();
}
System.out.print("...DONE\n");
System.out.println(toClient + " is the new manager.");
// System.out.print("...DONE\n");
System.out.println(java.time.LocalTime.now() + " " + toClient + " is the new manager.");
break;
}
......@@ -218,7 +218,7 @@ public class ClientController extends UnicastRemoteObject implements IClientCont
}
server.users.clear();
} else {
System.out.println("You are not the manager");
// System.out.println("You are not the manager");
}
}
......
......@@ -166,7 +166,7 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
public void broadcastDrawingUser (String fromClient) throws RemoteException {
System.out.println("Current client is drawing: " + fromClient);
// System.out.println("Current client is drawing: " + fromClient);
IDrawingUpdate client;
for (User u: server.users){
client = u.getIDrawingUpdate();
......@@ -176,7 +176,7 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
}
public void broadcastDrawingUserStopped (String fromClient) throws RemoteException{
System.out.println("Current user stopped drawing" + fromClient);
// System.out.println("Current user stopped drawing" + fromClient);
IDrawingUpdate client;
for (User u: server.users){
client = u.getIDrawingUpdate();
......@@ -206,14 +206,16 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
client.receiveImage(baos.toByteArray());
}
catch (IOException err) {
err.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Error in broadcasting the latest canvas.");
// err.printStackTrace();
}
baos.close();
}
}
}
catch (IOException err) {
err.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Error in broadcasting the latest canvas.");
// err.printStackTrace();
}
// System.out.print("...DONE\n");
......@@ -229,7 +231,8 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
g2.drawImage(bufferedImage, null, 0, 0);
}
catch (IOException err) {
err.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Error in updating canvas.");
// err.printStackTrace();
}
return true;
}
......@@ -246,7 +249,8 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
baos.close();
}
catch (IOException err) {
err.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Error in getting canvas.");
// err.printStackTrace();
}
for( User u : server.users )
......
......@@ -26,7 +26,7 @@ public class MySharedKey {
this.sharedSecretKey = new SecretKeySpec(new byte[16], "AES");
System.out.println(sharedSecretKey);
this.encryptedSharedSecretKey = wrapKey(encryptionUpdate.getPub());
System.out.println("Shared key on server:" + sharedSecretKey);
// System.out.println("Shared key on server:" + sharedSecretKey);
encryptionUpdate.setSharedKey(encryptedSharedSecretKey);
}
......@@ -38,9 +38,9 @@ public class MySharedKey {
byte[] result2 = c.wrap(sharedSecretKey);
return result2;
} catch (Exception e) {
e.printStackTrace();
throw new IllegalStateException(
e);
System.out.println(java.time.LocalTime.now() + " " + "Error in wrapping the key.");
// e.printStackTrace();
throw new IllegalStateException(e);
}
}
}
......@@ -56,7 +56,8 @@ public class Server
}
catch( Exception e )
{
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Server launch failed.");
// e.printStackTrace();
}
}
......@@ -91,7 +92,7 @@ public class Server
registry.rebind(chatControllerName, chatController);
registry.rebind(drawingControllerName, drawingController);
System.out.println("Server is ready");
System.out.println(java.time.LocalTime.now() + " " + "Server is ready");
printIP(serverIP);
}
......@@ -108,10 +109,11 @@ public class Server
}
catch (UnknownHostException e)
{
e.printStackTrace();
System.out.println(java.time.LocalTime.now() + " " + "Get IP failed.");
// e.printStackTrace();
}
System.out.println("IP Address:- " + inetAddress.getHostAddress());
System.out.println(java.time.LocalTime.now() + " " + "IP Address:- " + inetAddress.getHostAddress());
//System.out.println("Host Name:- " + inetAddress.getHostName());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment