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

SecurePlayLibrary::SPUtil Class Reference

#include <SPUtil.h>

List of all members.


Detailed Description

These are global functions and constants that can be used by various portions of the SecurePlay library. Some methods in this class wrap functions to accomodate between J2me and J2se. NOTE: Some may be simply placeholders for application specific services such as the hash, encryption, and signature functions.
Author:
IT GlobalSecure
See also:
SecurePlay License Information


Static Public Member Functions

int char62code2num (char c)
int num2char62code (int x)
string rippleadd1 (string inputstring)
string char62circadd (string str1, string str2)
string char62circsub (string str1, string str2)
int SPsmoothValue (int sampleSize, int seed, vector< int > keyArray)
string INTdelimiter ()
string MESSdelimiter ()
string INTMESSdelimiter ()
string vectorToString (vector< string > v, const string delim)
string StringArrToString (vector< string > sa, string delim)
vector< string > StringArrAddEl (vector< string > sa, string str)
vector< int > IntArrAddEl (vector< int > iarr, int i)
vector< int > arrSplice (vector< int > iarr, int pos)
vector< string > StringArrAddArr (vector< string > sa1, vector< string > sa2)
vector< string > ByteArrToStringArr (vector< byte > bt)
vector< byteStringArrToByteArr (vector< string > strarr)
vector< string > StringToStringArr (string str, string del)
int toInt (const char *str)
string toString (int i)
vector< string > StringArrRemoveEl (vector< string > sa, string str)
string BinaryToString (vector< byte > digest)
vector< byteStringToBinary (string str)
int StringToInt (const char *str)
int HexStringToInt (const string hexStg)
string IntToString (int i)
string IntToString (int i, int hexdec)
vector< byteByteArrAddEl (vector< byte > sa, byte str)
vector< byteByteArrAddArr (vector< byte > sa1, vector< byte > sa2)
vector< byteIntToByte (int i)
vector< bytesubByteArr (vector< byte > inbArr, int start, int end)
bool arrComp (vector< byte > b1, vector< byte > b2)
vector< string > addVectorToVector (vector< string > sa1, vector< string > sa2)
vector< string > VectorToStringArr (vector< string > v)
vector< string > StringArrToVector (vector< string > strArr)
vector< string > StringArrGETsubArr (vector< string > strArr, int indexStart, int indexEnd)
vector< byteByteArrGETsubArr (vector< byte > strArr, int indexStart, int indexEnd)
string LongToString (long i)
long StringToLong (string str)
bool compareStringArrays (vector< string > str1, vector< string > str2)
map< string, SPAbstractTransactionInterface * > * getTransactionRegistry ()
bool SPUregisterTransaction (string transName, SPAbstractTransactionInterface *transInstance)
vector< string > viewRegisteredTransaction ()
SPAbstractTransactionInterfacegetRegisteredTransaction (string key)
string SPgenerateKey (int keySize)
string SPtransform (string input, string gameid)
vector< bytegetHashText (string plainText, string algorithm)
string byteArrtoString (vector< byte > bt)
string toUpper (string str)
string BoolToString (bool b)
string PrivateToString (SPUEPrivatePolicy p)
vector< bytegetBytes (string s)

Static Public Attributes

string INTERNAL_COMMS = "internal"
int SP_ID_SIZE = 12
int SP_KEY_SIZE = 25
int SP_UPDATE_INTERVAL = 380
string SP_TESTSEGMENT = "THISISANONCOMMERCIALONLYSECUREPLAYLICENSEAAAAAAAAAA"
string intDel = ":"
string messDel = ";"
string interMessDell = "~"
bool RULESLOOPBACK = true

Static Private Attributes

map< string, SPAbstractTransactionInterface * > transactionRegistry = *(new map<string, SPAbstractTransactionInterface*>())


Member Function Documentation

vector< string > SPUtil::addVectorToVector vector< string >  sa1,
vector< string >  sa2
[static]
 

This method adds two vectors together.

Parameters:
v1 Vector - vector one
v2 Vector - vector two
Returns:
Vector - the combined vector

bool SPUtil::arrComp vector< byte b1,
vector< byte b2
[static]
 

This method compares two byte arrays.

Parameters:
b1 byte[] - byte array to be compared
b2 byte[] - byte array to be compared
Returns:
boolean Boolean: TRUE, if the game was created successfully, FALSE, otherwise

vector< int > SPUtil::arrSplice vector< int >  iarr,
int  pos
[static]
 

Returns a new array that removes a single element from the input Integer array at a given position

