com.SecurePlay
Class SPCommsManagerClass

java.lang.Object
  extended bycom.SecurePlay.SPCommsManagerClass
All Implemented Interfaces:
SPCommsManagerCommsInterface

public class SPCommsManagerClass
extends java.lang.Object
implements SPCommsManagerCommsInterface

This class manages the communications and various communications services. It is essentially the "router" for the game data.

Author:
IT GlobalSecure
See Also:
SecurePlay License Information
 

Constructor Summary
SPCommsManagerClass(SPGameInterface gameobj, SPLogInterface log, SPSecurityManagerInterface security)
          Overloaded Constructor.
 
Method Summary
 boolean addComms(java.lang.String commsID)
          This method safely adds an available comms service to the game instance.
 boolean endGameComms()
          This method safely ends the game comms session.
 SPAbstractCommsInterface getComms(java.lang.String commsID)
          This method safely returns one of the comms services objects associated with this game instance.
 java.lang.String getCommsStatus()
          Gets the comms status.
 boolean getEncryptPolicy()
          This method returns the encryption policy flag.
 java.lang.String getGameID()
          Getter function that returns gameID associated with the Comms Manager Class
 SPGameInterface getGameinstance()
          Getter function that returns the property:
 byte[] getHashText(java.lang.String plainText, java.lang.String algorithm)
          This method gets the hashed string
 java.lang.String[] getInternalplayerIDList()
          Getter function that returns the property: internalplayerIDList
 SPLogInterface getMessagelog()
          Getter function that returns the property: messagelog
 SPMap getPlayerCommsList()
          Getter function that returns the property: playerCommsList
 java.lang.String[] getPrcommsIDList()
          Getter function that returns the property: prcommsIDList
 SPMap getPrcommsServList()
          Getter function that returns the property: prcommsServList
 SecurePlayClass getSecurePlay()
          Getter function that returns SecurePlayClass associated with Comms Manager Class
 SPSecurityManagerInterface getSecurityManager()
           
 boolean getSignaturePolicy()
          This method returns the Signature Policy flag for the game instance.
 boolean isPlayerInternal(java.lang.String pid)
          Checks to see if the player is internal to the game.
 void logError()
          This is a shell function for future use.
 boolean receiveMessage(SPMessageClass incoming)
          This method safely receives and routes incoming messages.
 boolean removeComms(java.lang.String cid)
          This method safely removes comms service from the game instance.
 void removePlayer(java.lang.String playerID)
          This method safely removes a player from the game instance's comms.
 boolean sendMessage(SPRootTransactionClass sendingobject, java.lang.String sender, java.lang.String[] receivers, boolean encryptflag, boolean privateflag, java.lang.String messagetype, java.lang.String[] messagebody, java.lang.String[] altmessage)
          This method manages actually sending messages to other game instances via communication services objects.
 boolean setPlayerComms(java.lang.String pid, java.lang.String cid, boolean rflag)
          This method safely associates a Player with a comms service and enables relay support for that player via that comms service.
 boolean setSecurityPolicy(boolean sign, boolean encrypt)
          This method safely sets the security policy (encryption and signatures, for the game instance).
 byte[] SPcreateBHashCM(java.lang.String input, java.lang.String gameid)
          This is a wrapper function for creating a hash of a string.
 byte[] SPcreateBSignature(java.lang.String senderID, byte[] input, java.lang.String gameid)
          This is a wrapper function for creating a digital signature based on an existing hashed string and a Sender ID.
 java.lang.String SPcreateHash(java.lang.String input, java.lang.String gameid)
          This is a wrapper function for creating a hash of a string.
 java.lang.String SPcreateSignature(java.lang.String senderID, java.lang.String input, java.lang.String gameid)
          This is a wrapper function for creating a digital signature based on an existing hashed string and a Sender ID.
 java.lang.String[] SPdecrypt(java.lang.String[] input, java.lang.String senderID, java.lang.String[] recvrs, java.lang.String gameID, java.lang.String messageID)
          This is a placeholder for an decryption function.
 java.lang.String[] SPencrypt(java.lang.String[] input, java.lang.String senderID, java.lang.String[] recvrs, java.lang.String gameID, java.lang.String messageID)
          This is a placeholder for an encryption function.
 java.lang.String SPtransform(java.lang.String input, java.lang.String gameid)
          This function performs an irreversible transform on an input string to generate an output string.
 boolean SPverifySignature(byte[] sigToVerify, java.lang.String senderID, byte[] testhash, java.lang.String gameid)
          This is a wrapper for a digital signature verification function.
 boolean SPverifySignature(java.lang.String signature, java.lang.String senderID, java.lang.String testhash, java.lang.String gameid)
          This is a wrapper for a digital signature verification function.
 void startCommsManager()
          initialize the message log with licensing information
 java.lang.String UpdateCommsStatus()
          This method reviews and updates the status of the comms instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SPCommsManagerClass

public SPCommsManagerClass(SPGameInterface gameobj,
                           SPLogInterface log,
                           SPSecurityManagerInterface security)
