/// <summary>
        /// Initializes a new instance of the <see cref="KeyRotationOptions"/> class.
        /// </summary>
        /// <param name="other">The other.</param>
        internal KeyRotationOptions(KeyRotationOptions other)
        {
            if (other == null)
            {
                return;
            }

            KeyPropagationWindow = other.KeyPropagationWindow;
            MaxServerClockSkew   = other.MaxServerClockSkew;
            KeyRingRefreshPeriod = other.KeyRingRefreshPeriod;
            AutoGenerateKeys     = other.AutoGenerateKeys;
            NewKeyLifetime       = other.NewKeyLifetime;
            XmlEncryptor         = other.XmlEncryptor;
            XmlRepository        = other.XmlRepository;
            AuthenticatedEncryptorConfiguration = other.AuthenticatedEncryptorConfiguration;

            foreach (var keyEscrowSink in other.KeyEscrowSinks)
            {
                KeyEscrowSinks.Add(keyEscrowSink);
            }

            foreach (var encryptorFactory in other.AuthenticatedEncryptorFactories)
            {
                AuthenticatedEncryptorFactories.Add(encryptorFactory);
            }
        }
Пример #2
0
        public KeyRingProvider(
            IKeyManager keyManager,
            IOptions <KeyRotationOptions> keyManagementOptions, // options change from original KeyManagementOptions
            IDefaultKeyResolver defaultKeyResolver,
            ILoggerFactory loggerFactory)
        {
            _keyManagementOptions    = new KeyRotationOptions(keyManagementOptions.Value); // clone so new instance is immutable
            _keyManager              = keyManager;
            CacheableKeyRingProvider = this;
            _defaultKeyResolver      = defaultKeyResolver;
            _logger = loggerFactory.CreateLogger <KeyRingProvider>();

            // We will automatically refresh any unknown keys for 2 minutes see https://github.com/aspnet/AspNetCore/issues/3975
            AutoRefreshWindowEnd = DateTime.UtcNow.AddMinutes(2);
        }