Parameters:
iarr Integer[] - the Integer array to be edited.
pos int - the position from where the element is to be removed.
Returns:
intArr - Integer[] - the Integer array that has the specified element removed.

string SPUtil::BinaryToString vector< byte digest  )  [static]
 

This method convets a byte array to a string.

Parameters:
digest byte[] - byte array to be converted
Returns:
String - the converted string.

string SPUtil::BoolToString bool  b  )  [static]
 

This function returns a string representation of a boolean.

vector< byte > SPUtil::ByteArrAddArr vector< byte sa1,
vector< byte sa2
[static]
 

This method add two byte arrays together.

Parameters:
sa1 byte[] - byte array to be added.
sa2 byte[] - byte array to be added.
Returns:
sa - byte[] - added byte array.

vector< byte > SPUtil::ByteArrAddEl vector< byte sa,
byte  str
[static]
 

This function appends a byte element to the end of the byte array.

Parameters:
sa byte[] - a byte array that needs an element to be added.
str byte - the element to be added.
Returns:
strArr[] - byte[] - the byte array with added element

vector< byte > SPUtil::ByteArrGETsubArr vector< byte strArr,
int  indexStart,
int  indexEnd
[static]
 

This method gets the sub array of a Stirng array.

Parameters:
strArr String[] - the array from which the sub array will be extracted
indexStart int - starting index.
indexEnd int - ending index.
Returns:
String[] - the sub array.

string SPUtil::byteArrtoString vector< byte bt  )  [static]
 

vector< string > SPUtil::ByteArrToStringArr vector< byte bt  )  [static]
 

Converts byte array into string array.

Parameters:
bt byte[] - byte array to be converted.
Returns:
String[]

string SPUtil::char62circadd string  str1,
string  str2
[static]
 

This function does a circular, character by character addition mod 62 assuming the strings are "right justified". This returns the result as a new string.

Parameters:
str1 String
str2 String
Returns:
resultstring - String:

string SPUtil::char62circsub string  str1,
string  str2
[static]
 

This function does a circular, character by character subtraction mod 62 assuming the strings are "right justified" this returns the result as a new string.

Parameters:
str1 String
str2 String
Returns:
resultstring - String

int SPUtil::char62code2num char  c  )  [static]
 

This function takes the character code provided and converts it to a number between 0 and 61

Parameters:
c char - a character code
Returns:
x - int - a number between 0 and 61

bool SPUtil::compareStringArrays vector< string >  str1,
vector< string >  str2
[static]
 

Compares two string arrays if they contain identical items. The order does not matter, just as long as they contain number and same strings.

Parameters:
str1 
str2 
Returns:
boolean

vector< byte > SPUtil::getBytes string  s  )  [static]
 

This function returns the byte array representation of the string passed in. NOTE: Please note there may be some issues with this function for UNICODE strings.

Parameters:
string - s
Returns:
vector<byte>

vector< byte > SPUtil::getHashText string  plainText,
string  algorithm
[static]
 

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

SPAbstractTransactionInterface * SPUtil::getRegisteredTransaction string  key  )  [static]
 

This method gets a registered Transaction object from the register list and returns it to the user.

Parameters:
key String - the name of the transaction.
Returns:
SPAbstractTransactionInterface

map< string, SPAbstractTransactionInterface * > * SPUtil::getTransactionRegistry  )  [static]
 

This method returns the transaction registry list. It is set to private because no one should be able to edit it.

Returns:
SPMap

int SPUtil::HexStringToInt const string  hexStg  )  [static]
 

This function converts a hexidecimal string to an int.

vector< int > SPUtil::IntArrAddEl vector< int >  iarr,
int  i
[static]
 

This function appends a integer element to the end of the integer array.

Parameters:
iarr Integer[] - the integer array that needs an element to be added.
i int - the element to be added.
Returns:
intArr - Integer[] - the Integer array with the added element.

string SPUtil::INTdelimiter  )  [static]
 

Returns a String delimiter1 Delimiter1 = ":" Used for serializing internal message arrays

Returns:
del - String

string SPUtil::INTMESSdelimiter  )  [static]
 

Returns a String delimiter3 Delimiter3 = "~" Used for serialising multiple messages

Returns:
String

vector< byte > SPUtil::IntToByte int  i  )  [static]
 

This method converts an integer into a byte array.

Parameters:
i int - integer to be converted
Returns:
intB - byte[] - integer that has been converted to byte.

string SPUtil::IntToString int  i,
int  hexdec
[static]
 

