public ScutexLicense Validate(ScutexLicense scutexLicense)
        {
            try
            {
                if (!EventLog.SourceExists("Scutex"))
                {
                    EventLog.CreateEventSource("Scutex", "Application");
                }

                if (scutexLicense.IsTrialValid)
                {
                    EventLog.WriteEntry("Scutex", "SCUTEX: Your trial is invalid, this can be due to tampering or system changes/corruption.", EventLogEntryType.Warning, 500);
                    Environment.Exit(1001);
                }

                if (scutexLicense.WasTrialFristRun)
                {
                    EventLog.WriteEntry("Scutex", "SCUTEX: This is your first time running the product, your trail starts now.", EventLogEntryType.Warning, 500);
                }

                if (scutexLicense.IsTrialExpired)
                {
                    EventLog.WriteEntry("Scutex", "SCUTEX: Your trial has expired, please buy the product if you wish to continue using it.", EventLogEntryType.Warning, 500);
                    Environment.Exit(1001);
                }
            }
            catch { }

            return(scutexLicense);
        }
Ejemplo n.º 2
0
        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            ScutexLicense license = null;

            try
            {
                if (context.UsageMode == LicenseUsageMode.Designtime)
                {
                    if (_licensingManager != null)
                    {
                        license = _licensingManager.Validate(InteractionModes.Silent);
                    }

                    if (license != null)
                    {
                        if (!license.IsLicenseValid())
                        {
                            //throw new LicenseException(type, instance, "Invalid license or trial expired");
                            return(null);
                        }
                        else
                        {
                            return(new ScutexComponentLicense(license));
                        }
                    }
                }

                return(null);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public ScutexLicense Validate(ScutexLicense scutexLicense)
        {
            WriteScutexHeader();

            if (scutexLicense.IsTrialValid)
            {
                Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialInvalid);
                Thread.Sleep(2000);
                Environment.Exit(1001);
            }

            if (scutexLicense.WasTrialFristRun)
            {
                Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialFirstRun);
            }

            if (scutexLicense.IsTrialExpired)
            {
                Console.WriteLine(Resources.ConsoleInteractionService_Validate_TrialExpired);
                Thread.Sleep(2000);
                Environment.Exit(1001);
            }

            return(scutexLicense);
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            LicensingManager licensingManager = new LicensingManager(null);
            ScutexLicense    license          = licensingManager.Validate(InteractionModes.Gui);


            bool wasPressed = license.InterfaceInteraction.TryButtonClicked;

            Console.WriteLine(Guid.NewGuid().ToString());
            Console.WriteLine("Test Product");
            Console.WriteLine();

            Console.WriteLine(String.Format("Is Product Licensed: {0}", license.IsLicensed));
            Console.WriteLine(String.Format("Is Trial Valid: {0}", license.IsTrialValid));
            Console.WriteLine(String.Format("Is Trial Expired: {0}", license.IsTrialExpired));
            Console.WriteLine(String.Format("Is Trial Fault Reason: {0}", license.TrialFaultReason));
            Console.WriteLine(String.Format("Is Trial Remaining: {0}", license.TrialRemaining));
            Console.WriteLine(String.Format("Is Trial Elapsed: {0}", license.TrialUsed));
            Console.WriteLine(String.Format("Is Trial First Run: {0}", license.WasTrialFristRun));

            Console.WriteLine();
            Console.WriteLine("Press ENTER to exit.");
            Console.ReadLine();
        }
