Thread: [ActiveLock-Development] CVS: activelock2/src ActiveLock.cls,1.11,1.12 ActiveLockEventNotifier.cls,1
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2003-08-03 08:38:16
|
Update of /cvsroot/activelock/activelock2/src In directory sc8-pr-cvs1:/tmp/cvs-serv7316 Modified Files: ActiveLock.cls ActiveLockEventNotifier.cls Globals.cls IActiveLock.cls IKeyStoreProvider.cls ProductLicense.cls Log Message: - VBDox'ed publicly accesible classes. - Corrected typo: ActiveLockErrCodeConstants.alerrLockChanged -> ActiveLockErrCodeConstants.alerrClockChanged, Index: ActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLock.cls,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- ActiveLock.cls 2 Aug 2003 08:07:23 -0000 1.11 +++ ActiveLock.cls 3 Aug 2003 08:38:11 -0000 1.12 @@ -43,9 +43,8 @@ '* '' -' This is an unsecure implementation of IActiveLock, and hence it -' needs to be private. Access to this class from the outside world is -' brokered via the ActiveLockAgent object. +' This is an implementation of IActiveLock. It is not public-creatable, and so must only +' be accessed via ActiveLock.NewInstance() method. ' ' @author th...@us... ' @version 2.0.0 @@ -55,19 +54,23 @@ ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// ' -' [ ] Implement IActiveLock_Release -' [ ] Implement IActiveLock_Transfer -' -' /////////////////////////////////////////////////////////////////////// +' @todo Implement IActiveLock_Release. Not sure what if anything needs to be +' done here. +' @todo Implement IActiveLock_Transfer. This is the functionality to transfer +' a license from one machine to another. + +'* /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// -' -' 07.07.03 - mcrute - Updated the header comments for this file. -' 07.28.03 - th2tran - Using RSA signature for license key. -' 07.28.03 - wizzardme2000 - Implemented lockComp, lockHD, and lockWindows -' 07.31.03 - th2tran - Perform checksum on ALCrypto.dll on Init() -' - ValidateKey() to bypass checking expiry -' if there's no expiration date. +' @history +' <pre> +' 07.07.03 - mcrute - Updated the header comments for this file. +' 07.28.03 - th2tran - Using RSA signature for license key. +' 07.28.03 - wizzardme2000 - Implemented lockComp, lockHD, and lockWindows +' 07.31.03 - th2tran - Perform checksum on ALCrypto.dll on Init() +' - ValidateKey() to bypass checking expiry if there's no expiration date. +' </pre> + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -107,9 +110,9 @@ Private Sub IActiveLock_Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) ' Checksum ALCrypto.dll Const ALCRYPTO_MD5$ = "ac0dd6351905e6d688199146165170c4" - Dim strdata As String, strMD5 As String - Call modActiveLock.ReadFile(App.path & "\ALCrypto.Dll", strdata) - strMD5 = modMD5.Hash(strdata) ' use our own MD5 hashing routine instead of ALCrypto's md5_hash() function. + Dim strData As String, strMD5 As String + Call modActiveLock.ReadFile(App.Path & "\ALCrypto.Dll", strData) + strMD5 = modMD5.Hash(strData) ' use our own MD5 hashing routine instead of ALCrypto's md5_hash() function. If strMD5 <> ALCRYPTO_MD5 Then Err.Raise ActiveLockErrCodeConstants.alerrFileTampered, "IActiveLock_Acquire", "ALCrypto.dll has been tampered." End If @@ -196,7 +199,7 @@ ' try to detect the user setting their system clock back If Now < CDate(Lic.LastUsed) Then ' TODO: Need to account for Daylight Savings Time - Err.Raise ActiveLockErrCodeConstants.alerrLockChanged, "ActiveLock2", "License invalid. You have set your system clock backward!" + Err.Raise ActiveLockErrCodeConstants.alerrClockChanged, "ActiveLock2", "License invalid. You have set your system clock backward!" End If UpdateLastUsed Lic mKeyStore.Store Lic Index: ActiveLockEventNotifier.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ActiveLockEventNotifier.cls,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ActiveLockEventNotifier.cls 28 Jul 2003 06:35:30 -0000 1.3 +++ ActiveLockEventNotifier.cls 3 Aug 2003 08:38:11 -0000 1.4 @@ -75,6 +75,8 @@ '' ' ProductLicense Property Value validation event allows the client application ' to return the encrypted version of a license property value. +' The client will receive this event, encrypt <code>Value</code> using its own encryption algorithm, +' and store the result in <code>Result</code> to be returned to ActiveLock. ' @param Value Property value. ' @param Result Encrypted value. Public Event ValidateValue(ByVal Value As String, Result As String) Index: Globals.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/Globals.cls,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Globals.cls 2 Aug 2003 08:07:23 -0000 1.11 +++ Globals.cls 3 Aug 2003 08:38:11 -0000 1.12 @@ -44,6 +44,10 @@ '' ' This class contains global object factory and utility methods. +' It is a global class so its routines in here can be accessed directly +' from the ActiveLock2 namespace. +' For example, the <code>NewInstance()</code> routine can be access via +' <code>ActiveLock2.NewInstance()</code>. ' ' @author th...@us... ' @version 2.0.0 @@ -52,13 +56,14 @@ '* /////////////////////////////////////////////////////////////////////// ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// +' @todo GetLicTypeString() - Implement this fully. ' -' [ ] GetLicTypeString() - implement this -' + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// -' +' @history +' <pre> ' 07.07.03 - mcrute - Updated the header comments for this file. ' 07.21.03 - th2tran - Added ActiveLockErrCodeConstants to contain ' a list of error code constants raised by ActiveLock. @@ -66,36 +71,32 @@ ' 07.31.03 - th2tran - Added alerrFileTampered ' - CreateProductLicense() to ignore Expiration date ' for Permanent license type -' +' 08.03.03 - th2tran - VBDox'ed this class. +' </pre> ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// Option Explicit '' -' This class contains global object factory and utility methods. -' -' @author th2tran -' @version 2.0.0 -' @date 20030616 -' - - -'' ' ActiveLock Error Codes ' ' @param alerrOK No error. Operation was successful. +' @param alerrNoLicense No license available. ' @param alerrLicenseInvalid License is invalid. ' @param alerrLicenseExpired License has expired. -' @param alerrKeyStoreInvalid Key Store Provider hasn't been initialized yet. -' @param alerrNoLicense No license available. +' @param alerrLicenseTampered License has been tampered. +' @param alerrClockChanged System as been set back. +' @param alerrKeyStoreInvalid Key Store Provider has not been initialized yet. +' @param alerrFileTampered License file has been tampered. +' @param alerrNotInitialized ActiveLock has not been initialized yet. Public Enum ActiveLockErrCodeConstants alerrOK = 0 ' successful alerrNoLicense = &H80040001 ' vbObjectError (&H80040000) + 1 alerrLicenseInvalid = &H80040002 alerrLicenseExpired = &H80040003 alerrLicenseTampered = &H80040004 - alerrLockChanged = &H80040005 + alerrClockChanged = &H80040005 alerrKeyStoreInvalid = &H80040010 alerrFileTampered = &H80040011 alerrNotInitialized = &H80040012 @@ -103,6 +104,7 @@ '' ' Returns a new instance of an object that implements IActiveLock interface. +' @param Args Optional list of parameters. ' Public Function NewInstance(Optional Args As Variant) As IActiveLock 'TODO: Add parameters as appropriate Dim NewInst As IActiveLock @@ -118,7 +120,18 @@ ' Instantiates a new ProductLicense object. ' If LicType is "Permanent", then Expiration date parameter will be ignored. ' -Public Function CreateProductLicense(name As String, _ +' @param Name Product/Software Name +' @param Code Product/Software Code +' @param Ver Product version +' @param Licclass License class +' @param LicType License type +' @param Licensee Registered party for which the license has been issued +' @param Expiration Expiration date +' @param LicKey License key +' @param RegisteredDate Date on which the product is registered +' @param Hash1 Hash-1 code +' +Public Function CreateProductLicense(Name As String, _ Code As String, _ Ver As String, _ LicClass As ActiveLock2.ALLockTypes, _ @@ -131,7 +144,7 @@ ) As ProductLicense Dim NewLic As New ProductLicense With NewLic - .ProductName = name + .ProductName = Name .ProductKey = Code .ProductVer = Ver .LicenseClass = GetClassString(LicClass) @@ -173,6 +186,8 @@ '' ' Returns a string version of LicType ' +' @param LicType License Type +' Private Function GetLicTypeString(LicType As ALLicType) As String 'TODO: Implement this properly. GetLicTypeString = "Single" @@ -180,12 +195,14 @@ '' ' Trim Null characters from the string. +' @param str String to be trimmed. ' Public Function TrimNulls(str As String) As String TrimNulls = modActiveLock.TrimNulls(str) End Function '' ' Computes an MD5 hash of the specified string. +' @param str String to be hashed. ' Public Function MD5Hash(str As String) As String MD5Hash = modMD5.Hash(str) @@ -193,6 +210,7 @@ '' ' Base-64 encode the specified string. +' @param str String to be encoded ' Public Function Base64Encode(str As String) As String Base64Encode = modBase64.Base64_Encode(str) @@ -200,6 +218,7 @@ '' ' Base-64 decode the string. +' @param strEncoded String to be decoded ' Public Function Base64Decode(strEncoded As String) As String Base64Decode = modBase64.Base64_Decode(strEncoded) @@ -207,16 +226,20 @@ '' ' Performs RSA signing of strData using the specified key. +' @param strPub Public key blob +' @param strPriv Private key blob +' @param strData Data to be signed +' @return Signature string. ' -Public Function RSASign(strPub As String, strPriv As String, strdata As String) As String +Public Function RSASign(strPub As String, strPriv As String, strData As String) As String Dim Key As RSAKey ' create the key from the key blobs modActiveLock.rsa_createkey strPub, Len(strPub), strPriv, Len(strPriv), Key ' sign the data using the created key Dim sLen& - rsa_sign Key, strdata, Len(strdata), vbNullString, sLen + rsa_sign Key, strData, Len(strData), vbNullString, sLen Dim strSig As String: strSig = String(sLen, 0) - modActiveLock.rsa_sign Key, strdata, Len(strdata), strSig, sLen + modActiveLock.rsa_sign Key, strData, Len(strData), strSig, sLen ' throw away the key modActiveLock.rsa_freekey Key RSASign = strSig @@ -224,14 +247,18 @@ '' ' Verifies an RSA signature. +' @param strPub Public key blob +' @param strData Data to be signed +' @param strSig Private key blob +' @return Zero if verification is successful; Non-zero otherwise. ' -Public Function RSAVerify(strPub As String, strdata As String, strSig As String) As Long +Public Function RSAVerify(strPub As String, strData As String, strSig As String) As Long Dim Key As RSAKey Dim rc& ' create the key from the public key blob rsa_createkey strPub, Len(strPub), vbNullString, 0, Key ' validate the key - rc = rsa_verifysig(Key, strSig, Len(strSig), strdata, Len(strdata)) + rc = rsa_verifysig(Key, strSig, Len(strSig), strData, Len(strData)) ' de-allocate memory used by the key rsa_freekey Key RSAVerify = rc Index: IActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IActiveLock.cls,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- IActiveLock.cls 28 Jul 2003 06:35:30 -0000 1.6 +++ IActiveLock.cls 3 Aug 2003 08:38:11 -0000 1.7 @@ -43,8 +43,126 @@ '* '' -' This is the interface by which all ActiveLock implemenations must -' adhere. +' This is the main interface into ActiveLock. +' The user program interacts with ActiveLock via this IActiveLock interface. +' Typically, the user program would obtain an instance of this interface via the +' <code>ActiveLock2.NewInstance()</code> accessor method. From there, initialization calls are taken +' place, and then various method such as <code>Register()</code>, <code>Acquire()</code>, etc..., can be used. +' ActiveLock also sends event notifications to to the user program whenever it needs the +' user program's help to perform some action, such as parameter validation. These events +' are sent via the ActiveLockEventNotifier object, which can be obtained from IActiveLock_Notifier() +' accessor method. +' <p> +' <b>Important!</b> It is also strongly recommended that a checksum on ActiveLock2.dll be performed +' prior to accessing and interacting with ActiveLock. See sample code below on how it is done. +' <p> The sample code below illustrates of how this interface is used. +' <pre> +' Form1.frm: +' ... +' Private MyActiveLock As ActiveLock2.IActiveLock +' Private WithEvents ActiveLockEventSink As ActiveLockEventNotifier +' Private Const AL_CRC& = 308603 '' ActiveLock2.dll's CRC checksum to be used for validation +'<br> +' '' This RSA private key will be used for data encryption and/or license key signing. +' Private Const PRIV_KEY$ = "AAAAgEPRFzhQEF7S91vt2K6kOcEdDDe5BfwNiEL30/+ozTFHc7cZctB8NIlS++ZR//D3AjSMqScjh7xUF/gwvUgGCjiExjj1DF/XWFWnPOCfF8UxYAizCLZ9fdqxb1FRpI5NoW0xxUmvxGjmxKwazIW4P4XVi/+i1Bvh2qQ6ri3whcsNAAAAQQCyWGsbJKO28H2QLYH+enb7ehzwBThqfAeke/Gv1Te95yIAWme71I9aCTTlLsmtIYSk9rNrp3sh9ItD2Re67SE7AAAAQQCAookH1nws1gS2XP9cZTPaZEmFLwuxlSVsLQ5RWmd9cuxpgw5y2gIskbL4c+4oBuj0IDwKtnMrZq7UfV9I5VfVAAAAQQCEnyAuO0ahXH3KhAboop9+tCmRzZInTrDYdMy23xf3PLCLd777dL/Y2Y+zmaH1VO03m6iOog7WLiN4dCL7m+Im" +' '' This RSA public key will be used as the product's software code. +' Private Const PUB_KEY$ = "AAAAB3NzaC1yc2EAAAABJQAAAIBZnXD4IKfrBH25ekwLWQMs5mJuNH7D7U99EKFIsVhKQv17GHxKWvxHv/FwWhI1Rmd8TCiqk4Wmk7H1rh6xdbIVBwDj+RSeiXs8mmQX4/XvaWZx9BIQr5wODWnQCH/tj6Y6In2Xjc2J3B7LSjD60cWDBY/u+z9cSheTHLyhb16zFw==" +'<br> +' ... +' Private Sub Form_Load() +' On Error GoTo Hell +' '' Obtain an instance of AL +' Set MyActiveLock = ActiveLock2.NewInstance() +' '' Verify AL's authenticity +' '' modActiveLock.CRCCheckSumTypeLib() requires a public-creatable object to be passed in so that it can +' '' determine the Type Library DLL on which to perform the checksum. +' '' So can't use MyActiveLock object to authenticate since it is not a public creatable object. +' '' So we'll use ActiveLock2.Globals, which is just as good because they are in the same DLL. +' Dim crc As Long +' crc = modActiveLock.CRCCheckSumTypeLib(New ActiveLock2.Globals) +' Debug.Print "Hash: " & crc +' If crc <> AL_CRC Then +' MsgBox "ActiveLock2.dll has been corrupted. If you were running a real application, it should terminate at this point." +' End If +'<br> +' '' Initialize the keystore. We use a File keystore in this case. +' MyActiveLock.KeyStoreType = alsFile +' MyActiveLock.KeyStorePath = App.path & "\al.lic" +'<br> +' '' Obtain the EventNotifier so that we can receive notifications from AL. +' Set ActiveLockEventSink = MyActiveLock.EventNotifier +'<br> +' '' Specify the name of the product that will be locked through AL. +' MyActiveLock.SoftwareName = "MyApp" +'<br> +' '' Specify our product code. This is a RSA public key, which will be used later by ActiveLock to validate license signatures +' MyActiveLock.SoftwareCode = "AAAAB3NzaC1yc2EAAAABJQAAAIBZnXD4IKfrBH25ekwLWQMs5mJuNH7D7U99EKFIsVhKQv17GHxKWvxHv/FwWhI1Rmd8TCiqk4Wmk7H1rh6xdbIVBwDj+RSeiXs8mmQX4/XvaWZx9BIQr5wODWnQCH/tj6Y6In2Xjc2J3B7LSjD60cWDBY/u+z9cSheTHLyhb16zFw==" +'<br> +' '' Specify product version +' MyActiveLock.SoftwareVersion = txtVersion +'<br> +' '' Specify License Type +' MyActiveLock.LicenseType = allicTimeLocked +'<br> +' '' Specify Lock Type +' MyActiveLock.LockType = lockHD +'<br> +' '' Now initialize AL +' MyActiveLock.Init +'<br> +' '' At this point, either AL has been initialized or an error would have already been raised +' '' if there were problems (such as the DLL has been tampered). +'<br> +' '' Check registration status by calling Acquire() +' '' Note: Calling Acquire() may trigger ActiveLockEventNotifier_ValidateValue() event. +' '' So we must be prepared to handle that. +' MyActiveLock.Acquire +'<br> +' '' By now, if the product is not registered, then an error whould have been raised, +' '' which means if we get to here, then we're registered. +'<br> +' '' Just for fun, print out some registration status info +' Debug.Print "Used Days: " & MyActiveLock.UsedDays +' Debug.Print "Expiration Date: " & MyActiveLock.ExpirationDate +' Exit Sub +' Hell: +' MsgBox Err.Number & ": " & Err.Description +' '' End program +' End +' End Sub +' ... +' ... +' '' +' '' ActiveLock raises this event typically when it needs a value to be encrypted. +' '' We can use any kind of encryption we'd like here, as long as it's deterministic. +' '' i.e. there's a one-to-one correspondence between unencrypted value and encrypted value. +' '' NOTE: BlowFish is NOT an example of deterministic encryption so you can't use it here. +' Private Sub ActiveLockEventSink_ValidateValue(ByVal Value As String, Result As String) +' Result = Encrypt(Value) +' End Sub +'<br> +' '' Encrypts a string. +' Private Function Encrypt(strData As String) As String +' Dim Key As RSAKey +' '' create the key from the key blobs +' modActiveLock.rsa_createkey PUB_KEY, Len(PUB_KEY), PRIV_KEY, Len(PRIV_KEY), Key +'<br> +' '' sign the data using the created key +' Dim dLen& +' Dim strEnc As String * 255 +' strEnc = strData +' dLen = Len(strData) +' modActiveLock.rsa_encrypt 1, strEnc, dLen, Key +'<br> +' '' done with the key - throw it away +' modActiveLock.rsa_freekey Key +'<br> +' Dim strOut As String +' strOut = Left$(strEnc, dLen) +' Encrypt = strOut +' End Function +' </pre> +' ' ' @author th...@us... ' @version 2.0.0 @@ -53,16 +171,18 @@ '* /////////////////////////////////////////////////////////////////////// ' / MODULE TO DO LIST / ' /////////////////////////////////////////////////////////////////////// -' [ ] TODO Item 1 -' [ ] TODO Item 2 ' ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// -' +' @history +' <pre> ' 07.07.03 - mcrute - Updated the header comments for this file. ' 07.20.03 - th2tran - Added EventNotifier used for firing COM events. +' 08.03.03 - th2tran - VBDox'ed this interface. ' +' </pre> + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -70,12 +190,12 @@ Option Explicit '' -' License Types. Values are mutually exclusive. +' License Types. Values are mutually exclusive. i.e. they cannot be OR'd together. ' -' @param licNone Not licensed -' @param licPeriodic License expires after X number of days -' @param licPermanent License will never expire -' @param licTimeLocked License expires on a particular date +' @param allicNone Not licensed +' @param allicPeriodic License expires after X number of days +' @param allicPermanent License will never expire +' @param allicTimeLocked License expires on a particular date Public Enum ALLicType allicNone = 0 allicPeriodic = 1 @@ -84,9 +204,9 @@ End Enum '' -' License Lock Types. Values can be combined (OR'ed) together. +' License Lock Types. Values can be combined (OR''ed) together. ' -' @param licNone No locking - not recommended +' @param lockNone No locking - not recommended ' @param lockWindows Lock to windows serial number ' @param lockComp Lock to computer name ' @param lockHD Lock to hard drive serial @@ -102,7 +222,7 @@ End Enum '' -' License Flags. Values can be combined (OR'ed) together. +' License Flags. Values can be combined (OR''ed) together. ' ' @param alfSingle Single-user license ' @param alfMulti Multi-user license @@ -115,82 +235,86 @@ ' License Store Type specifies where to store license keys ' ' @param alsRegistry ' Store in Windows Registry -' @param alsFile ' Store in a license type +' @param alsFile ' Store in a license file Public Enum LicStoreType alsRegistry = 0 alsFile = 1 End Enum -'' -' Performs special initialization before we start operating. -' -' @param Args -'* [th2tran20030720] I can't think of any special initialization that is required right now. -' But let's keep this for future use. -Public Sub Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) - -End Sub - '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Interface Properties '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' ' Specifies the license type for this instance of ActiveLock. +' @param LicType License Type ' Public Property Let LicenseType(LicType As ALLicType) End Property + +'' +' Returns the License Type being used in this instance. +' Public Property Get LicenseType() As ALLicType End Property '' ' Specifies the lock type for this instance of ActiveLock. +' @param LockTypes Lock Types. ' -Public Property Let LockType(locktypes As ALLockTypes) +Public Property Let LockType(LockTypes As ALLockTypes) End Property + +'' +' Returns the Lock Type being used in this instance. +' Public Property Get LockType() As ALLockTypes End Property '' ' Specifies the name of the product being locked. +' @param sName Software Name ' Public Property Let SoftwareName(sName As String) End Property + +'' +' Returns the Software Name being used in this instance. +' Public Property Get SoftwareName() As String End Property '' ' Specifies the software code (product code) -' +' @param sCode Software Code. Public Property Let SoftwareCode(sCode As String) End Property '' ' Specifies the version of the product being locked. +' @param sVer Version string e.g. "1.0" ' Public Property Let SoftwareVersion(sVer As String) End Property -Public Property Get SoftwareVersion() As String - -End Property '' -' Specifies the product code for the product being locked. -' -'Public Property Get SoftwareCode(sCode As String) +' Returns the Software Version being used in this instance. ' -'End Property +Public Property Get SoftwareVersion() As String + +End Property '' ' Specifies the key store type. +' @param KeyStore Key Store Type. ' Public Property Let KeyStoreType(KeyStore As LicStoreType) @@ -198,18 +322,22 @@ '' ' Specifies the key store path. -' +' @param Path The path to be used for the specified KeyStoreType. +' e.g. If <code>alsFile</code> is used for <code>KeyStoreType</code>, then Path specifies the path to the license file. +' If <code>alsRegistry</code> is used for <code>KeyStoreType</code>, the Path specifies the Registry hive where license information is stored. Public Property Let KeyStorePath(Path As String) End Property -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -' Interface Methods -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +'* +'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' +'* Interface Methods +'*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' -' Returns the software code corresponding to the set LockTypes, license class, etc... +' Computes a lock code corresponding to the specified Lock Types, License Class, etc... ' Optionally, if a product license is specified, then a lock string specific to that license is returned. +' @param Lic Product License for which to compute the lock code. Public Function LockCode(Optional Lic As ProductLicense = Nothing) As String End Function @@ -217,7 +345,7 @@ '' ' Registers the following product license. -' +' @param Lic Product License with which to register. Public Sub Register(Lic As ProductLicense) End Sub @@ -225,12 +353,26 @@ '' ' Transfers the current license to another computer. ' Returns the liberation key tailored for the other request code. +' @param RequestCode Request Code generated from the other computer. ' Public Function Transfer(RequestCode As String) As String End Function '' +' Performs special initialization before we start operating. Some of the routines, including <code>Acquire()</code> +' and <code>Register()</code> requires Init() to be called first. +' This routine accepts varying number of parameters. +' @todo [th2tran20030720] I can't think of any special initialization that is required right now. But let''s keep this for future use. +' +' @param Arg1 First parameter to be passed to this routine. +' @param OtherArgs The remaining array of arguments to be passed into this routine. +Public Sub Init(Arg1 As Variant, ParamArray OtherArgs() As Variant) + +End Sub + + +'' ' Acquires a valid license token. ' If no valid license can be found, an appropriate error will be thrown, specifying the cause. ' @@ -248,13 +390,14 @@ '' ' Retrieves the event notifier. ' Client applications uses this Notifier to handle event notifications sent by ActiveLock, -' including key validation events. +' including license validation events. +' @see ActiveLockEventNotifier for more information. Public Property Get EventNotifier() As ActiveLockEventNotifier End Property '' -' Returns the number of days this product has been used. +' Returns the number of days this product has been used since its registration. ' Public Property Get UsedDays() As Long @@ -268,7 +411,7 @@ End Property '' -' Returns the expiration date +' Returns the expiration date string. ' Public Property Get ExpirationDate() As String Index: IKeyStoreProvider.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/IKeyStoreProvider.cls,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- IKeyStoreProvider.cls 23 Jul 2003 03:55:21 -0000 1.5 +++ IKeyStoreProvider.cls 3 Aug 2003 08:38:11 -0000 1.6 @@ -43,8 +43,8 @@ '* '' -' This is the interface for a an object that facilitates storing and -' retrieving of product keys. +' This is the interface for a class that facilitates storing and +' retrieving of product license keys. ' ' @author th...@us... ' @version 2.0.0 @@ -57,31 +57,35 @@ ' [ ] TO-DO Item 1 ' ' + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// -' +' @history +' <pre> ' 07.07.03 - mcrute - Updated the header comments for this file. -' -' +' 08.03.03 - th2tran - VBDox'ed this class. +' </pre> + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// - - Option Explicit - '' ' Specifies the path under which the keys are stored. ' Example: path to a license file, or path to the Windows Registry hive. +' @param Path Key store path. ' Public Property Let KeyStorePath(Path As String) End Property '' -' Retrieves license info for the specified product key. +' Retrieves license info for the specified product name. +' @param ProductName Product name. +' @return ProductLicense object matching the specified product name. +' If no license found, then <code>Nothing</code> is returned. ' Public Function Retrieve(ProductName As String) As ProductLicense @@ -89,6 +93,7 @@ '' ' Stores a license. +' @param Lic License to be stored. ' Public Sub Store(Lic As ProductLicense) Index: ProductLicense.cls =================================================================== RCS file: /cvsroot/activelock/activelock2/src/ProductLicense.cls,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ProductLicense.cls 28 Jul 2003 06:35:30 -0000 1.4 +++ ProductLicense.cls 3 Aug 2003 08:38:11 -0000 1.5 @@ -45,7 +45,7 @@ '' ' This class encapsulates a product license. A product license contains ' information such as the registered user, license type, product ID, -' license code, etc... +' license key, etc... ' ' @author th...@us... ' @version 2.0.0 @@ -60,11 +60,13 @@ ' /////////////////////////////////////////////////////////////////////// ' / MODULE CHANGE LOG / ' /////////////////////////////////////////////////////////////////////// -' +' <pre> ' 06.16.03 - th2tran - created ' 07.07.03 - mecrute - Updated the header comments for this file. -' -' +' 08.03.03 - th2tran - VBDox'ed this class. +' </pre> + + ' /////////////////////////////////////////////////////////////////////// ' / MODULE CODE BEGINS BELOW THIS LINE / ' /////////////////////////////////////////////////////////////////////// @@ -83,67 +85,115 @@ Private mstrHash1 As String ' hash of mstrRegisteredDate +'' ' CPU License Class - I don't yet know how this could be done! +' Public Property Get CLASS_1() As String CLASS_1 = "Class1" End Property -' ' Site License Class - lock to hard-drive(nic?) +'' +' Site License Class - lock to hard-drive(nic?) +' Public Property Get CLASS_2() As String CLASS_2 = "Class2" End Property -Friend Property Let ProductName(name As String) - mstrProductName = name +'' +' [INTERNAL] Specifies product name. +' +Friend Property Let ProductName(Name As String) + mstrProductName = Name End Property + +'' +' Returns the product name. +' Public Property Get ProductName() As String ProductName = mstrProductName End Property +'' +' [INTERNAL] Specified product version. +' Friend Property Let ProductVer(Ver As String) mstrProductVer = Ver End Property + +'' +' Returns the product version string. +' Public Property Get ProductVer() As String ProductVer = mstrProductVer End Property '' -' !!!WARNING!!! Use this method with caution. You run the risk of invalidating your existing license +' Specifies the product key. +' +' <p>!!!WARNING!!! Use this method with caution. You run the risk of invalidating your existing license ' if you call this method without knowing what you are doing. +' @param Key Product Key ' Public Property Let ProductKey(Key As String) mstrProductKey = Key End Property + +'' +' Returns the product key. +' Public Property Get ProductKey() As String ProductKey = mstrProductKey End Property +'' +' [INTERNAL] Specifies license type. +' Friend Property Let LicenseType(LicType As String) mstrType = LicType End Property + +'' +' Returns the license type. +' Public Property Get LicenseType() As String LicenseType = mstrType End Property +'' +' [INTERNAL] Specifies the license class string. +' Friend Property Let LicenseClass(LicClass As String) mstrLicenseClass = LicClass End Property + +'' +' Returns the license class string. +' Public Property Get LicenseClass() As String LicenseClass = mstrLicenseClass End Property -Friend Property Let Licensee(name As String) - mstrLicensee = name +'' +' [INTERNAL] Specifies the licensed user. +' +Friend Property Let Licensee(Name As String) + mstrLicensee = Name End Property + +'' +' Returns the person or organization registered to this license. +' Public Property Get Licensee() As String Licensee = mstrLicensee End Property '' ' Updates the License Key. -' !!! WARNING !!! Make sure you know what you're doing when you call this method; otherwise, you run +' <p>!!! WARNING !!! Make sure you know what you're doing when you call this method; otherwise, you run ' the risk of invalidating your existing license. ' +' @param Key New license key to be updated. +' Public Property Let LicenseKey(Key As String) mstrLicenseKey = Key End Property @@ -155,11 +205,17 @@ LicenseKey = mstrLicenseKey End Property +'' +' [INTERNAL] Specifies expiration data. +' @param strData expiration date string +' Friend Property Let Expiration(strDate As String) mstrExpiration = strDate End Property + '' ' Returns the expiration date string. +' Public Property Get Expiration() As String Expiration = mstrExpiration End Property @@ -170,6 +226,10 @@ Public Property Get RegisteredDate() As String RegisteredDate = mstrRegisteredDate End Property + +'' +' [INTERNAL] Specifies the registered date. +' @param strDate registered date Friend Property Let RegisteredDate(strDate As String) mstrRegisteredDate = strDate End Property @@ -180,16 +240,25 @@ Public Property Get LastUsed() As String LastUsed = mstrLastUsed End Property + +'' +' [INTERNAL] Sets the last used date. +' @param strDateTime DateTime string +' Friend Property Let LastUsed(strDateTime As String) mstrLastUsed = strDateTime End Property '' -' Returns Hash-1 code. +' Returns Hash-1 code. Hash-1 code is the encryption hash of the <code>LastUsed</code> property. ' Public Property Get Hash1() As String Hash1 = mstrHash1 End Property + +'' +' [INTERNAL] Sets the Hash-1 code. +' Friend Property Let Hash1(hcode As String) mstrHash1 = hcode End Property @@ -212,6 +281,7 @@ '' ' Loads the license from a formatted string. +' @param strLic Formatted license string, delimited by CrLf characters. ' Public Sub Load(strLic As String) ' First, base64-decode it @@ -231,6 +301,7 @@ '' ' Saves the license into a formatted string. +' @param strOut [out] Formatted license string will be saved into this parameter when the routine returns. ' Public Sub Save(strOut As String) strOut = ToString() & vbCrLf & LicenseKey 'add License Key at the end |