Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

SecurePlayLibrary::SPGameClass Class Reference

#include <SPGameClass.h>

Inheritance diagram for SecurePlayLibrary::SPGameClass:

SecurePlayLibrary::SPRootTransactionClass SecurePlayLibrary::SPGameInterface List of all members.

Detailed Description

This is the general class that holds a game instance. It is also the transaction class for the basic game transaction.
Author:
IT GlobalSecure
See also:
SecurePlay License Information


Public Member Functions

 SPGameClass ()
 ~SPGameClass ()
 SPGameClass (string gameID, string master, bool signaturepolicy, bool encryptionpolicy, SecurePlayClass *SPlibobj, SPLogInterface *log, SPSecurityManagerInterface *security)
void initializegame (string gameID, string master, bool signaturepolicy, bool encryptionpolicy, SecurePlayClass *SPlibobj, SPLogInterface *log, SPSecurityManagerInterface *security)
bool attach (string gid, SecurePlayClass *lib, string master, bool signaturepolicy, bool encryptionpolicy, SPLogInterface *log, SPSecurityManagerInterface *security)
SPGameAPIInterfacegetGameAPI ()
bool addPlayer (string pid)
bool removePlayer (string pid)
bool setPlayerComms (string playerID, string commsID, bool relayflag)
SPPlayerInterfacegetGamePlayer (string playerID)
void prUpdateGameStatus ()
bool gameComplete ()
bool addComms (string commsID)
bool removeComms (string commsID)
bool addTransaction (SPAbstractTransactionInterface *transObj)
bool closeTransaction (string transID)
SPAbstractTransactionInterfacegetGameTransaction (string tid)
string prsetTransactionID (SPAbstractTransactionInterface *transObj)
bool transactionincluded (string tid)
bool onbeginGame (SPMessageClass *messObj)
bool onendGame (SPMessageClass *messObj)
void onrequestbeginGame (SPMessageClass *messObj)
void onrequestendGame (SPMessageClass *messObj)
bool updateGameSegment (string currentseg, string nextseg)
bool incrementBasicGameTransactionCount (int count)
bool onnextGameSegmentID (SPMessageClass *messObj)
void onIncomingTransaction (SPMessageClass *messObj)
bool isPlayerInternal (string pid)
void logError ()
bool sendMessage (string sender, vector< string > receivers, bool encryptflag, bool privateflag, string messagetype, vector< string > messagebody, vector< string > altmessage)
SPCommsManagerClassgetCommsManager ()
SecurePlayClassgetSecurePlay ()
string getGamestatus ()
vector< string > getOpentransactionIDList ()
vector< SPAbstractTransactionInterface * > getTransactions ()
int getBasicGameTransactionCount ()
string getCurrentGameSegment ()
int getGameSegmentCount ()
string getNextGameSegment ()
vector< SPPlayerInterface * > getPlayers ()
int getPreloadGameSegment ()
SPSecurityManagerInterfacegetSecurityManager ()
vector< bytegetHashText (string plainText, string algorithm)
vector< byteSPcreateBHash (string input, string gameid)
vector< byteSPcreateBSignature (string senderID, vector< byte > input, string gameid)
string SPcreateHash (string input, string gameid)
string SPcreateSignature (string senderID, string input, string gameid)
vector< string > SPdecrypt (vector< string > input, string senderID, vector< string > recvrs, string gameID, string messageID)
vector< string > SPencrypt (vector< string > input, string senderID, vector< string > recvrs, string gameID, string messageID)
string SPtransform (string input, string gameid)
bool SPverifySignature (vector< byte > sigToVerify, string senderID, vector< byte > testhash, string gameid)
bool SPverifySignature (string signature, string senderID, string testhash, string gameid)
string getGameID ()
string getTransactionID ()
string getMaster ()
vector< string > getPlayerIDList ()
void SPnotify (string eventdescription, vector< string > args)

Public Attributes

const string extendedversion
const string releaseversion

Private Member Functions

 SPGameClass (const SPGameClass &p)
 operator= (const SPGameClass &p)

Private Attributes

SPRootTransactionClassroot
SPGameAPIInterfaceclassAPI
SPCommsManagerClasscomms
map< string, SPPlayerInterface * > prplayerList
map< string, SPAbstractTransactionInterface * > propentransactionList
vector< string > opentransactionIDList
string prcurrentGameSegment
string prnextGameSegment
int prpreloadGameSegment
int prgamesegmentcount
int prBasicGameTransactionCount
string gamestatus
string gameready
SecurePlayClasssecureplay


