Example #1
0
        /// <summary>
        /// Creates a new instance of the <see cref="SlickUploadModule" /> class.
        /// </summary>
        public SlickUploadModule()
        {
            _licenseType = LicenseType.Evaluation;
            _licenseScope = LicenseScope.WebSite;
            //_license = (KrystalwareRuntimeLicense)new KrystalwareLicenseProvider().GetLicense(null, typeof(SlickUploadModule), this, false);
            _license = (KrystalwareRuntimeLicense)KrystalwareLicenseProvider.GetLicense(typeof(SlickUploadModule), "<RSAKeyValue><Modulus>tk384UItx23mrOJcdDqipI05NXJKZAbUL0ewFaloFzpUBFV8AQd1hUSZ9XVgNAPqBLej9rUz4v08vi2rQ/fqJXtWieQSdwa7fe+ZjaS2qYGeBWZVpEDXwT5fG63+c2MlLjX0fKMQ7FU0OkZPo76Sj1O5cIjMlX9nvOQnevW0ABM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
            
            List<string> licensedUrls = new List<string>();

            if (_license != null)
            {
                foreach (RuntimeLicensedProduct product in _license.LicensedProducts)
                {
                    if (product.AssemblyName.EndsWith(".SlickUpload") && Convert.ToInt32(product.Version) >= 6 && DateTime.Now <= product.ExpirationDate)
                    {
                        // changed to fix obfuscation issue
                        // if (product.Type > _licenseType)
                        if (product.Type != _licenseType)
                            _licenseType = product.Type;

                        // changed to fix obfuscation issue
                        // if (product.Scope > _licenseScope)
                        if (product.Scope != _licenseScope)
                                _licenseScope = product.Scope;

                        if (!string.IsNullOrEmpty(product.LicenseUrl))
                            licensedUrls.Add("." + product.LicenseUrl);
                    }
                }
            }

            _licensedUrls = licensedUrls.ToArray();
        }
Example #2
0
		public LicenseValidator(KrystalwareRuntimeLicense l)
		{
			if (l.LicenseKey == null)
				throw new ArgumentNullException("l");

			XmlDocument doc = new XmlDocument();

			doc.LoadXml(l.LicenseKey);

			_doc = doc;
		}
Example #3
0
        public LicenseValidator(KrystalwareRuntimeLicense l)
        {
            if (l.LicenseKey == null)
            {
                throw new ArgumentNullException("l");
            }

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(l.LicenseKey);

            _doc = doc;
        }
Example #4
0
        /// <summary>
        /// Creates a new instance of the <see cref="SlickUploadModule" /> class.
        /// </summary>
        public SlickUploadModule()
        {
            _licenseType  = LicenseType.Commercial;
            _licenseScope = LicenseScope.WebSite;
            //_license = (KrystalwareRuntimeLicense)new KrystalwareLicenseProvider().GetLicense(null, typeof(SlickUploadModule), this, false);
            _license = (KrystalwareRuntimeLicense)KrystalwareLicenseProvider.GetLicense(typeof(SlickUploadModule), "<RSAKeyValue><Modulus>tk384UItx23mrOJcdDqipI05NXJKZAbUL0ewFaloFzpUBFV8AQd1hUSZ9XVgNAPqBLej9rUz4v08vi2rQ/fqJXtWieQSdwa7fe+ZjaS2qYGeBWZVpEDXwT5fG63+c2MlLjX0fKMQ7FU0OkZPo76Sj1O5cIjMlX9nvOQnevW0ABM=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");

            List <string> licensedUrls = new List <string>();

            if (_license != null)
            {
                foreach (RuntimeLicensedProduct product in _license.LicensedProducts)
                {
                    if (product.AssemblyName.EndsWith(".SlickUpload") && Convert.ToInt32(product.Version) >= 6 && DateTime.Now <= product.ExpirationDate)
                    {
                        // changed to fix obfuscation issue
                        // if (product.Type > _licenseType)
                        if (product.Type != _licenseType)
                        {
                            _licenseType = product.Type;
                        }

                        // changed to fix obfuscation issue
                        // if (product.Scope > _licenseScope)
                        if (product.Scope != _licenseScope)
                        {
                            _licenseScope = product.Scope;
                        }

                        if (!string.IsNullOrEmpty(product.LicenseUrl))
                        {
                            licensedUrls.Add("." + product.LicenseUrl);
                        }
                    }
                }
            }

            _licensedUrls = licensedUrls.ToArray();
        }
		//internal License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        internal static License GetLicense(Type type, string key)
		{
			//if (System.Security.SecurityManager.SecurityEnabled == false)
			//	return null;
				
			KrystalwareRuntimeLicense l = null;

			string assembly = type.Assembly.GetName().Name;
			string licenseFile = assembly + ".xml.lic";

			// First, check if someone has set the license manually
			PropertyInfo[] licenseProperties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Static);

			foreach (PropertyInfo pi in licenseProperties)
			{
				if (pi.PropertyType == typeof(KrystalwareRuntimeLicense))
				{
					l = pi.GetValue(null, null) as KrystalwareRuntimeLicense;

					break;
				}
			}
            
            // First, check to see if there's a license file with the app
            if (l == null)
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/"));

            // Next, check to see if there's a license file in the bin folder
            if (l == null)
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/bin/"));

            // Next, check to see if there's a license file in the App_Data folder
            if (l == null)
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/App_Data/"));

            // Next, check to see if there's a license resource somewhere
			if (l == null)
				l = LoadLicenseFromResource(type);

			// Next, check to see if there's a license file with the assembly
			if (l == null)
				l = LoadLicenseFromFile(type);
			
            if (l != null)
			{
				//string key = ((LicensePublicKeyAttribute)Attribute.GetCustomAttribute(type.Assembly, typeof(LicensePublicKeyAttribute))).XmlString;

				if (key != null)
				{
					KeyInfo keyInfo = LicenseValidator.GetKeyInfoFromXml(key);

					LicenseValidator validator = new LicenseValidator(l);

					if (!validator.IsValid(keyInfo))
						l = null;
				}
				else
				{
					l = null;
				}
			}

			// If not, create a new evaluation license
			if (l == null)
			{
				string version = type.Assembly.GetName().Version.Major.ToString();

				l = new KrystalwareRuntimeLicense(assembly, version);
			}

			return l;
		}
