Пример #1
0
 /// <summary>
 /// When overridden in a derived class, restores the pre-installation state of the computer.
 /// </summary>
 /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the pre-installation state of the computer.</param>
 /// <exception cref="T:System.ArgumentException">
 /// The <paramref name="savedState"/> parameter is null.
 /// -or-
 /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted.
 /// </exception>
 /// <exception cref="T:System.Configuration.Install.InstallException">
 /// An exception occurred during the <see cref="M:System.Configuration.Install.Installer.Rollback(System.Collections.IDictionary)"/> phase
 /// of the installation. This exception is ignored and the rollback continues.
 /// However, the computer might not be fully reverted to its initial state after the rollback completes.
 /// </exception>
 public override void Rollback(IDictionary savedState)
 {
     LicenseFile.Uninstall();
     FileNames.DeleteKeys();
     ManifestManagement.DeleteDeployManifest();
     base.Rollback(savedState);
 }
Пример #2
0
 /// <summary>
 /// This is the constructor for the <c>ProcessorConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public ProcessorConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Processor Constraint";
     base.Description  = "This ProcessorConstraint constrains the user to only use the license ";
     base.Description += "with a given OS or Processor.";
 }
Пример #3
0
 /// <summary>
 /// Removes an installation.
 /// </summary>
 /// <param name="savedState">
 /// An IDictionary used to save information needed to perform a commit, rollback, or uninstall operation.
 /// </param>
 public override void Uninstall(System.Collections.IDictionary savedState)
 {
     LicenseFile.Uninstall();
     FileNames.DeleteKeys();
     ManifestManagement.DeleteDeployManifest();
     base.Uninstall(savedState);
 }
Пример #4
0
 /// <summary>
 /// This is the constructor for the <c>VersionConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public VersionConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Version Constraint";
     base.Description  = "This VersionConstraint constrains the user to only use the license ";
     base.Description += "with a given range of versions attached to an Assembly.";
 }
Пример #5
0
        public static async Task <MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null)
        {
            var mac  = _networkManager.GetMacAddress();
            var data = new Dictionary <string, string> {
                { "feature", feature }, { "key", SupporterKey }, { "mac", mac }, { "mb2equiv", mb2Equivalent }, { "legacykey", LegacyKey }
            };

            var reg = new RegRecord();

            try
            {
                using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
                {
                    reg = jsonSerializer.DeserializeFromStream <RegRecord>(json);
                }

                if (reg.registered)
                {
                    LicenseFile.AddRegCheck(feature);
                }
            }
            catch (Exception)
            {
                //if we have trouble obtaining from web - allow it if we've validated in the past 30 days
                reg.registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30);
            }

            return(new MBRegistrationRecord {
                IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true
            });
        }
Пример #6
0
        /// <summary>
        /// It is called by the constructor at the end of the license validation process if a proper license file can be opened.
        /// By default it traces the information about the license to the <see cref="LicenseTraceSource"/> as verbose message.
        /// If implemented by the derived class the current license can be used to get more information from it.
        /// </summary>
        /// <param name="license">The current license for temporal use. The current license is disposed just after returning from this method
        /// </param>
        /// <remarks>
        /// Because the current license is disposed in the base class just after returning from this method, it must not be
        /// assigned locally to keep it for future use. To keep it for future use the derived class must make a local copy.
        /// </remarks>
        protected virtual void TraceCurrentLicense(LicenseFile license)
        {
            string format = "Obtained valid license for {0}, runtime={1}, volume={2}";
            string msg    = string.Format(format, typeof(type).FullName, license.RunTimeConstrain, license.VolumeConstrain);

            LicenseTraceSource.TraceVerbose(0, msg);
        }
Пример #7
0
 /// <summary>
 /// This is the constructor for the <c>DayTimeConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public DayTimeConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Day Time Constraint";
     base.Description  = "The DayTimeConstraint constrains the user ";
     base.Description += "to only using this license during a period of time within a day.  I.E. A user may ";
     base.Description += "use the license between midnight and 7am and 5pm and midnight - Non business hours.";
 }
Пример #8
0
 /// <summary>
 /// This is the constructor for the <c>DesigntimeConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public DesigntimeConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Design Time Constraint";
     base.Description  = "This DesigntimeConstraint constrains the user to only running ";
     base.Description += "the license in a design time environment.  If it is not in a ";
     base.Description += "Design Time environment then this constraint will fail.";
 }
