Beispiel #1
0
        /// <summary>
        /// Checks if a feature license is valid
        /// </summary>
        /// <param name="licensePath">Full path to license file</param>
        /// <param name="featureName">Name of feature to check</param>
        /// <param name="passCode">Passcode - A token between the client and the server</param>
        /// <param name="bThrow">Throw exception in case of failure</param>
        /// <returns></returns>
        public bool IsValid(string licensePath, string featureName, string passCode, bool bThrow)
        {
            string      licenseSignature;
            LicenseInfo licenseInformation = GetLicenseFromFile(licensePath, passCode, out licenseSignature);

            licenseInformation.computerID = MMDBLicenser.GetComputerId();
            string signature = CreateSignature(licenseInformation);

            if (signature != licenseSignature)
            {
                if (bThrow)
                {
                    throw (new LicenseException("License information does not match it's signature"));
                }
                return(false);
            }

            if (licenseInformation.kind == LicenseType.NodeLocked)
            {
                if (licenseInformation.computerID != GetComputerId())
                {
                    if (bThrow)
                    {
                        throw (new LicenseException("License is customed to a different computer"));
                    }
                    return(false);
                }
            }

            foreach (FeatureInfo feature in licenseInformation.features)
            {
                if (feature.featureName == featureName)
                {
                    if (feature.timeDepend)
                    {
                        if (DateTime.Now > feature.expiration)
                        {
                            if (bThrow)
                            {
                                throw (new LicenseException("Feature has been expired"));
                            }
                            return(false);
                        }
                    }
                    return(true);
                }
            }

            if (bThrow)
            {
                throw (new LicenseException("Feature not found"));
            }
            return(false);
        }
Beispiel #2
0
 public bool IsValid()
 {
     bool returnvalue = false;
     MMDBLicenser l = new MMDBLicenser();
     try
     {
         string LicensePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\" +
             ConfigurationSettings.AppSettings["LicenseFile"].ToString();
         returnvalue = l.IsValid(LicensePath, FeatureName, Passcode, false);
     }
     catch (Exception err)
     {
         MMDBLogFile.Log(err.Message);
     }
     return returnvalue;
 }
Beispiel #3
0
        public bool IsValid()
        {
            bool         returnvalue = false;
            MMDBLicenser l           = new MMDBLicenser();

            try
            {
                string LicensePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + @"\" +
                                     ConfigurationSettings.AppSettings["LicenseFile"].ToString();
                returnvalue = l.IsValid(LicensePath, FeatureName, Passcode, false);
            }
            catch (Exception err)
            {
                MMDBLogFile.Log(err.Message);
            }
            return(returnvalue);
        }