Beispiel #1
0
        public static LicenseChecker GetLicenseChecker(LicenseOptions options)
        {
            var sys = new WinSys();
              var remote = GetRemoteChecker(options, sys);
              var validator = GetValidator(options);

              return new LocalChecker(remote, validator);
        }
Beispiel #2
0
        //
        private static Details LoadCompanyAndProduct(LicenseOptions options)
        {
            var r1 = new OptionsDetailsReader(options);
              var r2 = new AssemblyDetailsReader(GetRootAssembly());
              var reader = new CompositeDetailsReader(r1, r2);

              return reader.Read();
        }
Beispiel #3
0
        /// <summary>
        ///   Factory method
        /// </summary>
        /// <param name="options">The license options</param>
        /// <returns>A new Licenser</returns>
        public static Licenser Create(LicenseOptions options)
        {
            var storage = Bootstrapper.GetStorage(options);
              var checker = Bootstrapper.GetLicenseChecker(options);

              var licenser = new Licenser(storage, checker);
              licenser.Initialize();

              return licenser;
        }
Beispiel #4
0
 private static Validator GetValidator(LicenseOptions options)
 {
     return new OrValidator(
     new HMACValidator(options.Password, it => it, null),
     new GuidValidator(it => it.Key, null),
     new NonEmptyValidator(it => it.Name,
       new NonEmptyValidator(it => it.Contact,
     new ExpirationValidator(it => it.Expiration,
       null))));
 }
Beispiel #5
0
        private static LicenseChecker GetRemoteChecker(LicenseOptions options, Sys sys)
        {
            var checkUrl = options.CheckUrl;
              if (String.IsNullOrWhiteSpace(checkUrl))
            return new NullRemoteChecker();

              var submitUrl = options.SubmitUrl.NullIfEmpty() ?? checkUrl;
              var remote = new WebRemote(submitUrl);
              var builder = new WebRequestBuilder(sys, checkUrl);
              var parser = new WebResponseParser();

              return new RemoteCheckerClient(remote, builder, parser);
        }
Beispiel #6
0
        public static Storage GetStorage(LicenseOptions options)
        {
            var details = LoadCompanyAndProduct(options);

              var pathBuilder = new RegistryPathBuilder();
              var subkey = pathBuilder.GetPath(details);
              var key = Registry.CurrentUser.OpenSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree)
                ?? Registry.CurrentUser.CreateSubKey(subkey, RegistryKeyPermissionCheck.ReadWriteSubTree);
              var io = new RegistryIO(key);

              var encryptor = GetEncryptor(options);
              var serializer = new LicenseSerializer();

              return new SecureStorage(io, encryptor, serializer);
        }
Beispiel #7
0
        public MainForm()
        {
            InitializeComponent();

              var options = new LicenseOptions
              {
            Password = "******",
            Salt = "saltsaltsalt",
            CheckUrl = null,
            SubmitUrl = null,
              };
              licenser = Licenser.Create(options);

              sys = new WinSys();
        }
Beispiel #8
0
 private static Encryptor GetEncryptor(LicenseOptions options)
 {
     return String.IsNullOrWhiteSpace(options.Password) || String.IsNullOrWhiteSpace(options.Salt)
     ? (Encryptor) new NullEncryptor()
     : new RijndaelEncryptor(options.Password, options.Salt);
 }
Beispiel #9
0
        public void SetUp()
        {
            var options = new LicenseOptions
              {
            Password = PASSWORD,
            Salt = SALT,
            CheckUrl = null,
            SubmitUrl = null,
            Company = COMPANY,
            Product = PRODUCT,
              };

              licenser = Licenser.Create(options);
        }
Beispiel #10
0
 public OptionsDetailsReader(LicenseOptions options)
 {
     this.options = options;
 }