Пример #9
0
 /// <summary>
 /// This is the constructor for the <c>UsageConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public UsageConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Usage Constraint";
     base.Description  = "This UsageConstraint constrains the user to a usage ";
     base.Description += "limit. It supports a Maximum Usage, Hit and Days ";
     base.Description += "count. Once the maximum number is reached the license ";
     base.Description += "expires.";
 }
Пример #10
0
 /// <summary>
 /// This is the constructor for the <c>BetaConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public BetaConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Beta Constraint";
     base.Description  = "The BetaConstraint constrains the user to a given time ";
     base.Description += "period.  It supports an end date that the license will ";
     base.Description += "expire. It also has the ability to show the user a link ";
     base.Description += "to download an update to the beta once it expires.";
 }
Пример #11
0
 /// <summary>
 /// This is the constructor for the <c>DemoConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public DemoConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Demo Constraint";
     base.Description  = "This DemoConstraint constrains the user to a given time period ";
     base.Description += "or duration.  It supports start and end date that the license ";
     base.Description += "will expire.  It also support a duration, to constrain the ";
     base.Description += "license to.";
 }
Пример #12
0
 internal static void InstallLicense(string user, string company, string email, bool loadLicenseFromDefaultContainer, string alternativeProductName, string licenseUnlockCode, Assembly assembly)
 {
     if (assembly == null)
     {
         throw new ArgumentNullException(nameof(assembly), $"Entring {nameof(InstallLicense)} with null argument.");
     }
     LicenseTraceSource.TraceVerbose(39, $"Entering InstallLicense {user}, {company}, {email}");
     ManifestManagement.WriteDeployManifest(assembly, alternativeProductName);
     LicenseFile.Install(user, company, email, FileNames.LicenseFilePath, loadLicenseFromDefaultContainer, licenseUnlockCode);
 }
Пример #13
0
 /// <summary>
 /// This is the constructor for the <c>AndConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public AndConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "And Constraint";
     base.Description  = "This AndConstraint contains a collection of constraints that ";
     base.Description += "will be grouped together as a bitwise AND operation.  It is ";
     base.Description += "validating the containing IConstraints and will be valid ";
     base.Description += "all the constraints contained are valid.  The purpose of this ";
     base.Description += "is to allow a user to force multiple constraints to pass before ";
     base.Description += "allowing the license to be valid.";
 }
Пример #14
0
 /// <summary>
 /// This is the constructor for the <c>OrConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 public OrConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Or Constraint";
     base.Description  = "This OrConstraint contains a collection of constraints that will ";
     base.Description += "be grouped together as a bitwise OR operation.  It is responsible ";
     base.Description += "for validating the containing IConstraints and will be valid as ";
     base.Description += "long as one of the constraints contained is valid.  The purpose of ";
     base.Description += "this is to allow multiple constraints to be added and create a run ";
     base.Description += "as long as one is valid scheme.";
 }
Пример #15
0
        /// <summary>
        /// Obtains a license from the application data path and adds it to the <paramref name="licenses"/> if exists.
        /// </summary>
        /// <param name="key">The encryption key to verify the license.</param>
        /// <param name="licenses">The licenses collection.</param>
        private void AddLicenseFromPaths(RSACryptoServiceProvider key, List <License> licenses)
        {
            LicenseFile lic = null;

            using (Stream stream = FileNames.CreateLicenseFileStream(FileMode.Open, FileAccess.Read, FileShare.Read))
                lic = LicenseFile.LoadFile(stream, key);
            if (lic != null)
            {
                licenses.Add(lic);
            }
        }
Пример #16
0
        /// <summary>
        /// Obtains a license from Isolated Storage if exist.
        /// </summary>
        /// <param name="licFile">The string name of the license file.</param>
        /// <param name="key">The encryption key to verify the license.</param>
        /// <param name="licenses">The licenses collection to add new license if exist.</param>
        private void AddLicenseFromIsolatedStorage(string licFile, RSACryptoServiceProvider key, List <License> licenses)
        {
            LicenseFile license = null;

            using (var reader = IsolatedStorageAccess.CreateIsolatedStorageLicenseStream(FileMode.Open))
                license = LicenseFile.LoadFile(reader, key);
            if (license != null)
            {
                licenses.Add(license);
            }
        }