Overloaded Constructor.

Parameters:
gameobj - - SPGameInterface - game instance object
log - SPLogInterface - log class associated with this comms manager.
security - SPSecurityManagerInterface - security manager associated with this comms manager.
Method Detail

startCommsManager

public void startCommsManager()
initialize the message log with licensing information


setSecurityPolicy

public boolean setSecurityPolicy(boolean sign,
                                 boolean encrypt)
This method safely sets the security policy (encryption and signatures, for the game instance).

Parameters:
sign - boolean - Signature policy
encrypt - boolean - encryption policy
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

getComms

public SPAbstractCommsInterface getComms(java.lang.String commsID)
This method safely returns one of the comms services objects associated with this game instance.

Parameters:
commsID - String - id of the comms to be retrieved
Returns:
Object - SPAbstractCommsInterface - comms service object handler

addComms

public boolean addComms(java.lang.String commsID)
This method safely adds an available comms service to the game instance.

Parameters:
commsID - String - comms service identifier string
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

removeComms

public boolean removeComms(java.lang.String cid)
This method safely removes comms service from the game instance.

Parameters:
cid - String - id of the comms object to be removed
Returns:
result - Boolean: TRUE, if successful, FALSE, if not

getEncryptPolicy

public boolean getEncryptPolicy()
This method returns the encryption policy flag.

Returns:
result - Boolean: TRUE, if flag set, FALSE, if not.

getSignaturePolicy

public boolean getSignaturePolicy()
This method returns the Signature Policy flag for the game instance.

Returns:
result - Boolean, TRUE, if flag set, FALSE, if not.

endGameComms

public boolean endGameComms()
This method safely ends the game comms session. NOTE: it will not stop incoming messages, only outgoing or relayed messages.

Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

setPlayerComms

public boolean setPlayerComms(java.lang.String pid,
                              java.lang.String cid,
                              boolean rflag)
This method safely associates a Player with a comms service and enables relay support for that player via that comms service.

Parameters:
pid - String - player id to be set
cid - String - comms id to be set
rflag - boolean - relay flag
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

removePlayer

public void removePlayer(java.lang.String playerID)
This method safely removes a player from the game instance's comms.

Parameters:
playerID - String - id of the player to be removed

UpdateCommsStatus

public java.lang.String UpdateCommsStatus()
This method reviews and updates the status of the comms instance.

Returns:
prcommsstatus - String - the updated prcommsstatus property

sendMessage

public boolean sendMessage(SPRootTransactionClass sendingobject,
                           java.lang.String sender,
                           java.lang.String[] receivers,
                           boolean encryptflag,
                           boolean privateflag,
                           java.lang.String messagetype,
                           java.lang.String[] messagebody,
                           java.lang.String[] altmessage)
This method manages actually sending messages to other game instances via communication services objects. Also, for private messages, it sends an alternate message to the parties not recieving the main message.

Parameters:
sendingobject -
sender -
receivers -
encryptflag -
privateflag -
messagetype -
messagebody -
altmessage -
Returns:
result - Boolean: TRUE, if successful, FALSE, if not.

receiveMessage

public boolean receiveMessage(SPMessageClass incoming)
Description copied from interface: SPCommsManagerCommsInterface
This method safely receives and routes incoming messages. Only proper, valid messages will be sent on to transactions for processing.

Specified by:
receiveMessage in interface SPCommsManagerCommsInterface
Parameters:
incoming - SPMessageClass - incoming message
Returns:
Boolean - TRUE, if successful, FALSE, if not.

logError

public void logError()
This is a shell function for future use.


getCommsStatus

public java.lang.String getCommsStatus()
Gets the comms status.

Returns:
prcommsstatus - String - comms status

isPlayerInternal

public boolean isPlayerInternal(java.lang.String pid)
Checks to see if the player is internal to the game.

Parameters:
pid - String - the player id
Returns:
result - boolean:

getGameinstance

public SPGameInterface getGameinstance()
Getter function that returns the property:

Returns:
gameinstance - SPGameInterface

getInternalplayerIDList

public java.lang.String[] getInternalplayerIDList()
Getter function that returns the property: internalplayerIDList

Returns:
internalplayerIDList - String[]

getMessagelog

public SPLogInterface getMessagelog()
Getter function that returns the property: messagelog

Returns:
messagelog - SPLogInterface

getPlayerCommsList

public SPMap getPlayerCommsList()
Getter function that returns the property: playerCommsList

Returns:
playerCommsList - SPMap

getPrcommsIDList

public java.lang.String[] getPrcommsIDList()
Getter function that returns the property: prcommsIDList

Returns:
prcommsIDList - String[]

getPrcommsServList

public SPMap getPrcommsServList()
Getter function that returns the property: prcommsServList

Returns:
prcommsServList - SPHashtable

getGameID

public java.lang.String getGameID()
Getter function that returns gameID associated with the Comms Manager Class

Returns:
gameID - String

getSecurePlay

