Disk에 저장된 라이선스 파일에 대한 라이선스의 유효화에 대한 검증을 수행합니다.
Inheritance: AbstractLicenseValidator
Example #1
0
        private void ReadAvailableLicenses(string licensesDirectory)
        {
            if (string.IsNullOrEmpty(licensesDirectory))
            {
                throw new ArgumentNullException("licensesDirectory");
            }

            if (IsDebugEnabled)
            {
                log.Debug("유효한 라이선스 파일들을 읽습니다. licenseDirectory=[{0}], 라이선스 파일=*.xml", licensesDirectory);
            }

            foreach (var license in Directory.GetFiles(licensesDirectory, "*.xml"))
            {
                var set       = new HashSet <Guid>();
                var validator = new LicenseValidator(SoftwarePublicKey, license)
                {
                    DisableFloatingLicenses = true
                };
                try {
                    validator.AssertValidLicense();
                    if (IsDebugEnabled)
                    {
                        log.Debug("Found license for [{0}] of type [{1}]", validator.Name, validator.LicenseKind);
                    }

                    var isNewLicense = validator.LicenseKind == LicenseKind.Standard && set.Add(validator.UserId);
                    if (isNewLicense)
                    {
                        _availableLicenses.Add(validator);
                        if (IsDebugEnabled)
                        {
                            log.Debug("라이선스를 접수했습니다. 라이선스 소유자 명=[{0}], 소유자 Id=[{1}]", validator.Name, validator.UserId);
                        }
                    }
                }
                catch (Exception ex) {
                    if (log.IsWarnEnabled)
                    {
                        log.WarnException("라이선스 검증에 실패했습니다. license=" + license, ex);
                    }
                    continue;
                }
            }
        }
Example #2
0
 public void LicenseNotFoundExceptionTest() {
     var validator = new LicenseValidator(public_only, Path.GetTempFileName());
     Assert.Throws<LicenseNotFoundException>(() => validator.AssertValidLicense());
 }
Example #3
0
 public void LicenseFileNotFoundExceptionTest() {
     var validator = new LicenseValidator(public_only, "not_there");
     Assert.Throws<LicenseFileNotFoundException>(() => validator.AssertValidLicense());
 }
Example #4
0
        public void LicenseNotFoundExceptionTest()
        {
            var validator = new LicenseValidator(public_only, Path.GetTempFileName());

            Assert.Throws <LicenseNotFoundException>(() => validator.AssertValidLicense());
        }
Example #5
0
        public void LicenseFileNotFoundExceptionTest()
        {
            var validator = new LicenseValidator(public_only, "not_there");

            Assert.Throws <LicenseFileNotFoundException>(() => validator.AssertValidLicense());
        }
Example #6
0
        private void ReadAvailableLicenses(string licensesDirectory) {
            if(string.IsNullOrEmpty(licensesDirectory))
                throw new ArgumentNullException("licensesDirectory");

            if(IsDebugEnabled)
                log.Debug("유효한 라이선스 파일들을 읽습니다. licenseDirectory=[{0}], 라이선스 파일=*.xml", licensesDirectory);

            foreach(var license in Directory.GetFiles(licensesDirectory, "*.xml")) {
                var set = new HashSet<Guid>();
                var validator = new LicenseValidator(SoftwarePublicKey, license)
                                {
                                    DisableFloatingLicenses = true
                                };
                try {
                    validator.AssertValidLicense();
                    if(IsDebugEnabled)
                        log.Debug("Found license for [{0}] of type [{1}]", validator.Name, validator.LicenseKind);

                    var isNewLicense = validator.LicenseKind == LicenseKind.Standard && set.Add(validator.UserId);
                    if(isNewLicense) {
                        _availableLicenses.Add(validator);
                        if(IsDebugEnabled)
                            log.Debug("라이선스를 접수했습니다. 라이선스 소유자 명=[{0}], 소유자 Id=[{1}]", validator.Name, validator.UserId);
                    }
                }
                catch(Exception ex) {
                    if(log.IsWarnEnabled)
                        log.WarnException("라이선스 검증에 실패했습니다. license=" + license, ex);
                    continue;
                }
            }
        }
Example #7
0
 private static string GenerateLicense(Guid id, LicenseValidator validator, IDictionary<string, string> attributes) {
     return
         new LicenseGenerator(LicenseServerPrivateKey)
             .Generate(validator.Name,
                       id,
                       DateTime.UtcNow.AddMinutes(45),
                       attributes,
                       LicenseKind.Floating);
 }
Example #8
0
 private string GenerateLicenseAndRenewLease(string identifier, Guid id, LicenseValidator licenseValidator,
                                             IDictionary<string, string> attributes) {
     _leasedLicenses[identifier] = new KeyValuePair<DateTime, LicenseValidator>(DateTime.UtcNow.AddMinutes(30), licenseValidator);
     using(var file = new FileStream(_state, FileMode.Create, FileAccess.ReadWrite)) {
         WriteState(file);
     }
     return GenerateLicense(id, licenseValidator, attributes);
 }