Пример #17
0
        private void ValidateLicense(ref uint?runTimeConstrain, ref uint?volumeConstrain)
        {
            License lic       = null;
            bool    m_DemoVer = true;

            if (!LicenseManager.IsValid(this.GetType(), this, out lic))
            {
                Tracer.TraceWarning(157, src, string.Format(Resources.Tx_LicNoFileErr + Resources.Tx_LicCap));
            }
            else
            {
                using (lic)
                {
                    LicenseFile m_license           = lic as LicenseFile;
                    MaintenanceControlComponent mcc = new MaintenanceControlComponent();
                    if (mcc.Warning != null)
                    {
                        Tracer.TraceInformation(159, this.GetType().Name, "The following warning(s) appeared during loading of the license: " + mcc.Warning);
                    }
                    UserOrganization = m_license.User.Organization;
                    UserEmail        = m_license.User.Email;
                    Debug.Assert(m_license != null);
                    if (!String.IsNullOrEmpty(m_license.FailureReason))
                    {
                        Tracer.TraceWarning(167, src, string.Format(m_license.FailureReason + Resources.Tx_LicCap));
                    }
                    else
                    {
                        m_DemoVer = false;
                        if (m_license.RunTimeConstrain > 0)
                        {
                            runTimeConstrain = 60 * 60 * (uint)m_license.RunTimeConstrain;
                        }
                        else
                        {
                            runTimeConstrain = null;
                        }
                        if (m_license.VolumeConstrain > 0)
                        {
                            volumeConstrain = (uint)m_license.VolumeConstrain;
                        }
                        else
                        {
                            volumeConstrain = null;
                        }
                    }
                }
            }
            if (m_DemoVer)
            {
                Tracer.TraceWarning(183, src, string.Format(Resources.Tx_LicDemoModeInfo + Resources.Tx_LicCap));
            }
        }
Пример #18
0
 public ActionResult License()
 {
     try
     {
         LicenseData license = LicenseFile.Read(DataRepository.Instance.Key.PrivateKey);
         return(View((object)license));
     }
     catch (Exception)
     {
         return(View("Index"));
     }
 }
        public static async Task <MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null, string version = null)
        {
            //check the reg file first to alleviate strain on the MB admin server - must actually check in every 30 days tho
            var reg = new RegRecord {
                registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30)
            };
            var success = reg.registered;

            if (!reg.registered)
            {
                var mac  = _networkManager.GetMacAddress();
                var data = new Dictionary <string, string>
                {
                    { "feature", feature },
                    { "key", SupporterKey },
                    { "mac", mac },
                    { "mb2equiv", mb2Equivalent },
                    { "legacykey", LegacyKey },
                    { "ver", version },
                    { "platform", Environment.OSVersion.VersionString },
                    { "isservice", _applicationHost.IsRunningAsService.ToString().ToLower() }
                };

                try
                {
                    using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
                    {
                        reg     = jsonSerializer.DeserializeFromStream <RegRecord>(json);
                        success = true;
                    }

                    if (reg.registered)
                    {
                        LicenseFile.AddRegCheck(feature);
                    }
                    else
                    {
                        LicenseFile.RemoveRegCheck(feature);
                    }
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Error checking registration status of {0}", e, feature);
                }
            }

            return(new MBRegistrationRecord {
                IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true, RegError = !success
            });
        }
Пример #20
0
        /// <summary>
        /// It completes the install transaction.
        /// </summary>
        /// <param name="savedState">An <see cref="T:System.Collections.IDictionary"/> that contains the state
        /// of the computer after all the installers in the collection have run.
        /// </param>
        /// <exception cref="T:System.ArgumentException">
        /// The <paramref name="savedState"/> parameter is null.
        /// -or-
        /// The saved-state <see cref="T:System.Collections.IDictionary"/> might have been corrupted.
        /// </exception>
        /// <exception cref="T:System.Configuration.Install.InstallException">
        /// An exception occurred during the <see cref="M:System.Configuration.Install.Installer.Commit(System.Collections.IDictionary)"/> phase
        /// of the installation. This exception is ignored and the installation continues.
        /// However, the application might not function correctly after the installation is complete.
        /// </exception>
        public override void Commit(IDictionary savedState)
        {
            base.Commit(savedState);
            InstallContext _Context = this.Context;

            try
            {
                ManifestManagement.WriteDeployManifest(_Context);
                LicenseFile.Install(_Context.Parameters[InstallContextNames.User], _Context.Parameters[InstallContextNames.Company], _Context.Parameters[InstallContextNames.Email], FileNames.LicenseFilePath, true, null);
            }
            catch (Exception ex)
            {
                throw new InstallException("Installation Error", ex);
            }
        }
