Esempio n. 1
0
        private static byte[] PW()
        {
            Process currentProcess = Process.GetCurrentProcess();
            string  data           = currentProcess.MachineName + currentProcess.Id;

            return(BBSLic.GetHash(data));
        }
Esempio n. 2
0
        // Checks if license is valid for SQLsecure
        // Checks ProductID, Version, Scope, Expiration, Is Duplicate
        private LicenseState IsLicenseValid(BBSLic lic, string licenseKey)
        {
            LicenseState licState = LicenseState.InvalidKey;

            if (lic != null)
            {
                while (licState == LicenseState.InvalidKey)
                {
                    licState = LicenseState.Valid;

                    // Is the product ID for SQLsecure
                    if (!IsLicenseProductIDValid(lic))
                    {
                        licState = LicenseState.InvalidProductID;
                        break;
                    }
                    // Is this for correct version
                    if (!IsLicenseVersionValid(lic))
                    {
                        licState = LicenseState.InvalidProductVersion;
                        break;
                    }
                    // Is it registered for this repository or enterprise
                    if (!IsLicenseScopeValid(lic))
                    {
                        licState = LicenseState.InvalidScope;
                        break;
                    }
                    // Is license expired
                    if (lic.IsExpired)
                    {
                        licState = LicenseState.InvalidExpired;
                        break;
                    }
                    // Does it already exist
                    bool bDuplicate = false;
                    foreach (LicenseData licData2 in m_Licenses)
                    {
                        if (licData2.key == licenseKey)
                        {
                            bDuplicate = true;
                            break;
                        }
                    }
                    if (bDuplicate)
                    {
                        licState = LicenseState.InvalidDuplicateLicense;
                    }

                    if (!IsLicenseReasonable(lic))
                    {
                        licState = LicenseState.InvalidKey;
                        break;
                    }
                }
            }

            return(licState);
        }
Esempio n. 3
0
        private int GetLicenseCount(BBSLic bbsLic)
        {
            int count = 0;

            if (bbsLic != null)
            {
                count = bbsLic.Limit1;
            }
            return(count);
        }
Esempio n. 4
0
        private bool IsLicenseTrial(BBSLic bbsLic)
        {
            bool isTrial = false;

            if (bbsLic != null)
            {
                isTrial = bbsLic.IsTrial;
            }
            return(isTrial);
        }
Esempio n. 5
0
        private bool IsLicensePermament(BBSLic bbsLic)
        {
            bool isPermament = false;

            if (bbsLic != null)
            {
                isPermament = bbsLic.IsPermanent;
            }
            return(isPermament);
        }
Esempio n. 6
0
        // Returns display string for number of licensed servers
        private string GetLicenseCountStr(BBSLic bbsLic)
        {
            string count = string.Empty;

            if (bbsLic != null)
            {
                count = CountToString(bbsLic.Limit1);
            }
            return(count);
        }
Esempio n. 7
0
        // Is the ProductID valid for SQLsecure
        private bool IsLicenseVersionValid(BBSLic lic)
        {
            bool bValid = false;

            if (lic != null)
            {
                if (lic.ProductVersion == m_productVersion)
                {
                    bValid = true;
                }
            }
            return(bValid);
        }
Esempio n. 8
0
        // Is the scope hash valid for our repository
        private bool IsLicenseScopeValid(BBSLic lic)
        {
            bool bValid = false;

            if (lic != null)
            {
                if (lic.IsEnterprise || lic.CheckScopeHash(m_scopeString))
                {
                    bValid = true;
                }
            }
            return(bValid);
        }
Esempio n. 9
0
        // Is the ProductID valid for SQLsecure
        private bool IsLicenseProductIDValid(BBSLic lic)
        {
            bool bValid = false;

            if (lic != null)
            {
                if (lic.ProductID == m_productID)
                {
                    bValid = true;
                }
            }
            return(bValid);
        }
Esempio n. 10
0
 // Is the Product Version valid for SQLsecure
 private bool IsLicenseVersionValid(BBSLic lic)
 {
     return(true);
     //bool bValid = false;
     //if (lic != null)
     //{
     //    if (lic.ProductVersion >= m_productVersion)
     //    {
     //        bValid = true;
     //    }
     //}
     //return bValid;
 }
Esempio n. 11
0
        private LicenseState LoadAndValidateLicense(string license, out BBSLic bbsLic)
        {
            LicenseState licState = LicenseState.InvalidKey;

            bbsLic = new BBSLic();
            LicErr rc = bbsLic.LoadKeyString(license);

            if (rc == LicErr.OK)
            {
                licState = IsLicenseValid(bbsLic, license);
            }

            return(licState);
        }
Esempio n. 12
0
        public string GenerateTrialLicense()
        {
            BBSLic lic = new BBSLic();

            lic.IsTrial          = true;
            lic.KeyID            = 0;
            lic.DaysToExpiration = 14;
            lic.ProductID        = (short)m_productID;
            lic.SetScopeHash(m_scopeString);
            lic.Limit1         = 10;
            lic.ProductVersion = m_productVersion;

            string key = lic.KeyString;

            return(key);
        }