public SecurePlayClass getSecurePlay()
Getter function that returns SecurePlayClass associated with Comms Manager Class

Returns:
SecurePlayClass - secure play class associated with this manager

getSecurityManager

public SPSecurityManagerInterface getSecurityManager()

getHashText

public byte[] getHashText(java.lang.String plainText,
                          java.lang.String algorithm)
This method gets the hashed string

Parameters:
plainText - String - string to be hashed
algorithm - String - The algorithm to use like MD2, MD5, SHA-1, etc.
Returns:
hash - String - the hashed string

SPcreateBHashCM

public byte[] SPcreateBHashCM(java.lang.String input,
                              java.lang.String gameid)
This is a wrapper function for creating a hash of a string. This reference implementation includes a MD5 hash.

Parameters:
input - String
Returns:
str - String - Hash of input

SPcreateBSignature

public byte[] SPcreateBSignature(java.lang.String senderID,
                                 byte[] input,
                                 java.lang.String gameid)
This is a wrapper function for creating a digital signature based on an existing hashed string and a Sender ID. The reference implementation currently uses an MD5 function to approximate performance of a real signature. The included signature function is a sample function - REPLACE with a function that meets your specific security requirements.

Parameters:
senderID - String
input - String
gameid - String
Returns:
realSig - byte[] - digital signature of hashstring signed by senderID.

SPcreateHash

public java.lang.String SPcreateHash(java.lang.String input,
                                     java.lang.String gameid)
This is a wrapper function for creating a hash of a string. This reference implementation includes a MD5 hash.

Parameters:
input - String
Returns:
str - String - Hash of input

SPcreateSignature

public java.lang.String SPcreateSignature(java.lang.String senderID,
                                          java.lang.String input,
                                          java.lang.String gameid)
This is a wrapper function for creating a digital signature based on an existing hashed string and a Sender ID. The reference implementation currently uses an MD5 function to approximate performance of a real signature. The included signature function is a sample function - REPLACE with a function that meets your specific security requirements.

Parameters:
senderID - String
input - String
gameid - String
Returns:
str - String - digital signature of hashstring signed by senderID.

SPdecrypt

public java.lang.String[] SPdecrypt(java.lang.String[] input,
                                    java.lang.String senderID,
                                    java.lang.String[] recvrs,
                                    java.lang.String gameID,
                                    java.lang.String messageID)
This is a placeholder for an decryption function. An actual encryption function is the responsibility of the game implementer.

Parameters:
input - String[] - input message body to be decrypted
senderID - String - sender id
recvrs - String[] - receiver id list
gameID - String - game id
messageID - String - message id
Returns:
mess - String[] - String array of decrypted messagebody.

SPencrypt

public java.lang.String[] SPencrypt(java.lang.String[] input,
                                    java.lang.String senderID,
                                    java.lang.String[] recvrs,
                                    java.lang.String gameID,
                                    java.lang.String messageID)
This is a placeholder for an encryption function. An actual encryption function is the responsibility of the game implementer.

Parameters:
input - String[] - message body to be encrypted
senderID - String - sender id
recvrs - String[] - receiver id list
gameID - String - game id
messageID - String - message id
Returns:
mess - String[] - Encrypted message body

SPtransform

public java.lang.String SPtransform(java.lang.String input,
                                    java.lang.String gameid)
This function performs an irreversible transform on an input string to generate an output string. The sample implementation uses MD5. This method can be overridden and should be reviewed for security purposes prior to use in a production implementation.

Parameters:
input - String
Returns:
str - String

SPverifySignature

public boolean SPverifySignature(byte[] sigToVerify,
                                 java.lang.String senderID,
                                 byte[] testhash,
                                 java.lang.String gameid)
This is a wrapper for a digital signature verification function. CAREFUL CHOICE OF ACTUAL DIGITAL SIGNATURES AND VERIFICATION IS CRITICAL. SELECTION OF APPROPRIATE FUNCTIONS AND IMPLEMENTATION MAY HAVE A SUBSTANTIAL IMPACT ON THE SECURITY AND PERFORMANCE OF A GAME IMPLEMENTATION.

Parameters:
sigToVerify - byte[]
senderID - String
testhash - String
Returns:
true - Boolean - TRUE, if verification Successful, FALSE, if not.

SPverifySignature

public boolean SPverifySignature(java.lang.String signature,
                                 java.lang.String senderID,
                                 java.lang.String testhash,
                                 java.lang.String gameid)
This is a wrapper for a digital signature verification function. CAREFUL CHOICE OF ACTUAL DIGITAL SIGNATURES AND VERIFICATION IS CRITICAL. SELECTION OF APPROPRIATE FUNCTIONS AND IMPLEMENTATION MAY HAVE A SUBSTANTIAL IMPACT ON THE SECURITY AND PERFORMANCE OF A GAME IMPLEMENTATION.

Parameters:
signature - String
senderID - String
testhash - String
Returns:
true - Boolean - TRUE, if verification Successful, FALSE, if not.