[ActiveLock-Development] CVS: activelock/src ActiveLock.cls,1.10,1.11 ActiveLock2.vbp,1.7,1.8 IActiv
Brought to you by:
ialkan
From: Thanh H. T. <th...@us...> - 2004-07-19 12:07:16
|
Update of /cvsroot/activelock/activelock/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15095 Modified Files: ActiveLock.cls ActiveLock2.vbp IActiveLock.cls modActiveLock.bas Log Message: Batch commit for 2.0.10 Index: ActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock/src/ActiveLock.cls,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- ActiveLock.cls 16 May 2004 18:37:38 -0000 1.10 +++ ActiveLock.cls 19 Jul 2004 12:06:57 -0000 1.11 @@ -96,7 +96,16 @@ ' User can blank out the LastUsed property, set their clock back and continue to use an otherwise-expired ' license. ' 05.13.04 - th2tran - Fixed "Object variable not set" error in IActiveLock_UsedDays() caused when retrieved Lic is Nothing. -' +' 07.11.04 - th2tran - For regional setting in which Daylight Savings Time (DST) applies, +' There was a chance that ActiveLock could misbehave when DST goes into effect, due to +' its usage of local time in the LastUsed property tripping over when Daylights Savings Time (DST) goes into effect. +' To avoid this problem, all date-time sensitive values are now to be handled in UTC format. +' - Raise alerrNotImplemented for KeyStoreType other than alsFile +' 07.19.04 - th2tran - Fixed bug: Bad InstallationCode was generated when UserName="" and LockType is other than lockNone. +' This problem was because, previously, the vbLf delimiter wasn't included in the Installation Code when the +' user name is blank, which causes ALUGEN to (correctly) take the LockCode part of InstallationCode +' (the part after the last vbLf delimiter) for the user name, resulting in an invalid liberation key +' being generated. ' </pre> ' /////////////////////////////////////////////////////////////////////// @@ -128,6 +137,11 @@ Private mfInit As Boolean ' flag to indicate that ActiveLock has been initialized +Private Sub Class_Initialize() + ' Default to alsFile + IActiveLock_KeyStoreType = alsFile +End Sub + ''' ' IActiveLock Interface implementations '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' @@ -265,7 +279,7 @@ If Lic.Expiration = "" Then Exit Sub Dim dtExp As Date dtExp = CDate(Lic.Expiration) - If Now > dtExp Then + If modActiveLock.UTC(Now) > dtExp Then Err.Raise ActiveLockErrCodeConstants.alerrLicenseExpired, "ActiveLock2", "License expired" End If End Sub @@ -290,8 +304,15 @@ Err.Raise ActiveLockErrCodeConstants.alerrLicenseTampered, "ActiveLock2", "License may have been tampered." End If ' try to detect the user setting their system clock back - If Now < CDate(Lic.LastUsed) Then - ' TODO: Need to account for Daylight Savings Time + ' Need to account for Daylight Savings Time + 'Dim dtNow As Date + 'dtNow = modActiveLock.UTC(Now) + Dim strNow As String + ' Normalize to the format of the saved date-time, before we compare + strNow = Format(modActiveLock.UTC(Now()), "YYYY/MM/DD HH:MM:SS") + If strNow < Lic.LastUsed Then + Debug.Print "UTC Now: " & strNow + Debug.Print "LastUsed: " & CDate(Lic.LastUsed) Err.Raise ActiveLockErrCodeConstants.alerrClockChanged, "ActiveLock2", "License invalid. You have set your system clock backward!" End If UpdateLastUsed Lic @@ -305,7 +326,7 @@ ' Update license store with LastRunDate Dim strEncrypted As String Dim strLastUsed As String - strLastUsed = Format(Now(), "YYYY/MM/DD HH:MM:SS") + strLastUsed = Format(modActiveLock.UTC(Now()), "YYYY/MM/DD HH:MM:SS") Lic.LastUsed = strLastUsed MyNotifier.Notify "ValidateValue", strLastUsed Lic.Hash1 = modMD5.Hash(strLastUsed) @@ -338,7 +359,9 @@ If RHS = alsFile Then Set mKeyStore = New FileKeyStoreProvider Else - Set mKeyStore = New RegistryKeyStoreProvider +' Set mKeyStore = New RegistryKeyStoreProvider + ' TODO: Implement me! + Err.Raise ActiveLockErrCodeConstants.alerrNotImplemented, "IActiveLock_KeyStoreType", "Not implemented" End If ' Set Key Store Path in KeyStoreProvider If mKeyStorePath <> "" Then @@ -392,11 +415,7 @@ Dim strReq As String, strLock As String strLock = IActiveLock_LockCode() ' combine with user name - If User = "" Then - strReq = strLock - Else - strReq = strLock & vbLf & User - End If + strReq = strLock & vbLf & User ' base-64 encode the request Dim strReq2 As String strReq2 = modBase64.Base64_Encode(strReq) @@ -465,5 +484,5 @@ ' validate the license ValidateLic Lic - IActiveLock_UsedDays = CLng(DateDiff("d", Lic.RegisteredDate, Now)) + IActiveLock_UsedDays = CLng(DateDiff("d", Lic.RegisteredDate, modActiveLock.UTC(Now))) End Property Index: ActiveLock2.vbp =================================================================== RCS file: /cvsroot/activelock/activelock/src/ActiveLock2.vbp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- ActiveLock2.vbp 16 May 2004 18:37:38 -0000 1.7 +++ ActiveLock2.vbp 19 Jul 2004 12:06:58 -0000 1.8 @@ -32,7 +32,7 @@ VersionCompatible32="1" MajorVer=2 MinorVer=0 -RevisionVer=7 +RevisionVer=10 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="The ActiveLock Software Group" Index: IActiveLock.cls =================================================================== RCS file: /cvsroot/activelock/activelock/src/IActiveLock.cls,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- IActiveLock.cls 16 May 2004 18:37:38 -0000 1.7 +++ IActiveLock.cls 19 Jul 2004 12:06:58 -0000 1.8 @@ -233,6 +233,7 @@ ' Better to do it via property accessors (such as the AutoRegisterKeyPath property), and ' leave Init() with no parameters. ' 04.21.04 - th2tran - Added AutoRegisterKeyPath property +' 07.11.04 - th2tran - Fixed bad alsRegistry href in vbdox ' </pre> ' /////////////////////////////////////////////////////////////////////// @@ -345,7 +346,7 @@ ' @param sPath The path to be used for the specified KeyStoreType. ' e.g. If <a href="IActiveLock.LicStoreType.html">alsFile</a> is used for <a href="IActiveLock.Let.KeyStoreType.html">KeyStoreType</a>, ' then <code>Path</code> specifies the path to the license file. -' If <a href="IActiveLock.LicStoreType.html">alsRegistry</a> is used for <a href="IActiveLock.Let.KeyStoreType.htm">KeyStoreType</a>, +' If <a href="IActiveLock.LicStoreType.html">alsRegistry</a> is used, ' the Path specifies the Registry hive where license information is stored. Public Property Let KeyStorePath(ByVal sPath As String) Attribute KeyStorePath.VB_Description = "Specifies the path where the license store resides." Index: modActiveLock.bas =================================================================== RCS file: /cvsroot/activelock/activelock/src/modActiveLock.bas,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- modActiveLock.bas 18 Apr 2004 01:50:46 -0000 1.3 +++ modActiveLock.bas 19 Jul 2004 12:07:06 -0000 1.4 @@ -66,6 +66,7 @@ ' in the forum and mailing list a while back. ' 08.02.03 - th2tran - VBdox'd this module. ' 04.17.04 - th2tran - Added FileExists() routine. +' 07.11.04 - th2tran - New routines for handling GMT date-time. ' </pre> ' /////////////////////////////////////////////////////////////////////// @@ -184,6 +185,50 @@ hwndProgbar As Long End Type +Type SYSTEMTIME + wYear As Integer + wMonth As Integer + wDayOfWeek As Integer + wDay As Integer + wHour As Integer + wMinute As Integer + wSecond As Integer + wMilliseconds As Integer +End Type + +Private Type TIME_ZONE_INFORMATION + bias As Long ' current offset to GMT + StandardName(1 To 64) As Byte ' unicode string + StandardDate As SYSTEMTIME + StandardBias As Long + DaylightName(1 To 64) As Byte + DaylightDate As SYSTEMTIME + DaylightBias As Long +End Type + +Public Enum TimeZoneReturn + TimeZoneCode = 0 + TimeZoneName = 1 + UTC_BaseOffset = 2 + UTC_Offset = 3 + DST_Active = 4 + DST_Offset = 5 +End Enum + +' ----------------- For Time Zone Retrieval ------------------ +Private Const TIME_ZONE_ID_UNKNOWN = 0 +Private Const TIME_ZONE_ID_STANDARD = 1 +Private Const TIME_ZONE_ID_INVALID = &HFFFFFFFF +Private Const TIME_ZONE_ID_DAYLIGHT = 2 + + +Private Declare Sub GetSystemTime Lib "kernel32" _ + (lpSystemTime As SYSTEMTIME) + +Private Declare Function GetTimeZoneInformation Lib "kernel32" _ + (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long + + ' ActiveLock Encryption Key ' !!!WARNING!!! It is highly recommended that you change this key for your version of ActiveLock before deploying your app. Public Const ENCRYPT_KEY$ = "AAAAgEPRFzhQEF7S91vt2K6kOcEdDDe5BfwNiEL30/+ozTFHc7cZctB8NIlS++ZR//D3AjSMqScjh7xUF/gwvUgGCjiExjj1DF/XWFWnPOCfF8UxYAizCLZ9fdqxb1FRpI5NoW0xxUmvxGjmxKwazIW4P4XVi/+i1Bvh2qQ6ri3whcsNAAAAQQCyWGsbJKO28H2QLYH+enb7ehzwBThqfAeke/Gv1Te95yIAWme71I9aCTTlLsmtIYSk9rNrp3sh9ItD2Re67SE7AAAAQQCAookH1nws1gS2XP9cZTPaZEmFLwuxlSVsLQ5RWmd9cuxpgw5y2gIskbL4c+4oBuj0IDwKtnMrZq7UfV9I5VfVAAAAQQCEnyAuO0ahXH3KhAboop9+tCmRzZInTrDYdMy23xf3PLCLd777dL/Y2Y+zmaH1VO03m6iOog7WLiN4dCL7m+Im" ' RSA Private Key @@ -327,3 +372,76 @@ End Function +'' +' Retrieves the local time zone. +' @param returnType Type of time zone information being requested +' UTC_BaseOffset = UTC offset, not including DST <br> +' UTC_Offset = UTC offset, including DST if active <br> +' DST_Active = True if DST is currently active, otherwise false <br> +' DST_Offset = Offset value for DST (generally -60, if in US) +' @returns Return type varies depending on returnValue parameter. +Public Function LocalTimeZone(ByVal returnType As TimeZoneReturn) As Variant + Dim X As Long + Dim tzi As TIME_ZONE_INFORMATION + Dim strName As String + Dim bDST As Boolean + Dim rc& + rc = GetTimeZoneInformation(tzi) + Select Case rc + ' if not daylight assume standard + Case TIME_ZONE_ID_DAYLIGHT + strName = tzi.DaylightName ' convert to string + bDST = True + Case Else + strName = tzi.StandardName + End Select + + ' name terminates with null + X = InStr(strName, vbNullChar) + If X > 0 Then strName = Left$(strName, X - 1) + + If returnType = DST_Active Then + LocalTimeZone = bDST + End If + + If returnType = TimeZoneName Then + LocalTimeZone = strName + End If + + If returnType = TimeZoneCode Then + LocalTimeZone = Left(strName, 1) + X = InStr(1, strName, " ") + Do While X > 0 + LocalTimeZone = LocalTimeZone & Mid(strName, X + 1, 1) + X = InStr(X + 1, strName, " ") + Loop + LocalTimeZone = Trim(LocalTimeZone) + End If + + If returnType = UTC_BaseOffset Then + LocalTimeZone = tzi.bias + End If + + If returnType = DST_Offset Then + LocalTimeZone = tzi.DaylightBias + End If + + If returnType = UTC_Offset Then + If tzi.DaylightBias = -60 Then + LocalTimeZone = tzi.bias + Else + LocalTimeZone = -tzi.bias + End If + ' Account for Daylight Savings Time + If bDST Then LocalTimeZone = LocalTimeZone - 60 + End If +End Function + + +'' +' Converts a local date-time into UTC/GMT date-time +' +Public Function UTC(dt As Date) As Date + ' Returns current UTC date-time. + UTC = DateAdd("n", LocalTimeZone(UTC_Offset), dt) +End Function |