Exemplo n.º 1
0
 public LicenseValidationController(IDataContextFactory dataContextFactory, IApplicationIssueUnitOfWork applicationIssueUnitOfWork,
                                    ILoggingService loggingService, ILicenseValidator licenseValidator)
 {
     this.dataContextFactory         = dataContextFactory;
     this.applicationIssueUnitOfWork = applicationIssueUnitOfWork;
     this.loggingService             = loggingService;
     this.licenseValidator           = licenseValidator;
 }
        public void CompleteValidatorChain()
        {
            if (currentValidatorChain == null)
                return;

            validators.Enqueue(currentValidatorChain);
            currentValidatorChain = null;
        }
Exemplo n.º 3
0
        public X1(EnterpriseManagementGroup emg, Guid settingsGuid, string productName)
        {
            _emg         = emg;
            _productName = productName;

            _emoSettings = _emg.EntityObjects.GetObject <EnterpriseManagementObject>(settingsGuid,
                                                                                     ObjectQueryOptions.Default);

            _validator = new LicenseValidator();
        }
        public void CompleteValidatorChain()
        {
            if (currentValidatorChain == null)
            {
                return;
            }

            validators.Enqueue(currentValidatorChain);
            currentValidatorChain = null;
        }
        public bool ValidateLicense(string productKey, string applicationName, string licenseKey, string version)
        {
            _validator = new LicenseValidator();

            try
            {
                return(_validator.ValidateLicense(productKey, applicationName, licenseKey, version) != null);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 6
0
 public RequestTrialCommandHandler(
     ILicenseClient licenseClient,
     IDeviceIdProvider deviceIdProvider,
     IUserInfoProvider userInfoProvider,
     ILicenseStorage licenseStorage,
     ILicensePublicKeyStorage publicKeyStorage,
     ILicenseValidator licenseValidator,
     ILicenseInformationProvider licenseInformationProvider,
     ILogger <RequestTrialCommandHandler> logger
     )
 {
     this.licenseClient              = licenseClient;
     this.deviceIdProvider           = deviceIdProvider;
     this.userInfoProvider           = userInfoProvider;
     this.licenseStorage             = licenseStorage;
     this.publicKeyStorage           = publicKeyStorage;
     this.licenseValidator           = licenseValidator;
     this.licenseInformationProvider = licenseInformationProvider;
     this.logger = logger;
 }
        public bool ValidateLicense(string productKey, string applicationName, string licenseKey, string version, out DateTime?expirationDate)
        {
            _validator = new LicenseValidator();

            try
            {
                var license = _validator.ValidateLicense(productKey, applicationName, licenseKey, version);
                if (license == null)
                {
                    expirationDate = null;
                    return(false);
                }
                expirationDate = license.LicenseKeyExpirationDate;
                return(true);
            }
            catch (Exception)
            {
                expirationDate = null;
                return(false);
            }
        }
Exemplo n.º 8
0
        public ModuleLicensingService(ILogger <ModuleLicensingService> logger, ILicenseValidator licenseValidator,
                                      IModuleMetrics moduleMetrics)
        {
            this.logger           = logger;
            this.licenseValidator = licenseValidator;
            moduleInstanceName    = Environment.GetEnvironmentVariable("IOTEDGE_MODULEID");
            if (string.IsNullOrWhiteSpace(moduleInstanceName))
            {
                throw new InvalidOperationException($"IOTEDGE_MODULEID environment variable is null or blank.");
            }
            hostName = Environment.GetEnvironmentVariable("IOTEDGE_DEVICEID");
            if (string.IsNullOrWhiteSpace(hostName))
            {
                throw new InvalidOperationException($"IOTEDGE_DEVICEID environment variable is null or blank.");
            }
            hubName = Environment.GetEnvironmentVariable("IOTEDGE_IOTHUBHOSTNAME");
            if (string.IsNullOrWhiteSpace(hubName))
            {
                throw new InvalidOperationException($"IOTEDGE_IOTHUBHOSTNAME environment variable is null or blank.");
            }
            logger.LogInformation("Beginning periodic license validation for module {Module} on host {Host} for IoT Hub {Hub}",
                                  moduleInstanceName, hostName, hubName);

            licenseKey = Environment.GetEnvironmentVariable("MODULE_LICENSE_KEY");
            if (string.IsNullOrWhiteSpace(licenseKey))
            {
                throw new InvalidOperationException($"MODULE_LICENSE_KEY environment variable is null or blank.");
            }
            logger.LogInformation("License key '{LicenseKey}' loaded from environment variable", licenseKey);

            licenseCheckInterval        = TimeSpan.FromHours(1);
            maxConsecutiveCheckFailures = 36;
            serviceStopping             = new CancellationTokenSource();

            consecutiveLicenseCheckFailures = moduleMetrics.CreateGauge(
                "edgelicensing_consecutive_failures", "Consecutive edge licensing check failures");
            remainingConsecutiveLicenseCheckFailures = moduleMetrics.CreateGauge(
                "edgelicensing_remaining_consecutive_failures", "Remaining consecutive edge licensing check failures");
        }
 public ValidateLicenseSteps()
 {
     this.serverLicenseGenerator = new ServerLicenseGenerator();
     this.privateKeyProvider     = new RsaPrivateKeyProvider();
     this.licenseValidator       = new LicenseValidator();
 }
 public ILicenseValidator StartValidatorChain()
 {
     return currentValidatorChain = new LicenseValidator();
 }
Exemplo n.º 11
0
 public ILicenseValidator StartValidatorChain()
 {
     return(currentValidatorChain = new LicenseValidator());
 }
 public ValidateLicenseSteps()
 {
     this.serverLicenseGenerator = new ServerLicenseGenerator();
     this.privateKeyProvider = new RsaPrivateKeyProvider();
     this.licenseValidator = new LicenseValidator();
 }