コード例 #1
0
        /// <summary>
        /// Show activate dialog the first time the application is idle.
        /// </summary>
        void OnApplicationIdle(object sender, EventArgs e)
        {
            // Disconnect
            Application.Idle -= OnApplicationIdle;

            if (!(LicenseContainer.IsValidBlackBerryEvalLicense() || LicenseContainer.IsValidBlackBerryProLicense()))
            {
                Activate();
            }
        }
コード例 #2
0
        public void LicenseContainer_Serialization()
        {
            var hardwareId = Guid.NewGuid().ToString();
            var productId  = Guid.NewGuid().ToString();
            var lic        = new LicenseMock();//, DateTime.UtcNow, DateTime.UtcNow);

            lic.SetHarwareId(hardwareId);
            lic.SetProductId(productId);
            var con = new LicenseContainer
            {
                Signature = "signature"
            }.SetLicense(lic);

            output.WriteLine("ToJson:");
            var json = con.ToJson();

            output.WriteLine(json);

            output.WriteLine("FromJson:");
            var con2  = json.FromJson <LicenseContainer>();
            var json2 = con2.ToJson();

            output.WriteLine(json2);
            Assert.Equal(json, json2);
            Assert.True(con2.LicenseIs <LicenseMock>());
            var lic2 = con2.LicenseAs <LicenseMock>();

            Assert.NotNull(lic2);
            Assert.Equal(lic.HardwareId.Key, lic2.HardwareId.Key);
            Assert.Equal(lic.ProductId.Key, lic2.ProductId.Key);

            //Assert.Equal(con2.LicenseAs<LicenseMock>(), lic);

            var time = new Random((int)DateTime.Now.Ticks).Next(500, 1500);

            output.WriteLine("Time: " + time);
            Thread.Sleep(time);
            output.WriteLine("FromJson timed:");
            var con3  = json.FromJson <LicenseContainer>();
            var json3 = con3.ToJson();

            output.WriteLine(json3);

            Assert.Equal(json, json3);
            Assert.Equal(json2, json3);
            Assert.True(con3.LicenseIs <LicenseMock>());
            var lic3 = con3.LicenseAs <LicenseMock>();

            Assert.NotNull(lic3);
            Assert.Equal(lic.HardwareId.Key, lic3.HardwareId.Key);
            Assert.Equal(lic.ProductId.Key, lic3.ProductId.Key);

            //Assert.Equal(con3.LicenseAs<LicenseMock>(), lic);
        }
コード例 #3
0
        /// <summary>
        /// Try to activate the app
        /// </summary>
        internal void Activate()
        {
#if LICENSED
            if (Helper.Activation(ParentForm, LicenseContainer.GetBlackBerryLicense()))
            {
                UpdateLicensingInfo();
            }
#else
            // Keep this as literal string.
            MessageBox.Show("Download the licensed version from the My Account section of our website.");
#endif
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: Devidence7/Fuxion
 public LicenseContainer Request(LicenseRequest request)
 {
     return(LicenseContainer.Sign(new LicenseMock(), Const.FULL_KEY));
     //if (request is LicenseMock)
     //{
     //    var req = request as LicenseMock;
     //    var lic = new LicenseMock(req.HardwareId, req.ProductId,
     //        req.SaltoEnabled, req.PresenceEnabled, req.VisitsEnabled, req.LogisticEnabled, req.IntrusionEnabled);
     //    //string fullKey, publicKey;
     //    //LicensingManager.GenerateKey(out fullKey, out publicKey);
     //    return LicenseContainer.Sign(lic, FullKey);
     //}
     //throw new NotSupportedException($"License request of type '{request.GetType().Name}' is not supported by this provider");
 }
コード例 #5
0
        /// <summary>
        /// Refresh license info
        /// </summary>
        private void UpdateLicensingInfo()
        {
            var license = LicenseContainer.GetBlackBerryLicense();

            if (license.LicenseState != LicenseState.NotFound)
            {
                buttonActivate.Text = "Re-activate";
                lbLicStatus.Text    = String.Format("Licensed on: {0}, serial {1} ({2})", license.RuntimeAttributesKey, license.GetSerial(), GetLicenseType(license));
            }
            else
            {
                buttonActivate.Text = "Activate";
                lbLicStatus.Text    = String.Format("User account: {0}", license.RuntimeAttributesKey);
            }
        }
コード例 #6
0
        public void LicenseContainer_Signing()
        {
            var hardwareId = Guid.NewGuid().ToString();
            var productId  = Guid.NewGuid().ToString();
            var lic        = new LicenseMock();

            lic.SetHarwareId(hardwareId);
            lic.SetProductId(productId);
            var con = LicenseContainer.Sign(lic, Const.FULL_KEY);

            output.WriteLine("ToJson:");
            output.WriteLine(con.ToJson());
            output.WriteLine("License.ToJson:");
            output.WriteLine(con.License.ToJson());
            Assert.True(con.VerifySignature(Const.PUBLIC_KEY));
        }
コード例 #7
0
 /// <summary>
 /// Gets the type of license currently running.
 /// </summary>
 private static string GetLicenseType(License license)
 {
     if (license == null)
     {
         return("?");
     }
     if (LicenseContainer.IsValidBlackBerryProLicense())
     {
         return("Professional");
     }
     if (LicenseContainer.IsValidBlackBerryEvalLicense())
     {
         return("Evaluation");
     }
     return("?");
 }
コード例 #8
0
        public void LicenseContainer_Comment()
        {
            var hardwareId = Guid.NewGuid().ToString();
            var productId  = Guid.NewGuid().ToString();
            var lic        = new LicenseMock();

            lic.SetHarwareId(hardwareId);
            lic.SetProductId(productId);
            var con = LicenseContainer.Sign(lic, Const.FULL_KEY);

            con.Comment = "Original comment";
            output.WriteLine("Original ToJson:");
            output.WriteLine(con.ToJson());
            Assert.True(con.VerifySignature(Const.PUBLIC_KEY));
            con.Comment = "Change comment";
            Assert.True(con.VerifySignature(Const.PUBLIC_KEY));
            output.WriteLine("Changed ToJson:");
            output.WriteLine(con.ToJson());
        }
コード例 #9
0
 public bool Remove(LicenseContainer license)
 {
     return(licenses.Remove(license));
 }
コード例 #10
0
 public void Add(LicenseContainer license)
 {
     licenses.Add(license);
 }
コード例 #11
0
ファイル: LicenseStoreMock.cs プロジェクト: Devidence7/Fuxion
 public bool Remove(LicenseContainer license)
 {
     var res = licenses.Remove(license); LicenseRemoved?.Invoke(this, new EventArgs <LicenseContainer>(license)); return(res);
 }
コード例 #12
0
ファイル: LicenseStoreMock.cs プロジェクト: Devidence7/Fuxion
 public void Add(LicenseContainer license)
 {
     licenses.Add(license); LicenseAdded?.Invoke(this, new EventArgs <LicenseContainer>(license));
 }
コード例 #13
0
 public LicenseContainer Refresh(LicenseContainer oldLicense) => throw new NotImplementedException();