Constructor & Destructor Documentation

SecurePlayLibrary::SPGameClass::SPGameClass const SPGameClass p  )  [inline, private]
 

Private Copy Constructor that protects this class from being copied.

SPGameClass::SPGameClass  ) 
 

Default Constructor.

SPGameClass::~SPGameClass  ) 
 

Default Destructor.

SPGameClass::SPGameClass string  gameID,
string  master,
bool  signaturepolicy,
bool  encryptionpolicy,
SecurePlayClass SPlibobj,
SPLogInterface log,
SPSecurityManagerInterface security
 

Constructs an overloaded SPGameClass()

Parameters:
gameID string - id of the game
master string - id of the player who will be the master of this game
signaturepolicy bool - signature policy
encryptionpolicy bool - encryption policy
SecurePlayClass* - secure play library in which the game will be created.
log SPLogInterface* - log of this game.
security SPSecurityManagerInterface* - security manager of this game


Member Function Documentation

bool SPGameClass::addComms string  commsID  )  [virtual]
 

This method associates a comms service specified by the commsID string to a game instance.

Parameters:
commsID string - id of the comms to be added
Returns:
bool: TRUE, if gamestatus is "complete", FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::addPlayer string  pid  )  [virtual]
 

This method safely adds an existing Player, specified by the playerID to the game instance.

Parameters:
pid string - the id of the player to be added
Returns:
bool: TRUE, if successful, FALSE, if no

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::addTransaction SPAbstractTransactionInterface transObj  )  [virtual]
 

This safely adds a transaction to a game instance and appropriately updates the game state.

Parameters:
transObj SPAbstractTransactionInterface - the transaction Object handler
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::attach string  gid,
SecurePlayClass lib,
string  master,
bool  signaturepolicy,
bool  encryptionpolicy,
SPLogInterface log,
SPSecurityManagerInterface security
[virtual]
 

This method attaches an empty game object instance and configures it for use in the SecurePlay library as a game with default comms

Parameters:
gid string - game id
lib SecurePlayClass - the secure play library
master string - the master of the game
signaturepolicy bool - signature policy
encryptionpolicy bool - encryption policy
log SPLogInterface* - log of this game.
security SPSecurityManagerInterface* - security manager of this game
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::closeTransaction string  transID  )  [virtual]
 

Safely removes a transaction from a game instance.

Parameters:
transID string - the id of the transaction to be closed
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::gameComplete  )  [virtual]
 

This method allows external entities to review the status of the game instance without directly accessing its internals.

Returns:
bool: TRUE, if gamestatus is "complete", FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

int SPGameClass::getBasicGameTransactionCount  ) 
 

Getter function that returns the property: prBasicGameTransactionCount

Returns:
int

SPCommsManagerClass * SPGameClass::getCommsManager  )  [virtual]
 

This method returns the unique Comms Manager object associated with the game instance

Returns:
SPCommsManagerClass* - the comms manager

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::getCurrentGameSegment  ) 
 

Getter function that returns the property: prcurrentGameSegment

Returns:
string

SPGameAPIInterface * SPGameClass::getGameAPI  )  [virtual]
 

This method returns the handler for the Game API object.

Returns:
SPGameAPIInterface - Game API object handler

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::getGameID  )  [virtual]
 

Gets the game id

Returns:
string - the game id

Implements SecurePlayLibrary::SPGameInterface.

SPPlayerInterface * SPGameClass::getGamePlayer string  playerID  )  [virtual]
 

This method returns the player object specified by the playerID.

Parameters:
playerID string - the id of the player to get
Returns:
SPPlayerInterface* - the game player object handler or an empty instance of the class, if the player is not present

Implements SecurePlayLibrary::SPGameInterface.

int SPGameClass::getGameSegmentCount  ) 
 

Getter function that returns the property: prgamesegmentcount

Returns:
int

string SPGameClass::getGamestatus  ) 
 

Getter function that returns the property: gamestatus

Returns:
string

SPAbstractTransactionInterface * SPGameClass::getGameTransaction string  tid  )  [virtual]
 

This method returns a specific transaction associated with a given game instance.

Parameters:
tid string - identifier for transaction object
Returns:
SPAbstractTransactionInterface*