Пример #21
0
 /// <summary>
 /// This is responsible for saving the license into the proper locations.
 /// </summary>
 /// <param name="type">The object <c>Type</c> being licensed.</param>
 /// <param name="license">The license to save.</param>
 /// <param name="key">The encryption key to verify the license.</param>
 private void Save(Type type, LicenseFile license, RSACryptoServiceProvider key)
 {
     Debug.WriteLine("OpenLicenseProvider: PerformSave function");
     if (CheckIfWebApplication()) // Web app
     {
         //Force the save outside the bin directory since this causes the app to restart.
         string absoluteFilePath = HttpContext.Current.Server.MapPath("~" + Path.DirectorySeparatorChar) + license.Product.LicFileName;
         Save(license, key, false, absoluteFilePath);
         WebApplicationLicenseCollector.AddLicense2Collector(type, license);
     }
     else
     {
         Save(license, key, true, FileNames.ApplicationDataPath);
     }
 }
Пример #22
0
        internal static LicenseFile LoadLicense()
        {
            LicenseFile license     = null;
            string      licenseCode = "";

            if (CurrentSite != null)
            {
                licenseCode = CurrentSite.LicenceCode;
            }
            string serverName = Environment.MachineName;
            string path       = AppDomain.CurrentDomain.BaseDirectory;
            //string ipAddress = HttpContext.Current.Request.ServerVariables["remote_host"];
            string relativeUrl = HttpContext.Current.Request.Url.PathAndQuery;
            string completeUrl = HttpContext.Current.Request.Url.ToString();
            string domainName  = completeUrl.Replace(relativeUrl, "");

            try
            {
                BitSite.LicServiceReference.LicServiceClient client = BitMetaServerServicesHelper.GetLicenseServiceClient();
                //BitSite.BitAutorisationService.AutorisationClient client = BitAutorisationServiceHelper.GetClient();
                license = client.GetLicense(licenseCode, serverName, path, domainName);
                client.Close();
            }
            catch (Exception ex)
            {
            }

            if (license != null)
            {
                license.Decrypt();
                //opslaan als bestand. Er is vanuit Fred een verzoek dat licentie blijft werken, mocht lic server down zijn
                //dan lic laden vanuit bestand. Hier laatste versie opslaan.
                //hierdoor is license niet meer hackproof...
                license.SaveAsFile();

                CurrentSite.IsValidLicense = true;
            }
            else
            {
                //lic server is down: laden vanuit bestand
                license = new LicenseFile();

                license.LoadFromFile(licenseCode);

                CurrentSite.IsValidLicense = license.IsValid;
            }
            return(license);
        }
Пример #23
0
        public async Task UpdateSupporterKey(string newValue)
        {
            if (newValue != null)
            {
                newValue = newValue.Trim();
            }

            if (!string.Equals(newValue, LicenseFile.RegKey, StringComparison.Ordinal))
            {
                LicenseFile.RegKey = newValue;
                LicenseFile.Save();

                // Reset this
                await GetRegistrationStatusInternal("MBSupporter", true, _appHost.ApplicationVersion.ToString(), CancellationToken.None).ConfigureAwait(false);
            }
        }
Пример #24
0
        public async Task UpdateSupporterKey(string newValue)
        {
            if (newValue != null)
            {
                newValue = newValue.Trim();
            }

            if (!string.Equals(newValue, LicenseFile.RegKey, StringComparison.Ordinal))
            {
                LicenseFile.RegKey = newValue;
                LicenseFile.Save();

                // Reset this
                await IsSupporter().ConfigureAwait(false);
            }
        }
Пример #25
0
        private async Task <List <LicenseFile> > GetLicenses(FileInfo[] licenseFiles)
        {
            var licenses = new List <LicenseFile>();

            foreach (var file in licenseFiles)
            {
                var license = new LicenseFile
                {
                    FileName = file.Name,
                    FullName = file.FullName
                };

                licenses.Add(license);
                license.Content = await _fileUtilities.ReadFile(file);
            }

            return(licenses);
        }
Пример #26
0
        public void Test(string privateKey)
        {
            if (string.IsNullOrEmpty(privateKey))
            {
                MessageBox.Show("Create or open a private/public key pair file");
                return;
            }
            StringBuilder licenseContent = new StringBuilder();

            licenseContent.Append("<license>"); licenseContent.AppendFormat("<customer>{0}</customer>", "Customer");
            licenseContent.AppendFormat("<company>{0}</company>", "Company");
            licenseContent.AppendFormat("<trial>{0}</trial>", "Days");
            licenseContent.Append("</license>");

            LicenseFile license = new LicenseFile();

            XmlDocument fileContent = license.SignXmlDocument(licenseContent.ToString(), privateKey); StringToFile(@"c:\temp\testlicense.lic", fileContent.OuterXml);
        }
