예제 #1
0
            public void should_not_be_null()
            {
                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                Assert.IsNotNull(encryptedData);
            }
예제 #2
0
            public void should_not_be_null()
            {
                LicenseActivationPayload payload = new LicenseActivationPayload();

                payload.LicenseKey     = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData     = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                Assert.IsNotNull(encryptedData);
            }
예제 #3
0
        public string ActivateLicense(string token, string payload)
        {
            ActivationResult result  = new ActivationResult();
            KeyPair          keyPair = _keyPairService.GetClientKeyPair();

            Debug.WriteLine(keyPair.PrivateKey);
            Debug.WriteLine(keyPair.PublicKey);

            if (!_controlService.ValidateClientToken(token))
            {
                result.WasOperationSuccessful = false;
                result.WasRequestValid        = false;
                result.ActivationSuccessful   = false;

                return(SerializeAndEncryptResult(result, keyPair));
            }

            result.WasRequestValid = true;

            result.ServiceId = _masterService.GetMasterServiceData().ServiceId;

            string decryptedPayload = _asymmetricEncryptionProvider.DecryptPublic(payload, keyPair);
            LicenseActivationPayload activationPayload = _serializationProvider.Deserialize <LicenseActivationPayload>(decryptedPayload);

            if (!_keyService.AuthorizeLicenseForActivation(activationPayload.LicenseKey, activationPayload.ServiceLicense, activationPayload.HardwareFingerprint))
            {
                result.WasOperationSuccessful = false;
                result.ActivationSuccessful   = false;
            }
            else
            {
                Guid?activiationtoken = _keyService.ActivateLicenseKey(activationPayload.LicenseKey, activationPayload.Token,
                                                                       activationPayload.ServiceLicense, activationPayload.HardwareFingerprint);
                if (activiationtoken.HasValue)
                {
                    _activationLogService.LogActiviation(activationPayload.LicenseKey, ActivationResults.Success, GetIpAddress());

                    result.ActivationToken        = activiationtoken;
                    result.WasOperationSuccessful = true;
                    result.ActivationSuccessful   = true;
                }
                else
                {
                    _activationLogService.LogActiviation(activationPayload.LicenseKey, ActivationResults.ActivationFailure, GetIpAddress());

                    result.WasOperationSuccessful = false;
                    result.ActivationSuccessful   = false;
                }
            }

            return(SerializeAndEncryptResult(result, keyPair));
        }
        public ActivationResult ActivateLicense(string url, string token, EncryptionInfo encryptionInfo,
                                                LicenseActivationPayload payload, ClientLicense clientLicense)
        {
            ActivationServiceClient client = ActivationServiceClientCreator(url);

            string encryptedToken    = _symmetricEncryptionProvider.Encrypt(token, encryptionInfo);
            string serializedPayload = _objectSerializationProvider.Serialize(payload);
            string encryptedData     = _asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, clientLicense.ServicesKeys);


            string serviceResult = client.ActivateLicense(encryptedToken, encryptedData);
            string result        = _asymmetricEncryptionProvider.DecryptPublic(serviceResult, clientLicense.ServicesKeys);

            ActivationResult activationResult = _objectSerializationProvider.Deserialize <ActivationResult>(result);

            return(activationResult);
        }
            public void should_not_be_null()
            {
                string clientToken = packingService.PackToken(service.GetClientToken());

                LicenseActivationPayload payload = new LicenseActivationPayload();

                payload.LicenseKey     = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string encryptedToken    = symmetricEncryptionProvider.Encrypt(clientToken, servicesService.GetClientStandardEncryptionInfo(service));
                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData     = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);


                string encryptedResult = activationService.ActivateLicense(encryptedToken, encryptedData);

                Assert.IsNotNull(encryptedResult);
            }
예제 #6
0
            public void should_decrypt()
            {
                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                KeyPair kp = new KeyPair();
                kp.PrivateKey = service.OutboundKeyPair.PrivateKey;
                kp.PublicKey = service.InboundKeyPair.PublicKey;

                string unencryptedData = asymmetricEncryptionProvider.DecryptPublic(encryptedData, kp);

                Assert.IsNotNull(unencryptedData);
                Assert.AreEqual(serializedPayload, unencryptedData);
            }
            public void should_not_have_been_successful()
            {
                string clientToken = packingService.PackToken(service.GetClientToken());

                LicenseActivationPayload payload = new LicenseActivationPayload();

                payload.LicenseKey     = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string encryptedToken    = symmetricEncryptionProvider.Encrypt(clientToken, servicesService.GetClientStandardEncryptionInfo(service));
                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData     = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);


                string           encryptedResult = activationService.ActivateLicense(encryptedToken, encryptedData);
                string           decryptedResult = asymmetricEncryptionProvider.DecryptPublic(encryptedResult, servicesService.CreateTestClientLicense(service).ServicesKeys);
                ActivationResult result          = objectSerializationProvider.Deserialize <ActivationResult>(decryptedResult);

                Assert.IsFalse(result.WasOperationSuccessful);
            }