Implements SecurePlayLibrary::SPGameInterface.

vector< byte > SPGameClass::getHashText string  plainText,
string  algorithm
 

This is a wrapper function for creating a hash of a string. This reference implementation includes a MD5 hash.

Parameters:
input string
gameid string
Returns:
vector<byte> - Hash of input

string SPGameClass::getMaster  )  [virtual]
 

Gets the master of the transaction or game

Returns:
string - returns the id of the master

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::getNextGameSegment  ) 
 

Getter function that returns the property: prnextGameSegment

Returns:
string

vector< string > SPGameClass::getOpentransactionIDList  ) 
 

Getter function that returns the open transaction IDs

Returns:
vector<string>

vector< string > SPGameClass::getPlayerIDList  )  [virtual]
 

Gets the player id list of the players associated with the transaction or the game.

Returns:
vector<string> - players associated with a game or transaction in a string array.

Implements SecurePlayLibrary::SPGameInterface.

vector< SPPlayerInterface * > SPGameClass::getPlayers  ) 
 

Getter function that returns the players from prplayerlist

Returns:
vector<SPPlayerInterface*>

int SPGameClass::getPreloadGameSegment  ) 
 

Getter function that returns the property: prpreloadGameSegment

Returns:
int

SecurePlayClass * SPGameClass::getSecurePlay  )  [virtual]
 

This method returns the unique SecurePlay library object associated with the game instance object.

Returns:
SecurePlayClass* - the secure play class associated with this game.

Implements SecurePlayLibrary::SPGameInterface.

SPSecurityManagerInterface * SPGameClass::getSecurityManager  )  [virtual]
 

This method returns the security manager class associated with this game.

Returns:
SPSecurityManagerInterface*

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::getTransactionID  )  [virtual]
 

Gets the transaction id.

Returns:
string - the transaction id

Implements SecurePlayLibrary::SPGameInterface.

vector< SPAbstractTransactionInterface * > SPGameClass::getTransactions  ) 
 

Getter function that returns the transactions from propentransactionlist

Returns:
vector<SPAbstractTransactionInterface*>

bool SPGameClass::incrementBasicGameTransactionCount int  count  )  [virtual]
 

This method increments the game’s transaction counter to support certain licensing models

Parameters:
count int - number of increments
Returns:
bool TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

void SPGameClass::initializegame string  gameID,
string  master,
bool  signaturepolicy,
bool  encryptionpolicy,
SecurePlayClass SPlibobj,
SPLogInterface log,
SPSecurityManagerInterface security
 

Configures a new game.

Parameters:
gameID string - id of the game
master string - id of the player who will be the master of this game
signaturepolicy bool - signature policy
encryptionpolicy bool - encryption policy
SPlibobj SecurePlayClass - secure play library in which the game will be created.
log SPLogInterface* - log of this game.
security SPSecurityManagerInterface* - security manager of this game

bool SPGameClass::isPlayerInternal string  pid  )  [virtual]
 

Checks to see if the player is internal

Parameters:
pid string - id of the player to be checked
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

void SPGameClass::logError  ) 
 

This method is a placeholder for future internal logging

bool SPGameClass::onbeginGame SPMessageClass messObj  ) 
 

This method handles requests to begin the local game. It ensures that the game is ready to be played, and, if so, updates the local game state appropriately.

Parameters:
messObj SPMessageClass* - incoming Message Object
Returns:
bool: TRUE, if successful, FALSE, if not.

bool SPGameClass::onendGame SPMessageClass messObj  )  [virtual]
 

This method safely ends the local game instance.

Parameters:
messObj SPMessageClass* - incoming Message Object
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

void SPGameClass::onIncomingTransaction SPMessageClass messObj  )  [virtual]
 

This method is the generic handler for incoming Game transaction methods.

Parameters:
messObj SPMessageClass* - incoming Message Object

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::onnextGameSegmentID SPMessageClass messObj  ) 
 

This method supports the SecurePlay licensing system to maintain synchronization of game segment IDs within a game. Deletion, modification, or circumvention of this software functionality is in violation of the SecurePlay license.

Parameters:
messObj SPMessageClass* - incoming Message Object
Returns:
bool: TRUE, if successful, FALSE, if not

void SPGameClass::onrequestbeginGame SPMessageClass messObj  ) 
 

This method handles incoming requests to begin a game It passes the requests on to the API rules parser.