Пример #27
0
        public LicenseFile GetLicense(string licenseCode, string serverName, string path, string domainName)
        {
            string      logMsg  = "Licentie aanvraag voor code: " + licenseCode + ", server: " + serverName + ", locatie: " + path + ", domain: " + domainName + "\r\n";
            LicenseFile licFile = null;

            try
            {
                License license = null;
                string where = String.Format("Code = '{0}'", licenseCode);
                license      = BaseObject.GetFirst <License>(where);
                if (license != null && license.IsActive)
                {
                    //versleutel license met path, url, datum
                    licFile = license.CreateLicenseFile(serverName, path, domainName);
                    if (license == null)
                    {
                        logMsg += "Geen licFile aangemaakt";
                    }
                    else
                    {
                        logMsg += "licFile aangemaakt ";
                    }
                }
                else
                {
                    if (license == null)
                    {
                        logMsg += "Geen licentie gevonden voor code: " + licenseCode;
                    }
                    else if (license.IsActive)
                    {
                        logMsg += "Licentie is niet actief ";
                    }
                }
            }
            catch (Exception ex)
            {
                //log error
                logMsg += "ERROR: " + ex.Message + "\r\n " + ex.StackTrace;
            }
            TryWriteLogMsg(logMsg);
            return(licFile);
        }
Пример #28
0
        public bool SendNewPassword(string email)
        {
            bool         returnValue = false;
            BitplateUser user        = BaseObject.GetFirst <BitplateUser>("Email ='" + email + "'");
            //voor als je aankomt vanuit login.aspx --> nieuw ww aanvragen --> dan is er nog geen lic gezet
            LicenseFile lic = SessionObject.CurrentLicense;

            if (user != null)
            {
                returnValue = user.SendNewPasswordEmail();
                if (user.IsMultiSiteUser)
                {
                    string domainName = getDomainName();
                    UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                    client.SetUserData(user, domainName);
                }
            }
            return(returnValue);
        }
Пример #29
0
 /// <summary>
 /// This saves the license in the proper location.
 /// </summary>
 /// <param name="licenseFile">The license file to save.</param>
 /// <param name="key">The encryption key to verify the license.</param>
 /// <param name="useIsolatedStorage">Save to IsolatedStorage if true if saving in the application data path causes an exception.</param>
 /// <param name="appDataFilePath">The application data file path.</param>
 private void Save
     (LicenseFile licenseFile, RSACryptoServiceProvider key, bool useIsolatedStorage, string appDataFilePath)
 {
     Debug.WriteLine("OpenLicenseProvider: Save Function");
     try
     {
         using (Stream fileStream = FileNames.CreateLicenseFileStream(FileMode.Create, FileAccess.Write, FileShare.Write))
             licenseFile.SaveFile(fileStream, key);
     }
     catch (Exception ex)
     {
         if (!useIsolatedStorage)
         {
             throw new LicenseFileException(Resources.ErrStr_SaveLicense_UnableToSaveLicense + ex.Message);
         }
     }
     if (useIsolatedStorage)
     {
         using (Stream writer = IsolatedStorageAccess.CreateIsolatedStorageLicenseStream(FileMode.Create))
             licenseFile.SaveFile(writer, key);
     }
 }
Пример #30
0
 /// <summary>
 /// This is the constructor for the <c>DomainConstraint</c>.  The constructor
 /// is used to create the object and assign it to the proper license.
 /// </summary>
 /// <param name="license">
 /// The <see cref="LicenseFile">LicenseFile</see> this constraint
 /// belongs to.
 /// </param>
 /// <remarks>
 /// This constructor initializes the current domain.  When initializing this
 /// an exception can be thrown.  The constructor will catch the exception
 /// and set the current domain to an empty string.  The license can handle this
 /// by setting one of the domains to an empty string which should allow the
 /// validation to pass.  This call will throw an exception only when used in
 /// a non web environment.
 /// </remarks>
 public DomainConstraint(LicenseFile license)
 {
     base.License      = license;
     base.Name         = "Domain Constraint";
     base.Description  = "This DomainConstraint constrains the user to running within a given ";
     base.Description += "set of Domains.  This is primarily used for web based licensing to make ";
     base.Description += "sure that the license is only used for specific domains.";
     if (HttpContext.Current == null)
     {
         this.CurrentDomain = String.Empty;
     }
     else
     {
         try
         {
             this.context          = HttpContext.Current;
             this.currentDomainUri = this.context.Request.Url;
             this.CurrentDomain    = this.currentDomainUri.Host;
         }
         catch { this.CurrentDomain = String.Empty; }
     }
 }