Ejemplo n.º 5
0
        private void ShowLicensingWindow(ScutexLicense scutexLicense)
        {
            ThreadRunner runner = new ThreadRunner();

            runner.RunInSTA(
                delegate
            {
                LicenseWindow window = new LicenseWindow(this, scutexLicense, _clientLicenseService.GetClientLicense());
                window.Show();
                System.Windows.Threading.Dispatcher.Run();
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Attempts to register the software and turn the version into a full
        /// version. This method may call remote web services, or authenticate
        /// locally ('offline') depending on the settings.
        ///
        /// The Ex register method is an external integration point for programs
        /// that may not be able to consume complex .Net object's. This should only
        /// be used when you cannot use the returned model object of the normal Register
        /// method.
        /// </summary>
        /// <remarks>
        /// Unlike the non-Ex register method this one won't kill the program.
        /// The first index of the returned array is an ok check, if it's false
        /// the system failed required security checks and should be aborted.
        /// </remarks>
        /// <param name="licenseKey">Plain text license key to attempt to register</param>
        /// <returns></returns>
        public object[] RegisterEx(string licenseKey)
        {
            List <object> data = new List <object>();

            ScutexLicense sl = Register(licenseKey);

            data.Add(true);
            data.Add(sl.IsLicensed);
            data.Add(sl.IsActivated);
            data.Add(sl.ActivatedOn);

            return(data.ToArray());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Attempts to register the software and turn the version into a full
        /// version. This method may call remote web services, or authenticate
        /// locally ('offline') depending on the settings.
        /// </summary>
        /// <remarks>
        /// If the state of Scutex cannot be verified, for example the
        /// data file or Licensing assembly was tampered with, this method
        /// will warn the user and kill the entire process.
        /// </remarks>
        /// <param name="licenseKey">
        /// Plain text license key to attempt to register
        /// </param>
        public ScutexLicense Register(string licenseKey)
        {
            if (String.IsNullOrEmpty(licenseKey))
            {
                throw new ScutexAuditException();
            }

            ScutexLicense scutexLicense = licenseManagerService.GetScutexLicense();

            RegisterResult result = _registerService.Register(licenseKey, _clientLicenseService.GetClientLicense(), scutexLicense);

            return(result.ScutexLicense);
        }
Ejemplo n.º 8
0
        public LicenseWindow(object licensingManager, ScutexLicense scutexLicense, ClientLicense clientLicense)
        {
            InitializeComponent();

            _clientLicense    = clientLicense;
            _licensingManager = licensingManager as LicensingManager;
            _scutexLicense    = scutexLicense;

            SetIcon();
            SetWindowIcon();
            SetFormData();
            SetFormDisplay();
            SetTrialDelayTimer();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Validates the software trial/demo/license status. This method will
        /// determine the status and will either preset the user with that
        /// information or just log it.
        ///
        /// The Ex Validate method is an external integration point for programs
        /// that may not be able to consume complex .Net object's. This should only
        /// be used when you cannot use the returned model object of the normal
        /// Validate method.
        /// </summary>
        /// <remarks>
        /// Unlike the non-Ex Validate method this one won't kill the program.
        /// The first index of the returned array is an ok check, if it's false
        /// the system failed required security checks and should be aborted.
        /// </remarks>
        /// <param name="interactionMode"></param>
        /// <returns></returns>
        public object[] ValidateEx(int interactionMode)
        {
            List <object> data = new List <object>();

            ScutexLicense sl = Validate((InteractionModes)interactionMode);

            data.Add(true);
            data.Add(sl.IsTrialExpired);
            data.Add(sl.IsTrialValid);
            data.Add(sl.TrialFaultReason);
            data.Add(sl.IsLicensed);
            data.Add(sl.IsActivated);

            return(data.ToArray());
        }
Ejemplo n.º 10
0
        public ScutexLicense Validate(ScutexLicense scutexLicense)
        {
            if (scutexLicense.IsTrialValid)
            {
                Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialInvalid);
            }

            if (scutexLicense.WasTrialFristRun)
            {
                Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialFirstRun);
            }

            if (scutexLicense.IsTrialExpired)
            {
                Debug.WriteLine(Resources.ConsoleInteractionService_Validate_TrialExpired);
            }

            return(scutexLicense);
        }
Ejemplo n.º 11
0
        public RegisterContent(ClientLicense clientLicense, ScutexLicense scutexLicense)
            : this()
        {
            _clientLicense = clientLicense;
            _scutexLicense = scutexLicense;

            if (_clientLicense != null)
            {
                switch (_clientLicense.KeyGeneratorType)
                {
                case KeyGeneratorTypes.StaticSmall:
                    txtLicenseKey.InputMask = @"www-wwwwww-wwww";
                    break;

                case KeyGeneratorTypes.StaticLarge:
                    txtLicenseKey.InputMask = @"WWWWW-WWWWW-WWWWW-WWWWW-WWWWW";
                    break;
                }
            }
        }
Ejemplo n.º 12
0
        public ScutexLicense GetScutexLicense(ClientLicense clientLicense)
        {
            ScutexLicense scutexLicense = new ScutexLicense();

            scutexLicense.TrialFaultReason          = TrialFaultReasons.None;
            scutexLicense.IsTrialValid              = true;
            scutexLicense.LastRun                   = clientLicense.LastRun;
            scutexLicense.TrialSettings             = clientLicense.TrialSettings;
            scutexLicense.TrailNotificationSettings = clientLicense.TrailNotificationSettings;
            scutexLicense.IsCommunityEdition        = ApplicationConstants.IsCommunityEdition;

            if (!clientLicense.FirstRun.HasValue)
            {
                Logging.LogDebug(string.Format("Is First Run!"));
                clientLicense.FirstRun         = _networkTimeProvider.GetNetworkTime();
                scutexLicense.WasTrialFristRun = true;

                Logging.LogDebug(string.Format("FirstRun SetTo: {0}", clientLicense.FirstRun.Value));
            }
            else
            {
                Logging.LogDebug(string.Format("Is Existing Run!"));
                Logging.LogDebug(string.Format("FirstRun Date: {0}", clientLicense.FirstRun.Value));
                Logging.LogDebug(string.Format("NetTime Date: {0}", _networkTimeProvider.GetNetworkTime()));
            }

            if (clientLicense.LastRun.HasValue && _networkTimeProvider.GetNetworkTime() < clientLicense.LastRun)
            {
                Logging.LogDebug(string.Format("TIME FAULT"));
                Logging.LogDebug(string.Format("LastRun Date: {0}", clientLicense.LastRun.Value));
                Logging.LogDebug(string.Format("NetRun Date: {0}", _networkTimeProvider.GetNetworkTime()));
                Logging.LogDebug(string.Format("Delta: {0}", (_networkTimeProvider.GetNetworkTime() - clientLicense.LastRun.Value)));

                scutexLicense.IsTrialValid     = false;
                scutexLicense.TrialFaultReason = TrialFaultReasons.TimeFault;
            }

            clientLicense.LastRun = _networkTimeProvider.GetNetworkTime();

            Logging.LogDebug(string.Format("Old Run Count: {0}", clientLicense.RunCount));
            clientLicense.RunCount++;
            Logging.LogDebug(string.Format("New Run Count: {0}", clientLicense.RunCount));

            scutexLicense.FirstRun = clientLicense.FirstRun;

            switch (clientLicense.TrialSettings.ExpirationOptions)
            {
            case TrialExpirationOptions.Days:
                TimeSpan ts = clientLicense.FirstRun.Value -
                              _networkTimeProvider.GetNetworkTime().AddDays(-int.Parse(clientLicense.TrialSettings.ExpirationData));

                scutexLicense.TrialRemaining = ts.Days;

                if (ts.Days <= 0)
                {
                    scutexLicense.IsTrialExpired = true;
                    Logging.LogDebug(string.Format("Trial Expired"));
                }
                else
                {
                    scutexLicense.IsTrialExpired = false;
                    Logging.LogDebug(string.Format("Trial Not Expired"));
                }

                break;
            }

            // TODO: Need to set a fair amount of data here, like licensed edition, level, etc
            if (clientLicense.IsLicensed)
            {
                scutexLicense.IsLicensed = clientLicense.IsLicensed;
                Logging.LogDebug(string.Format("Product is licensed"));
            }
            else
            {
                Logging.LogDebug(string.Format("Product is not licensed"));
            }

            Logging.LogDebug(string.Format("Saving client license"));
            _clientLicenseService.SaveClientLicense(clientLicense);

            return(scutexLicense);
        }
Ejemplo n.º 13
0
 public ScutexLicense Validate(string licenseKey, ScutexLicense scutexLicense, ClientLicense clientLicense)
 {
     return(scutexLicense);
 }
Ejemplo n.º 14
0
        public RegisterResult Register(string licenseKey, LicenseBase scutexLicense, ScutexLicense license)
        {
            RegisterResult registerResult = new RegisterResult();

            registerResult.ScutexLicense = license;

            bool          result = _licenseKeyService.ValidateLicenseKey(licenseKey, scutexLicense, true);
            ClientLicense cl     = null;

            if (result)
            {
                KeyData keyData = _licenseKeyService.GetLicenseKeyData(licenseKey, scutexLicense, false);

                if (keyData.LicenseKeyType != LicenseKeyTypes.Enterprise && keyData.LicenseKeyType != LicenseKeyTypes.HardwareLockLocal)
                {
                    try
                    {
                        if (keyData.LicenseKeyType == LicenseKeyTypes.HardwareLock)
                        {
                            cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, _hardwareFingerprintService.GetHardwareFingerprint(FingerprintTypes.Default));
                        }
                        else
                        {
                            cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, false, (ClientLicense)scutexLicense, null);
                        }

                        if (cl.IsLicensed && cl.IsActivated)
                        {
                            registerResult.Result        = ProcessCodes.ActivationSuccess;
                            registerResult.ClientLicense = cl;
                        }
                        else
                        {
                            registerResult.Result = ProcessCodes.ActivationFailed;
                        }
                    }
                    catch
                    {
                        registerResult.Result = ProcessCodes.ActivationFailed;
                    }
                }
                else
                {
                    cl = _licenseActivationService.ActivateLicenseKey(licenseKey, null, true, (ClientLicense)scutexLicense, null);
                    registerResult.Result = ProcessCodes.LicenseKeyNotActivated;
                }
            }
            else
            {
                registerResult.Result = ProcessCodes.KeyInvalid;
            }

            if (cl != null)
            {
                license.IsLicensed  = cl.IsLicensed;
                license.IsActivated = cl.IsActivated;
                license.ActivatedOn = cl.ActivatedOn;
            }

            return(registerResult);
        }