Parameters:
messObj SPMessageClass* - incoming Message Object

void SPGameClass::onrequestendGame SPMessageClass messObj  ) 
 

This method passes a request to end a game on to the game master's rule parser.

Parameters:
messObj SPMessageClass* - incoming Message Object

SecurePlayLibrary::SPGameClass::operator= const SPGameClass p  )  [inline, private]
 

Private = operator that protects this class from being copied.

string SPGameClass::prsetTransactionID SPAbstractTransactionInterface transObj  ) 
 

This method generates a transactionID for a transaction object

Parameters:
transObj SPAbstractTransactionInterface* - the transaction object from which the id is retrieved
Returns:
string - the transaction id

void SPGameClass::prUpdateGameStatus  ) 
 

This method does a self-check on the game instance object and updates its status appropriately. Mainly, it is used to lock the game when changes are occuring or if an error has occured.

bool SPGameClass::removeComms string  commsID  )  [virtual]
 

This method removes the association of a communications service with a game instance.

Parameters:
commsID string - id of the comms to be removed
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::removePlayer string  pid  )  [virtual]
 

This method safely removes a Player instance from an existing Game Instance.

Parameters:
pid string - id of the player to be removed
Returns:
bool: TRUE, if successful, FALSE, if not.

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::sendMessage string  sender,
vector< string >  receivers,
bool  encryptflag,
bool  privateflag,
string  messagetype,
vector< string >  messagebody,
vector< string >  altmessage
 

This method actually constructs messages to be sent by the Game object to other game object instances via the Comms Manager

Parameters:
sender - id of the sender
receivers - ids of the recievers of the message
encryptflag - encryption flag
privateflag - private flag
messagetype - the type of message
messagebody - the message body
altmessage - alternative message
Returns:
bool: TRUE, if successful, FALSE, if not

bool SPGameClass::setPlayerComms string  playerID,
string  commsID,
bool  relayflag
[virtual]
 

This method associates a specific player instance, specified by the playerID, with a specific communications service, specified by the commsID. For certain remote players, a relay service is supported to allow messages to be forwarded. NOTE: there is a reserved comms service "internal" for player instances that are included in the local application session.

Parameters:
playerID string - id of the player to be added
commsID string - id of the comms object to be added
relayflag bool - relay flag
Returns:
bool: TRUE, if successful, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

vector< byte > SPGameClass::SPcreateBHash string  input,
string  gameid
[virtual]
 

This is a wrapper function for creating a hash of a string. This reference implementation includes a MD5 hash.

Parameters:
input string
Returns:
string - Hash of input

Implements SecurePlayLibrary::SPGameInterface.

vector< byte > SPGameClass::SPcreateBSignature string  senderID,
vector< byte input,
string  gameid
[virtual]
 

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:
vector<byte> - digital signature of hashstring signed by senderID.

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::SPcreateHash string  input,
string  gameid
[virtual]
 

This is a wrapper function for creating a hash of a string. This reference implementation includes a MD5 hash.

Parameters:
input string
Returns:
string - Hash of input

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::SPcreateSignature string  senderID,
string  input,
string  gameid
[virtual]
 

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:
string - digital signature of hashstring signed by senderID.

Implements SecurePlayLibrary::SPGameInterface.

vector< string > SPGameClass::SPdecrypt vector< string >  input,
string  senderID,
vector< string >  recvrs,
string  gameID,
string  messageID
[virtual]
 

This is a placeholder for an decryption function. An actual encryption function is the responsibility of the game implementer.

Parameters:
input vector<string> - input message body to be decrypted
senderID string - sender id
recvrs vector<string> - receiver id list
gameID string - game id
messageID string - message id
Returns:
vector<string> - string array of decrypted messagebody.

Implements SecurePlayLibrary::SPGameInterface.

vector< string > SPGameClass::SPencrypt vector< string >  input,
string  senderID,
vector< string >  recvrs,
string  gameID,
string  messageID
[virtual]
 

This is a placeholder for an encryption function. An actual encryption function is the responsibility of the game implementer.

Parameters:
input vector<string> - message body to be encrypted
senderID string - sender id
recvrs vector<string> - receiver id list
gameID string - game id
messageID string - message id
Returns:
vector<string> - Encrypted message body

Implements SecurePlayLibrary::SPGameInterface.

