|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.rmi.server.RemoteObject
java.rmi.server.RemoteServer
java.rmi.server.UnicastRemoteObject
messageServerP.Communication
public class Communication
The message server Communication class implements all the communications
interfaces offered by the message server with RMI. It also implements some methods
using other internet communication paradigms.
This class is security critical because it contains all the methods accessible by
other hosts on the Internet
one line to give the program's name and an idea of what it does. Copyright (C) 2005 Marco Cornolti (cornolti@cli.di.unipi.it)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Field Summary | |
---|---|
private static long |
serialVersionUID
Gossip Message Server version |
Fields inherited from class java.rmi.server.RemoteObject |
---|
ref |
Constructor Summary | |
---|---|
protected |
Communication()
Constructor for the remote object. |
Method Summary | |
---|---|
void |
addToFriends(User user,
java.lang.String userPw,
User userToAdd)
Used by a servlet to tell the message server to add another user in his contact list as friend. |
void |
assign(java.lang.String MSPw,
User user,
java.lang.String password)
Assigns a new user to the message server. |
void |
assignMovedUser(ManagedUser user)
Assigns a user management (sending all its datas) to the message server. |
void |
blockAssignation(java.lang.String MSPw,
boolean status)
Puts the MS in the 'blocked' or 'unblocked' status, depending on the boolean status given by argument. |
void |
blockContact(User user,
java.lang.String pw,
User userToBlock)
Marks userToBlock in the user's contact list as blocked, so that no more messages from that user are accepted. |
void |
changePassword(User user,
java.lang.String oldPw,
java.lang.String newPw)
Changes the user password. |
void |
deleteDownloadedMsgs(User user,
java.lang.String pw)
Deletes the messages that are already downloaded by a User. |
void |
deleteUserAdmin(User nick,
java.lang.String MSpw)
Deletes a user. |
java.util.Vector<Message> |
downloadMsgs(User user,
java.lang.String pw)
Downloads the messages stored in the Message server for a user. |
void |
forwardMessage(Message msgRef)
Forwards a message. |
ContactList |
getContactList(User user,
java.lang.String pw)
Returns user list of contacts. |
User |
getManagedUserContact(User user)
Gets a User IP address and TCP port to directely connect to its servlet. |
Statistics |
getStatistics(java.lang.String MSPw)
Returns the statistics of the message server. |
User |
getUserContact(User user)
Gets a User IP address and TCP port to directely connect to its servlet. |
java.util.Vector<User> |
getUsersList(java.lang.String MSPw)
Returns the list of users managed by the Message Server. |
boolean |
inListOfUserContains(User listUser,
User user)
Checks whether or not a user (U1) accepts messages sent from another user (U2) |
void |
moveUser(java.lang.String MSPw,
User user,
MessageServer ms)
Moves a user assignation from the message server to the specified one. |
void |
removeContact(User user,
java.lang.String pw,
User userToRemove)
Removes userToRemove from user's contact list, so that no more messages from that user are accepted. |
static void |
sendLoad()
Sends to the bootstrap the current load via a UDP packet. |
void |
setState(User user,
java.lang.String pw,
boolean state)
Sets a user state. |
void |
shutdown(java.lang.String MSPw)
Shuts down the MS server. |
boolean |
testPassword(java.lang.String pw)
Tests a message server administration password. |
boolean |
testPorts(int port,
java.net.InetAddress ip)
Tests the servlet port trying to connect to them. |
void |
testPresence()
Tests the presence of a Message Server |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
---|
clone, exportObject, exportObject, exportObject, unexportObject |
Methods inherited from class java.rmi.server.RemoteServer |
---|
getClientHost, getLog, setLog |
Methods inherited from class java.rmi.server.RemoteObject |
---|
equals, getRef, hashCode, toString, toStub |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
protected Communication() throws java.rmi.RemoteException
java.rmi.RemoteException
- if the remote object could not be created.Method Detail |
---|
public void testPresence()
MSForBSInterface
testPresence
in interface MSForBSInterface
public void deleteUserAdmin(User nick, java.lang.String MSpw) throws WrongPasswordException, BlockedException, UserNotManagedException
MSForBSInterface
deleteUserAdmin
in interface MSForBSInterface
nick
- the user to delete.MSpw
- the Message Server administration password.
WrongPasswordException
- if the password is not right.
BlockedException
- if the MS is currently blocked.
UserNotManagedException
- if the specified user is not managed by the Message server.public void blockAssignation(java.lang.String MSPw, boolean status) throws WrongPasswordException
MSForBSInterface
blockAssignation
in interface MSForBSInterface
MSPw
- the MS administration password.status
- true if the status must be set to 'blocked', false if the status must be set to 'unblocked'.
WrongPasswordException
- if the password is wrong.public void moveUser(java.lang.String MSPw, User user, MessageServer ms) throws WrongPasswordException, UserNotManagedException, java.rmi.RemoteException, AssignationNotAcceptedException, GenericErrorException
MSForBSInterface
moveUser
in interface MSForBSInterface
MSPw
- the message server password.user
- the user to move.ms
- the message server to move the user to.
WrongPasswordException
- id the MS admin password is wrong.
UserNotManagedException
- if the user is not managed by this MS (or does not exists).
java.rmi.RemoteException
- if a communication problem occurs.
AssignationNotAcceptedException
- if the MS the user was wanted to be moved to refused the assignation (i.e. is blocked).
GenericErrorException
- if a communication problem with the second MS occurred.public Statistics getStatistics(java.lang.String MSPw) throws WrongPasswordException
MSForBSInterface
getStatistics
in interface MSForBSInterface
MSPw
- the MS password
WrongPasswordException
- if the administration password is wrong.public void shutdown(java.lang.String MSPw) throws UsersStillPresentException, WrongPasswordException, BlockedException
MSForBSInterface
shutdown
in interface MSForBSInterface
MSPw
- the Message Server password.
UsersStillPresentException
- if the Message Server still manages some users.
WrongPasswordException
- if the password is wrong.
BlockedException
- if the Message Server is not blocked.public void assign(java.lang.String MSPw, User user, java.lang.String password) throws BlockedException, WrongPasswordException
MSForBSInterface
assign
in interface MSForBSInterface
MSPw
- the MS password.user
- the user to addpassword
- the user password
BlockedException
- if the server is blocked and does not accept new users.
WrongPasswordException
- if the Message Server Password is wrong.public java.util.Vector<User> getUsersList(java.lang.String MSPw) throws WrongPasswordException
MSForBSInterface
getUsersList
in interface MSForBSInterface
MSPw
- the MS password
WrongPasswordException
- if the password is wrong.public boolean testPassword(java.lang.String pw)
MSForBSInterface
testPassword
in interface MSForBSInterface
pw
- the password to check
public void addToFriends(User user, java.lang.String userPw, User userToAdd) throws UserNotManagedException, WrongPasswordException, UserBlockedException, UserAlreadyInsertedException
MSForServletInterface
addToFriends
in interface MSForServletInterface
user
- the invoking user.userPw
- the invoking user password.userToAdd
- the user to add.
UserNotManagedException
- if the user is not managed by the local MS.
WrongPasswordException
- if the password is not right.
UserBlockedException
- if the user is blocked.
UserAlreadyInsertedException
- if the user is already contained in the incoming list.public java.util.Vector<Message> downloadMsgs(User user, java.lang.String pw) throws UserNotManagedException, UserBlockedException, WrongPasswordException
MSForServletInterface
downloadMsgs
in interface MSForServletInterface
user
- the user whose messages are wanted.pw
- the user's password
UserNotManagedException
- if the user is not managed by this message server.
UserBlockedException
- if the user is blocked (i.e. to be moved).
WrongPasswordException
- if the given password is wrong.public void setState(User user, java.lang.String pw, boolean state) throws UserNotManagedException, WrongPasswordException, GenericErrorException, UserBlockedException
MSForServletInterface
setState
in interface MSForServletInterface
user
- the userpw
- the user passwordstate
- true if the state is on-line, false if the state is off-line
UserNotManagedException
- if the user is not managed by the MS.
WrongPasswordException
- if the password is wrong.
GenericErrorException
- if another error occurred, i.e. the server could not define the servlet ip address.
UserBlockedException
- if the user is blocked.public void forwardMessage(Message msgRef) throws NotAllowedException, UserNotManagedException, java.rmi.RemoteException, GenericErrorException, UserNotExistsException, SystemErrorException
MSForServletInterface
forwardMessage
in interface MSForMSInterface
forwardMessage
in interface MSForServletInterface
msgRef
- the message to forward.
NotAllowedException
- if the recipient user does have the sender in its blockedlist.
UserNotManagedException
- if the MS does not manage the recipient nor the sender.
java.rmi.RemoteException
- if a communication problem occurs.
GenericErrorException
- if another error has occurred.
UserNotExistsException
- if the recipient does not exist in the whole system.
SystemErrorException
- if a system error occurred.public ContactList getContactList(User user, java.lang.String pw) throws UserNotManagedException, WrongPasswordException, UserBlockedException
MSForServletInterface
getContactList
in interface MSForServletInterface
user
- the userpw
- the user password
UserNotManagedException
- if the user is not managed by this message server.
WrongPasswordException
- if the user's password is wrong.
UserBlockedException
- if the user is blocked.public void changePassword(User user, java.lang.String oldPw, java.lang.String newPw) throws UserNotManagedException, WrongPasswordException, UserBlockedException
MSForServletInterface
changePassword
in interface MSForServletInterface
user
- the useroldPw
- the old passwordnewPw
- the new password to set
UserNotManagedException
- if the user is not managed by the MS.
WrongPasswordException
- if the old password is wrong.
UserBlockedException
- if the user is blocked.public boolean testPorts(int port, java.net.InetAddress ip)
MSForServletInterface
testPorts
in interface MSForServletInterface
port
- the port to test.ip
- the servlet ip.
public boolean inListOfUserContains(User listUser, User user) throws UserNotManagedException
MSForMSInterface
inListOfUserContains
in interface MSForMSInterface
listUser
- the receiver user (U1)user
- the sender user (U2)
UserNotManagedException
- if the listUser (U1) is not managed by the server.public void assignMovedUser(ManagedUser user) throws AssignationNotAcceptedException
MSForMSInterface
assignMovedUser
in interface MSForMSInterface
user
- the user to assign.
AssignationNotAcceptedException
- if the assignation was not accepted.public void deleteDownloadedMsgs(User user, java.lang.String pw) throws UserNotManagedException, WrongPasswordException, UserBlockedException
MSForServletInterface
deleteDownloadedMsgs
in interface MSForServletInterface
user
- the user.pw
- the user password.
UserNotManagedException
- if the user is not managed by the MS.
WrongPasswordException
- if the password is wrong.
UserBlockedException
- is the user is blocked.public static void sendLoad()
public void blockContact(User user, java.lang.String pw, User userToBlock) throws UserNotManagedException, UserNotExistsException, WrongPasswordException, UserBlockedException
MSForServletInterface
blockContact
in interface MSForServletInterface
user
- the user.pw
- the user's password.userToBlock
- the user to block.
UserNotManagedException
- if user is not managed by this message server.
UserNotExistsException
- if the userToBlock is not present in the contact list.
WrongPasswordException
- if the user's password is wrong.
UserBlockedException
- if the user is blockedpublic User getUserContact(User user) throws java.rmi.RemoteException, UserNotExistsException, GenericErrorException, UserBlockedException
MSForServletInterface
getUserContact
in interface MSForServletInterface
user
- the user whose connection datas is wanted. Only the nickname is considered.
java.rmi.RemoteException
- if a communication problem occurs.
UserNotExistsException
- if the specificed user nickname does not exists.
GenericErrorException
- if another error occurred (i.e. a communication problem with another message server).
UserBlockedException
- if the user is blocked.public void removeContact(User user, java.lang.String pw, User userToRemove) throws UserNotManagedException, WrongPasswordException, UserBlockedException
MSForServletInterface
removeContact
in interface MSForServletInterface
user
- the user.pw
- the user's password.userToRemove
- the user to remove.
UserNotManagedException
- if user is not managed by this message server.
WrongPasswordException
- if the user's password is wrong.
UserBlockedException
- if the user is currently blocked.public User getManagedUserContact(User user) throws java.rmi.RemoteException, UserNotManagedException
MSForMSInterface
getManagedUserContact
in interface MSForMSInterface
user
- the user whose connection datas is wanted. Only the nickname is considered.
java.rmi.RemoteException
- if a communication problem occurs.
UserNotManagedException
- if the user is not locally managed.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |