/// <summary> /// 初始化一个<see cref="HybridOptions"/>类型的新实例 /// </summary> public HybridOptions() { DbContexts = new ConcurrentDictionary <string, HybridDbContextOptions>(StringComparer.OrdinalIgnoreCase); OAuth2S = new ConcurrentDictionary <string, OAuth2Options>(); Auditing = new AuditingConfiguration(); EmailSender = new EmailSenderConfiguration(); Quartz = new QuartzOptions(); Ids = new IdsOptions(); Jwt = new JwtOptions(); HttpEncrypt = new HttpEncryptConfiguration(); }
/// <summary> /// 初始化一个<see cref="HostHttpCrypto"/>类型的新实例 /// </summary> public HostHttpCrypto(IServiceProvider provider) { _logger = provider.GetLogger(typeof(HostHttpCrypto)); HybridOptions options = provider.GetHybridOptions(); if (options?.HttpEncrypt?.IsEnabled == true) { HttpEncryptConfiguration httpEncrypt = options.HttpEncrypt; _privateKey = httpEncrypt.HostPrivateKey; if (string.IsNullOrEmpty(_privateKey)) { throw new HybridException("配置文件中HttpEncrypt节点的HostPrivateKey不能为空"); } } }
/// <summary> /// 初始化一个<see cref="ClientHttpCrypto"/>类型的新实例 /// </summary> public ClientHttpCrypto(IServiceProvider provider) { _logger = provider.GetLogger(typeof(ClientHttpCrypto)); HybridOptions options = provider.GetHybridOptions(); if (options?.HttpEncrypt?.IsEnabled == true) { HttpEncryptConfiguration httpEncrypt = options.HttpEncrypt; string clientPublicKey = httpEncrypt.ClientPublicKey; if (string.IsNullOrEmpty(clientPublicKey)) { throw new HybridException("配置文件中HttpEncrypt节点的ClientPublicKey不能为空"); } RsaHelper rsa = new RsaHelper(); _encryptor = new TransmissionEncryptor(rsa.PrivateKey, httpEncrypt.ClientPublicKey); _publicKey = rsa.PublicKey; } }