Esempio n. 13
0
        // Returns display string for the scope
        // License is validated when class is instanciated.
        // Since license is valid then scope is either enterprise or our repository
        private string GetLicenseScopeStr(BBSLic bbsLic)
        {
            string scope = string.Empty;

            if (bbsLic != null)
            {
                if (bbsLic.IsEnterprise)
                {
                    scope = BBSLicenseConstants.LicenseTypeEnterprise;
                }
                else
                {
                    scope = m_scopeString;
                }
            }
            return(scope);
        }
Esempio n. 14
0
        // Returns display string for type (Production or Trial)
        private string GetLicenseTypeStr(BBSLic bbsLic)
        {
            string type = string.Empty;

            if (bbsLic != null)
            {
                if (bbsLic.IsTrial)
                {
                    type = BBSLicenseConstants.LicenseTypeTrial;
                }
                else
                {
                    type = BBSLicenseConstants.LicenseTypeProduction;
                }
            }
            return(type);
        }
Esempio n. 15
0
        // Returns display string for expiration date (None if no expiration)
        private string GetLicenseExpirationDateStr(BBSLic bbsLic)
        {
            string date = string.Empty;

            if (bbsLic != null)
            {
                if (bbsLic.IsPermanent)
                {
                    date = BBSLicenseConstants.LicenseNoExpirationDate;
                }
                else
                {
                    date = bbsLic.ExpirationDate.ToShortDateString();
                }
            }
            return(date);
        }
Esempio n. 16
0
        //---------------------------------------------------------------------
        // IsLicenseReasonable - Our license key checksum is not solid so
        //                       you can change characters in the key and
        //                       still have a valid license. This could allow
        //                       a customer to bump up their license cound.
        //                       However the changes always create unresonable
        //                       licenses like 1000s of seats. To avoid
        //                       problems of upgrading license DLL we just are
        //                       putting in a reasonableness check in the products
        //---------------------------------------------------------------------
        private bool IsLicenseReasonable(BBSLic license)
        {
            // Trials only valid for 0-90 days
            if (license.IsTrial)
            {
                if (license.IsPermanent)
                {
                    return(false);
                }
                if (license.DaysToExpiration < 0)
                {
                    return(false);
                }
                if (license.DaysToExpiration > 90)
                {
                    return(false);
                }
            }
            else // Purchase license only valid for 0-400 days or unlimited
            {
                if (license.DaysToExpiration < 0)
                {
                    return(false);
                }
                if (license.DaysToExpiration > 400 && license.DaysToExpiration != 32767)
                {
                    return(false);
                }
            }

            // License only good for up to 500 licenses
            if (license.Limit1 < -1)
            {
                return(false);
            }
            if (license.Limit1 > 500)
            {
                return(false);
            }
            if (license.Limit2 < -2 || license.Limit2 > 1)
            {
                return(false);                                           // some products code limit 2 as 1 instead of unlimited
            }
            return(true);
        }
Esempio n. 17
0
        // Check if the given string is a valid license
        // UI calls this before accepting license string
        public bool IsLicenseStringValid(string license, out LicenseState licState)
        {
            bool bValid = false;

            licState = LicenseState.InvalidKey;

            if (!string.IsNullOrEmpty(license))
            {
                BBSLic lic = new BBSLic();
                LicErr rc  = lic.LoadKeyString(license);
                if (rc == LicErr.OK)
                {
                    licState = IsLicenseValid(lic, license);
                    bValid   = licState == LicenseState.Valid ? true : false;
                }
            }

            return(bValid);
        }
Esempio n. 18
0
        // Check if the given string is a valid trial license
        // UI calls this before accepting license string
        public bool IsLicenseStringTrial(string licenseStr)
        {
            bool         bTrial   = false;
            LicenseState licState = LicenseState.InvalidKey;

            if (!string.IsNullOrEmpty(licenseStr))
            {
                BBSLic lic = new BBSLic();
                LicErr rc  = lic.LoadKeyString(licenseStr);
                if (rc == LicErr.OK)
                {
                    licState = IsLicenseValid(lic, licenseStr);
                    if (licState == LicenseState.Valid)
                    {
                        bTrial = lic.IsTrial;
                    }
                }
            }

            return(bTrial);
        }
Esempio n. 19
0
        // Returns display string for days to expiration or None if no expiration date
        private string GetLicenseDaysToExpirationStr(BBSLic bbsLic)
        {
            string days = string.Empty;

            if (bbsLic != null)
            {
                if (bbsLic.IsPermanent)
                {
                    days = BBSLicenseConstants.LicenseNoExpirationDate;
                }
                else if (bbsLic.IsExpired)
                {
                    days = BBSLicenseConstants.LicenseExpired;
                }
                else
                {
                    days = bbsLic.DaysToExpiration.ToString();
                }
            }
            return(days);
        }