예제 #8
0
            public void should_decrypt()
            {
                LicenseActivationPayload payload = new LicenseActivationPayload();

                payload.LicenseKey     = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData     = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                KeyPair kp = new KeyPair();

                kp.PrivateKey = service.OutboundKeyPair.PrivateKey;
                kp.PublicKey  = service.InboundKeyPair.PublicKey;

                string unencryptedData = asymmetricEncryptionProvider.DecryptPublic(encryptedData, kp);

                Assert.IsNotNull(unencryptedData);
                Assert.AreEqual(serializedPayload, unencryptedData);
            }
            public void should_not_be_null()
            {
                string clientToken = packingService.PackToken(service.GetClientToken());

                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string encryptedToken = symmetricEncryptionProvider.Encrypt(clientToken, servicesService.GetClientStandardEncryptionInfo(service));
                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                string encryptedResult = activationService.ActivateLicense(encryptedToken, encryptedData);

                Assert.IsNotNull(encryptedResult);
            }
            public void should_not_have_been_successful()
            {
                string clientToken = packingService.PackToken(service.GetClientToken());

                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey = "999-999999-9999";
                payload.ServiceLicense = new ServiceLicense(servicesService.CreateTestClientLicense(service));

                string encryptedToken = symmetricEncryptionProvider.Encrypt(clientToken, servicesService.GetClientStandardEncryptionInfo(service));
                string serializedPayload = objectSerializationProvider.Serialize(payload);
                string encryptedData = asymmetricEncryptionProvider.EncryptPrivate(serializedPayload, servicesService.CreateTestClientLicense(service).ServicesKeys);

                string encryptedResult = activationService.ActivateLicense(encryptedToken, encryptedData);
                string decryptedResult = asymmetricEncryptionProvider.DecryptPublic(encryptedResult, servicesService.CreateTestClientLicense(service).ServicesKeys);
                ActivationResult result = objectSerializationProvider.Deserialize<ActivationResult>(decryptedResult);

                Assert.IsFalse(result.WasOperationSuccessful);
            }
예제 #11
0
        public bool TestService(Service service)
        {
            string clientToken = _packingService.PackToken(service.GetClientToken());
            string mgmtToken   = _packingService.PackToken(service.GetManagementToken());

            LicenseActivationPayload payload = new LicenseActivationPayload();

            payload.ServiceLicense = new ServiceLicense(CreateTestClientLicense(service));

            LicenseGenerationOptions options = new LicenseGenerationOptions();

            options.LicenseKeyType = LicenseKeyTypes.MultiUser;

            payload.LicenseKey = _licenseKeyService.GenerateLicenseKey(null, payload.ServiceLicense, options);

            SetupTestProductResult result = _serviceStatusProvider.SetupTestProduct(service.ManagementUrl, mgmtToken, payload.LicenseKey, GetManagementStandardEncryptionInfo(service));

            if (result.WasRequestValid == false)
            {
                return(false);
            }

            if (result.WasOperationSuccessful == false)
            {
                return(false);
            }

            ActivationResult activationResult1 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                                                                                             payload, CreateTestClientLicense(service));

            ActivationResult activationResult2 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                                                                                             payload, CreateTestClientLicense(service));

            ActivationResult activationResult3 = _licenseActiviationProvider.ActivateLicense(service.ClientUrl, clientToken, GetClientStandardEncryptionInfo(service),
                                                                                             payload, CreateTestClientLicense(service));

            if (activationResult1.WasRequestValid == false || activationResult1.ActivationSuccessful == false)
            {
                return(false);
            }

            if (activationResult2.WasRequestValid == false || activationResult2.ActivationSuccessful == false)
            {
                return(false);
            }

            if (activationResult3.WasRequestValid == false || activationResult3.ActivationSuccessful == true)
            {
                return(false);
            }

            SetupTestProductResult cleanUpResult = _serviceStatusProvider.CleanUpTestProductData(service.ManagementUrl, mgmtToken,
                                                                                                 GetManagementStandardEncryptionInfo
                                                                                                     (service));

            if (cleanUpResult.WasOperationSuccessful == false)
            {
                return(false);
            }

            return(true);
        }
예제 #12
0
        public ClientLicense ActivateLicenseKey(string licenseKey, Guid?token, bool isOffline, ClientLicense scutexLicense, string hardwareFingerprint)
        {
            /* This method used to live in the LicenseKeyService class, where it should be
             *  but because of a circular reference in the WebServicesProvider and the ServicesLibrary
             *  project requiring the LicenseKeyService to valid keys it was causing and error and had
             *  to be moved here.
             */

            if (_licenseKeyService.ValidateLicenseKey(licenseKey, scutexLicense, true))
            {
                Token t = new Token();
                t.Data      = scutexLicense.ServiceToken;
                t.Timestamp = DateTime.Now;

                string packedToken = _packingService.PackToken(t);

                LicenseActivationPayload payload = new LicenseActivationPayload();
                payload.LicenseKey     = licenseKey;
                payload.ServiceLicense = new ServiceLicense(scutexLicense);
                payload.Token          = token;

                if (!String.IsNullOrEmpty(hardwareFingerprint))
                {
                    payload.HardwareFingerprint = hardwareFingerprint;
                }

                if (!isOffline)
                {
                    ActivationResult result = _licenseActiviationProvider.ActivateLicense(scutexLicense.ServiceAddress, packedToken,
                                                                                          GetClientStandardEncryptionInfo(scutexLicense),
                                                                                          payload, scutexLicense);

                    if (result != null && result.WasRequestValid && result.ActivationSuccessful)
                    {
                        scutexLicense.IsLicensed              = true;
                        scutexLicense.IsActivated             = true;
                        scutexLicense.ActivatingServiceId     = result.ServiceId;
                        scutexLicense.ActivationToken         = result.ActivationToken;
                        scutexLicense.ActivatedOn             = DateTime.Now;
                        scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                        _clientLicenseService.SaveClientLicense(scutexLicense);

                        return(scutexLicense);
                    }
                }
                else
                {
                    scutexLicense.IsLicensed              = true;
                    scutexLicense.IsActivated             = false;
                    scutexLicense.ActivatingServiceId     = null;
                    scutexLicense.ActivationToken         = null;
                    scutexLicense.ActivatedOn             = DateTime.Now;
                    scutexLicense.ActivationLastCheckedOn = DateTime.Now;

                    _clientLicenseService.SaveClientLicense(scutexLicense);

                    return(scutexLicense);
                }
            }

            return(scutexLicense);
        }