messageServerP
Class MyselfMessageServer

java.lang.Object
  extended by common.MessageServer
      extended by messageServerP.MyselfMessageServer
All Implemented Interfaces:
java.io.Serializable

public class MyselfMessageServer
extends MessageServer

A self-representation of a message server.

Author:
Marco Cornolti
See Also:
Serialized Form

Field Summary
private static boolean created
           
static MyselfMessageServer myself
           
private  java.lang.String password
           
private static long serialVersionUID
           
 
Constructor Summary
private MyselfMessageServer(java.net.InetAddress ip, int port, java.lang.String password)
          private constructor to not let anyone create two MyselfMessageServers
 
Method Summary
 boolean checkPassword(java.lang.String pw)
           
static MyselfMessageServer makeMyselfMessageServer(java.net.InetAddress ip, int port, java.lang.String password)
          A constructor that works just once, to avoid creating two MyselfMessageServers.
static boolean setPassword(java.lang.String oldPw, java.lang.String newPw)
          change the administration password
 
Methods inherited from class common.MessageServer
equals, getIP, getPort
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

password

private java.lang.String password

created

private static boolean created

myself

public static MyselfMessageServer myself
Constructor Detail

MyselfMessageServer

private MyselfMessageServer(java.net.InetAddress ip,
                            int port,
                            java.lang.String password)
private constructor to not let anyone create two MyselfMessageServers

Parameters:
ip - the ip address
port - the service port
password - the administration password
Method Detail

checkPassword

public boolean checkPassword(java.lang.String pw)
Parameters:
pw - the password to check
Returns:
true if and only if the given password is right

setPassword

public static boolean setPassword(java.lang.String oldPw,
                                  java.lang.String newPw)
change the administration password

Parameters:
oldPw - the old password
newPw - the new password
Returns:
true if the password has been changed, false if the given old password was not right

makeMyselfMessageServer

public static MyselfMessageServer makeMyselfMessageServer(java.net.InetAddress ip,
                                                          int port,
                                                          java.lang.String password)
A constructor that works just once, to avoid creating two MyselfMessageServers.

Parameters:
ip - the ip address
port - the service port
password - the administration password
Returns:
the new MyselfMessageServer if not yet created, null otherwise.