Integer to String.

Parameters:
i int - int number to be converted to string
Returns:
str - String - string representation of the integer number

string SPUtil::IntToString int  i  )  [static]
 

Integer to String.

Parameters:
i int - int number to be converted to string
Returns:
str - String - string representation of the integer number

string SPUtil::LongToString long  i  )  [static]
 

Long to String.

Parameters:
i int - int number to be converted to string
Returns:
str - String - string representation of the integer number

string SPUtil::MESSdelimiter  )  [static]
 

Returns a String delmiter2 Delimiter2 = ";" Used for serializing the message

Returns:
del2 - String

int SPUtil::num2char62code int  x  )  [static]
 

this function takes a numerical value between 0 and 61 and converts it to a character code from 0..9A..Za..z

Parameters:
x int - a number between 0 and 61
Returns:
c - int - a character code

string SPUtil::PrivateToString SPUEPrivatePolicy  p  )  [static]
 

This function returns a string representation of the PrivacyPolicy.

Returns:
string

string SPUtil::rippleadd1 string  inputstring  )  [static]
 

This function adds 1 to the low order character of a string. It returns the result as a returned string value the input string is from the range - 0..9A..Za..z.

Parameters:
inputstring string
Returns:
resultstring - string

string SPUtil::SPgenerateKey int  keySize  )  [static]
 

This function generates a "real" random key that is easily stored in a printable string. THIS FUNCTION SHOULD NOT BE USED FOR PRODUCTION GAMES. PLEASE USE A REAL RANDOM TOOL. THIS FUNCTION IS PROVIDED AS A SAMPLE ONLY

Parameters:
keySize int - a positive value - should be large enough to generate a good range of keys. SecurePlay library examples use 25
Returns:
generatedkey - String - a base 62 0..9A..Za..z string

int SPUtil::SPsmoothValue int  sampleSize,
int  seed,
vector< int >  keyArray
[static]
 

This is a somewhat smooth, keyed, pseudorandom number generator. It generates a result between 0 and SampleSize -1. It uses the seed to generate a range of possible outcomes and it is driven by an array keyArray. THIS FUNCTION SHOULD NOT BE USED FOR PRODUCTION GAMES. CAREFUL SELECTION OF PSEUDO-RANDOM NUMBER GENERATORS IS CRITICAL.

Parameters:
sampleSize int
seed int
keyArray Integer[]
Returns:
Positive - int - pseudorandom number.

string SPUtil::SPtransform string  input,
string  gameid
[static]
 

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

bool SPUtil::SPUregisterTransaction string  transName,
SPAbstractTransactionInterface transInstance
[static]
 

This method registers Transaction objects with so that they can be used in this library.

Parameters:
transName String - transaction name
transInstance SPAbstractTransactionInterface - the transaction object instance
Returns:
boolean

vector< string > SPUtil::StringArrAddArr vector< string >  sa1,
vector< string >  sa2
[static]
 

This method add two string arrays together.

Parameters:
sa1 String[] - string array to be added.
sa2 String[] - string array to be added.
Returns:
sa - String[] - added String array.

vector< string > SPUtil::StringArrAddEl vector< string >  sa,
string  str
[static]
 

This function appends a string element to the end of the String array.

Parameters:
sa String[] - a string array that needs an element to be added.
str String - the element to be added.
Returns:
strArr[] - String[] - the string array with added element

vector< string > SPUtil::StringArrGETsubArr vector< string >  strArr,
int  indexStart,
int  indexEnd
[static]
 

This method gets the sub array of a Stirng array.

Parameters:
strArr String[] - the array from which the sub array will be extracted
indexStart int - starting index.
indexEnd int - ending index.
Returns:
String[] - the sub array.

vector< string > SPUtil::StringArrRemoveEl vector< string >  sa,
string  str
[static]
 

This function removes a string element froma a String array.

Parameters:
sa String[] - a string array that needs an element to be removed.
str String - the element to be removed.
Returns:
strArr[] - String[] - the string array with removed element

vector< byte > SPUtil::StringArrToByteArr vector< string >  strarr  )  [static]
 

This method converts a String array to a byte array.

Parameters:
strarr String[] - string array
Returns:
byte[]

string SPUtil::StringArrToString vector< string >  sa,
string  delim
[static]
 

Parces the string array into a string with delimiters separating each array indexes

Parameters:
sa String[] - String array to be converted into a String
delim String - the delimiter that will parce the string
Returns:
str - String