void SPGameClass::SPnotify string  eventdescription,
vector< string >  args
[virtual]
 

This method notifies the Listeners of events

Parameters:
eventdescription 
vector<string> - arguments

Implements SecurePlayLibrary::SPGameInterface.

string SPGameClass::SPtransform string  input,
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:
string

bool SPGameClass::SPverifySignature string  signature,
string  senderID,
string  testhash,
string  gameid
[virtual]
 

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:
bool - TRUE, if verification Successful, FALSE, if not.

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::SPverifySignature vector< byte sigToVerify,
string  senderID,
vector< byte testhash,
string  gameid
[virtual]
 

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 vector<byte>
senderID string
testhash string
Returns:
bool - TRUE, if verification Successful, FALSE, if not.

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::transactionincluded string  tid  )  [virtual]
 

This method checks the specified transaction ID against the currently included transaction IDs in the game instance.

Parameters:
tid string - the id of the transaction in question
Returns:
result bool: TRUE, if included, FALSE, if not

Implements SecurePlayLibrary::SPGameInterface.

bool SPGameClass::updateGameSegment string  currentseg,
string  nextseg
 

This method supports the administration of game segment IDs and counters. It is part of the SecurePlay licensing system. No deletion, modification, or circumvention is allowed without explicit permission as detailed in the SecurePlay license.

Parameters:
currentseg string - current segment
nextseg string - next segment
Returns:
bool: TRUE, if successful, FALSE, if not


Member Data Documentation

SPGameAPIInterface* SecurePlayLibrary::SPGameClass::classAPI [private]
 

This is the same as prapi, it is being remapped to be consistent with the other classes.

SPCommsManagerClass* SecurePlayLibrary::SPGameClass::comms [private]
 

This is the SPcomms instance associated with the game instance. It is used to access the communications manager services to send and receive and process messages.

const string SecurePlayLibrary::SPGameClass::extendedversion
 

Developer extended version.

Reimplemented from SecurePlayLibrary::SPRootTransactionClass.

string SecurePlayLibrary::SPGameClass::gameready [private]
 

this variable was created because we were not sure if it was a bug and should have been gamestatus, it will be clear after we test it

string SecurePlayLibrary::SPGameClass::gamestatus [private]
 

This provides the current status of the game instance. The currenlty supported status strings are: "new" is a newly instantiateed game instance "ready" is ready to play (create transactions) "updating" is changing player or comms information "complete" is game over "error" is a hung game

vector<string> SecurePlayLibrary::SPGameClass::opentransactionIDList [private]
 

This property provides access to the open transaction IDs. This is the virtual method to access transactions.

int SecurePlayLibrary::SPGameClass::prBasicGameTransactionCount [private]
 

The basic game transaction count is a count of the total number of qualified basic game transactions in the game. It is required for conforming to the SecurePlay license. Unauthorized modification, circumvention, or removal is not permitted.

string SecurePlayLibrary::SPGameClass::prcurrentGameSegment [private]
 

This property should not be accessed directly. Modification of the game segment property or alteration of its usage is a violation of the SecurePlay license agreement.

int SecurePlayLibrary::SPGameClass::prgamesegmentcount [private]
 

This is the count of game segments within a game instance. This is part of the SecurePlay licensing system. Modification, circumvention, or removal of this property or its associated methods is a violation of the SecurePlay license.

string SecurePlayLibrary::SPGameClass::prnextGameSegment [private]
 

This is the preloaded identifier for the next Game Segment. Modification, deletion, or circumvention of this property or its associated methods is a violation of the SecurePlay license.

map<string, SPAbstractTransactionInterface*> SecurePlayLibrary::SPGameClass::propentransactionList [private]
 

This is the associative array that holds the transaction object pointers.

map<string, SPPlayerInterface*> SecurePlayLibrary::SPGameClass::prplayerList [private]
 

This is the associative array that holds the player objects that are participating in the game instance.

int SecurePlayLibrary::SPGameClass::prpreloadGameSegment [private]
 

This is a positive integer that specifies how early to preload a new game segment ID string. Modification, circumvention, or deletion of this property or its associated methods is a violation of the SecurePlay license.

const string SecurePlayLibrary::SPGameClass::releaseversion
 

IT GlobalSecure release version.

Reimplemented from SecurePlayLibrary::SPRootTransactionClass.

SPRootTransactionClass* SecurePlayLibrary::SPGameClass::root [private]