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); }
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); }