vector< string > SPUtil::StringArrToVector vector< string >  strArr  )  [static]
 

This method converts a string array to a vector.

Parameters:
strArr String[] - string array to be converted
Returns:
Vector - converted vector NOTE: this is only a shell method that was written to be consistent with the java release. because c++ version uses vector<string> as string array there really is no point in converting from vector to string in C++, they are the same.

vector< byte > SPUtil::StringToBinary string  str  )  [static]
 

String to binary

Parameters:
str 
Returns:
byte[]

int SPUtil::StringToInt const char *  str  )  [static]
 

String to integer.

Parameters:
str String - string number to be converted to int.
Returns:
i - int - int type number converted from string.

long SPUtil::StringToLong string  str  )  [static]
 

String to Long.

Parameters:
str String - string number to be converted to long
Returns:
l - long - long representation of the string number

vector< string > SPUtil::StringToStringArr string  str,
string  del
[static]
 

This method converts a string to a string array using the specified delimiter.

Parameters:
str String - string to be converted.
del String - the delimiter to be used to parce the string.
Returns:
String[]

vector< byte > SPUtil::subByteArr vector< byte inbArr,
int  start,
int  end
[static]
 

This method retrieves the specified sub array of a byte array passed in.

Parameters:
inbArr byte[] - byte array to be subed from.
start int - start index of the sub array.
end int - end index of the sub array.
Returns:
subArr - byte[] - the sub array.

int SPUtil::toInt const char *  str  )  [static]
 

Converts a string representaion of an integer to Integer class.

Parameters:
str - String - string representaion of an integer
Returns:
integer - Integer NOTE: remember to use c_str() when feeding the string. EX: string s = "123"; toInt(s.c_str());

string SPUtil::toString int  i  )  [static]
 

Converts an integer to string.

Parameters:
i - int
Returns:
str - String

string SPUtil::toUpper string  str  )  [static]
 

string SPUtil::vectorToString vector< string >  v,
const string  delim
[static]
 

Concatinates the objects in a Vector into a string using a delimiter.

Parameters:
v Vector - Vector to be converted
delim String - delimiter to be used

vector< string > SPUtil::VectorToStringArr vector< string >  v  )  [static]
 

This method converts a Vector to a string array.

Parameters:
v Vector - vector to be converted
Returns:
String[]- converted String array NOTE: this is only a shell method that was written to be consistent with the java release. because c++ version uses vector<string> as string array there really is no point in converting from vector to string in C++, they are the same.

vector< string > SPUtil::viewRegisteredTransaction  )  [static]
 

This method allows users to see what transactions have been registered.

Returns:
String[]


Member Data Documentation

string SPUtil::intDel = ":" [static]
 

Delimiter1 = : Used for serializing internal message arrays

string SPUtil::interMessDell = "~" [static]
 

Delimeter3 = ~ Used for serializing multiple messages

string SPUtil::INTERNAL_COMMS = "internal" [static]
 

Comms internal

string SPUtil::messDel = ";" [static]
 

Delimiter2 = ; Used for serializing the message

bool SPUtil::RULESLOOPBACK = true [static]
 

This should be set to FALSE for production systems or all "rulesXXXX methods should be edited

int SPUtil::SP_ID_SIZE = 12 [static]
 

used to set the default size of generated IDs - default is 12

int SPUtil::SP_KEY_SIZE = 25 [static]
 

This parameter is used to set game key size. Default is 25.

string SPUtil::SP_TESTSEGMENT = "THISISANONCOMMERCIALONLYSECUREPLAYLICENSEAAAAAAAAAA" [static]
 

This Constant is used to generate a Game Segment ID for sample code.

int SPUtil::SP_UPDATE_INTERVAL = 380 [static]
 

This parameter is used to force an update check - only necessary for polling communications. Default is 3800.

map< string, SPAbstractTransactionInterface * > SPUtil::transactionRegistry = *(new map<string, SPAbstractTransactionInterface*>()) [static, private]
 

Varialbe that stores all the registered transactions


The documentation for this class was generated from the following files: 2006 Copyright Filed by IT GlobalSecure, Inc. All Rights Reserved. Not to be used without authorization by Author. SecurePlay, IT GlobalSecure, and IT Armor are registered trademarks by IT GlobalSecure, Inc. Software protected by software license, and one or more the following U.S. and International patent numbers: U.S. Patent 6,030,288, U.S. Patent 6,165,072, European Patent Office EP1016049A1,and World Intellectual Property Organization WO9912135C1 and additional filings worldwide.