Exemplo n.º 1
0
        public RsaLicense GetLicense(Type type)
        {
            RsaLicense license = null;

            if (hash.ContainsKey(type))
            {
                license = (RsaLicense)hash[type];
            }
            return(license);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called by LicenseManager to retrieve a license
        /// </summary>
        /// <param name="context">Context of request (design/runtime)</param>
        /// <param name="type">Control type needing license</param>
        /// <param name="instance">Control instance needing license</param>
        /// <param name="allowExceptions">true if a LicenseException should be thrown when the component cannot be granted a license; otherwise, false.</param>
        /// <returns></returns>
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            string attrGuid  = "";
            string publicKey = "";

            // pull licensing data (guid/publickey) from custom attributes
            // on the control
            RsaLicenseDataAttribute licDataAttr = GetRsaLicenseDataAttribute(type);

            if (licDataAttr == null)
            {
                return(null);
            }
            publicKey = licDataAttr.PublicKey;
            attrGuid  = licDataAttr.Guid;

            // if in Design mode create and return non-expiring license
            // so design time ASP.NET is always working
            if (context.UsageMode == LicenseUsageMode.Designtime)
            {
                return(new RsaLicense(type, "", attrGuid, DateTime.MaxValue));
            }

            // check cache for cached license information
            RsaLicense license  = licenseCache.GetLicense(type);
            string     keyValue = "";

            if (license == null)
            {
                // check the license folder under the web root for a
                // license file and parse key data from it
                keyValue = LoadLicenseData(type);

                // validate the new license data key value
                DateTime expireDate = new DateTime();
                if (IsKeyValid(keyValue, publicKey, attrGuid, type, ref expireDate))
                {
                    license = new RsaLicense(type, keyValue, attrGuid, expireDate);
                    licenseCache.AddLicense(type, license);
                }
            }
            return(license);
        }
Exemplo n.º 3
0
 public void AddLicense(Type type, RsaLicense license)
 {
     hash.Add(type, license);
 }