Class Specifications: The attributes and operation specifications are written in UML notation.Assume all attributes have private visibility.If you need to access an attribute from another object, then use its get / set methods If these methods have not been explicitly designed, you. may implement them as needed.As part of your implementation, you may add extra attributes if required.However, DO NOT change the public interfaces of the operations. An exception to this is for the design of the GUI.
class ClientThis class represents a single client which can request session keys from the server, and communicate with other clients.attributesname: String {unique name of the client consisting of one word} server: Server {object reference to the Server object the client is " connected "to} sessions: Collection (Session) key: String {private key of client used for encryption of messages} gui: ClientGUIinvariantname is one word and uniquekey must contain one or more capital letters that have an ASCII value between 65 and 90.operation specifications Client (name: String, key: String, server: Server) - parameterised constructorpre:. name is unique, server and key are validpost: A ClientGUI object has been created and assigned to gui The server has been sent a reference to this Object with a call to addclient (self). A Valid Client Object is Retund. RequestSession (name: string): Integer - Sets up The Communication Session with selected userpre: name Corresponds to the current ly selected userpost: A session request has been sent to the server by a call to establishSession (self.name, name) The session data (including the session key) has been obtained from the server A Session object has been created and initialised with. The decrypted session data. The session state has been set to wait_reply. The session is in the wait_reply state. The session.id Has Been Returned.
updateConnectedUsers (connectedUsers: String []) -. updates the list of connected users on the GUI displaypre: connectedUsers contains the names of users connected to the server.post: The list of connected users is displayed self is not included in the displayed list . acceptSession (sessionData: SessionData, senderName: String) - accepts session data from the sender wanting to establish a communication session.pre:. sessionData is validpost: a Session object has been created and initialised with the decrypted session data The session has been added to sessions The session state has been set to ACCEPT_REJECT The GUI display indicates that the session is in the ACCEPT_REJECT state acceptCmd... (cmd: String, sessionId: Integer) - accepts a command from the sender during establishment of communication Session.Pre: cmd is valid2post: for the session ide1, is equal to wait_reply if cmd = ACCEPT then session state has been set to CHAT. The GUI display indicates that the session is in the CHAT state. else if cmd = REJECT then session has been removed from sessions. The GUI reflects the end of the session. end if Else if state of the session is equal to chat if cmd = end the session HAS been Removed from sessions. The gui reflectes the end of the session. end if endiff ing
sendCmd (cmd: String, sessionId: Integer) - sends a command to the receiver during establishment of communication session.pre: cmd is validpost: for the session identified by sessionId server.sendCmd (cmd, sessionId, receiverName) 3 if cmd = ACCEPT then session state has been set to CHAT. The GUI display indicates that the session is in the CHAT state. else if cmd = REJECT then session has been removed from sessions. The GUI reflects the end of the session. else if cmd = END then session has been removed from sessions The GUI reflects the end of the session end if acceptChatMessage (msg: String, sessionId: Integer) -.. accepts a chat message from the sender for the session identified by sessionId.pre: msg is encryptedpost : The Msg Has Been Decrypted According To The Session Key Associated with The sessionId. B oth the msg and the decrypted message are displayed on the GUI textdisplay sendChatMessage. (msg: String, sessionId: Integer) - sends a chat message to the receiver for the session identified by sessionId.pre: msg not nullpost: msg has been encrypted according to the session key associated with the sessionId. encrypted msg has been sent to the receiving client for this session by calling server.sendChatMsg (msg, sessionId, receiverName) msg and encrypted message are displayed on GUI textdisplay.