Example #6
0
        //internal License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        internal static License GetLicense(Type type, string key)
        {
            //if (System.Security.SecurityManager.SecurityEnabled == false)
            //	return null;

            KrystalwareRuntimeLicense l = null;

            string assembly    = type.Assembly.GetName().Name;
            string licenseFile = assembly + ".xml.lic";

            // First, check if someone has set the license manually
            PropertyInfo[] licenseProperties = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Static);

            foreach (PropertyInfo pi in licenseProperties)
            {
                if (pi.PropertyType == typeof(KrystalwareRuntimeLicense))
                {
                    l = pi.GetValue(null, null) as KrystalwareRuntimeLicense;

                    break;
                }
            }

            // First, check to see if there's a license file with the app
            if (l == null)
            {
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/"));
            }

            // Next, check to see if there's a license file in the bin folder
            if (l == null)
            {
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/bin/"));
            }

            // Next, check to see if there's a license file in the App_Data folder
            if (l == null)
            {
                l = LoadLicenseFromFile(type, HostingEnvironment.MapPath("~/App_Data/"));
            }

            // Next, check to see if there's a license resource somewhere
            if (l == null)
            {
                l = LoadLicenseFromResource(type);
            }

            // Next, check to see if there's a license file with the assembly
            if (l == null)
            {
                l = LoadLicenseFromFile(type);
            }

            if (l != null)
            {
                //string key = ((LicensePublicKeyAttribute)Attribute.GetCustomAttribute(type.Assembly, typeof(LicensePublicKeyAttribute))).XmlString;

                if (key != null)
                {
                    KeyInfo keyInfo = LicenseValidator.GetKeyInfoFromXml(key);

                    LicenseValidator validator = new LicenseValidator(l);

                    if (!validator.IsValid(keyInfo))
                    {
                        l = null;
                    }
                }
                else
                {
                    l = null;
                }
            }

            // If not, create a new evaluation license
            if (l == null)
            {
                string version = type.Assembly.GetName().Version.Major.ToString();

                l = new KrystalwareRuntimeLicense(assembly, version);
            }

            return(l);
        }