示例#1
0
        public DataMigrator(
            ILogger <DataMigrator <T> > logger,
            IKeyResolver <T> keyResolver,
            IGetAllQuery <T> sourceQuery,
            ICreateCommand <T> targetCommand,
            DataMigratorOptions options = null)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (keyResolver == null)
            {
                throw new ArgumentNullException(nameof(keyResolver));
            }
            if (sourceQuery == null)
            {
                throw new ArgumentNullException(nameof(sourceQuery));
            }
            if (targetCommand == null)
            {
                throw new ArgumentNullException(nameof(targetCommand));
            }

            log = logger;
            this.keyResolver   = keyResolver;
            this.sourceQuery   = sourceQuery;
            this.targetCommand = targetCommand;
            this.options       = options ?? new DataMigratorOptions();
        }
示例#2
0
 public void UnBind(IKeyResolver kr)
 {
     if (kr == null)
     {
         throw new ArgumentNullException("kr");
     }
     list.Remove(kr);
 }
示例#3
0
 public SubscriberFactory(IKeyResolver keyResolver,
                          ICacheClient cacheClient,
                          IExchangeSubscriberService subscriberService)
 {
     this.keyResolver       = keyResolver;
     this.cacheClient       = cacheClient;
     this.subscriberService = subscriberService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EncryptedMessageDeserializer"/> class.
 /// </summary>
 /// <param name="deserializer">The deserializer.</param>
 /// <param name="keyResolver">The key resolver.</param>
 /// <exception cref="ArgumentNullException">deserializer or keyResolver is null</exception>
 public EncryptedMessageDeserializer(JsonSerializer deserializer, IKeyResolver keyResolver)
     : this(deserializer, () => keyResolver)
 {
     if (keyResolver == null)
     {
         throw new ArgumentNullException(nameof(keyResolver));
     }
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="capacity">The maximim capacity for the cache</param>
        /// <param name="inner">The IKeyResolver to wrap</param>
        public CachingKeyResolver( int capacity, IKeyResolver inner )
        {
            if ( inner == null )
                throw new ArgumentNullException( "inner" );

            _cache = new LRUCache<string, IKey>( capacity );
            _inner = inner;
        }
        public AggregateKeyResolver Add( IKeyResolver resolver )
        {
            if ( resolver == null )
                throw new ArgumentNullException( "resolver" );

            _resolvers.Add( resolver );

            return this;
        }
示例#7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="capacity">The maximim capacity for the cache</param>
        /// <param name="inner">The IKeyResolver to wrap</param>
        public CachingKeyResolver(int capacity, IKeyResolver inner)
        {
            if (inner == null)
            {
                throw new ArgumentNullException("inner");
            }

            _cache = new LRUCache <string, IKey>(capacity);
            _inner = inner;
        }
        public AggregateKeyResolver Add(IKeyResolver resolver)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException("resolver");
            }

            _resolvers.Add(resolver);

            return(this);
        }
        public EncryptionPolicy(IKey encryptionKey, IKeyResolver decryptionKeyResolver)
        {
            if (encryptionKey == null & decryptionKeyResolver == null)
            {
                throw new ArgumentException($"Neither {nameof(encryptionKey)} nor {nameof(decryptionKeyResolver)} has been set.");
            }

            this.cachedEncryptionKey     = encryptionKey;
            this.encryptionPolicyOptions = new EncryptionPolicyOptions
            {
                KeyResolver = decryptionKeyResolver
            };

            if (encryptionKey != null)
            {
                this.encryptionPolicyOptions.EncryptionKey = (token) => Task.FromResult(encryptionKey);
            }

            this.encryptionPolicyOptions.Validate();
            this.semaphoreSlim   = new SemaphoreSlim(1);
            this.defaultSettings = new JsonSerializerSettings();
        }
示例#10
0
        public TableProvider(string accountName, string accountKey, string tableName, string keyId, IKeyResolver keyResolver)
        {
            var storageCredentials = new StorageCredentials(accountName, accountKey);
            var storageAccount     = new CloudStorageAccount(storageCredentials, useHttps: true);
            var tableClient        = storageAccount.CreateCloudTableClient();

            _table = tableClient.GetTableReference(tableName);
            _table.CreateIfNotExists();


            _requestOption = new TableRequestOptions()
            {
                EncryptionPolicy = new TableEncryptionPolicy(keyResolver.ResolveKeyAsync(keyId, CancellationToken.None).Result, null)
            };
            _retreiveOption = new TableRequestOptions()
            {
                EncryptionPolicy = new TableEncryptionPolicy(null, keyResolver)
            };
        }
示例#11
0
 public Interceptor(IKeyResolver keyResolver)
 {
     _keyResolver = keyResolver.Resolve;
 }
示例#12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueEncryptionPolicy"/> class with the specified key and resolver.
 /// </summary>
 /// <param name="key">An object of type <see cref="IKey"/> that is used to wrap/unwrap the content encryption key.</param>
 /// <param name="keyResolver">The key resolver used to select the correct key for decrypting existing queue messages.</param>
 /// <remarks>If the generated policy is to be used for encryption, users are expected to provide a key at the minimum.
 /// The absence of key will cause an exception to be thrown during encryption.<br/>
 /// If the generated policy is intended to be used for decryption, users can provide a key resolver. The client library will:<br/>
 /// 1. Invoke the key resolver, if specified, to get the key.<br/>
 /// 2. If resolver is not specified but a key is specified, the client library will match the key ID against the key and use the key.</remarks>
 public QueueEncryptionPolicy(IKey key, IKeyResolver keyResolver)
 {
     this.Key         = key;
     this.KeyResolver = keyResolver;
 }
示例#13
0
 /// <summary>
 /// Encryption
 /// </summary>
 /// <param name="keyResolver">Key Resolver</param>
 public Encryption(IKeyResolver keyResolver)
     : this()
 {
     this.keyResolver = keyResolver;
 }
示例#14
0
 public ExchangeSubscriberService(ICacheClient cacheClient, IKeyResolver keyResolver)
 {
     this.cacheClient = cacheClient;
     this.keyResolver = keyResolver;
 }
示例#15
0
 public EnvelopeCryptoStorageEngine(CloudStorageAccount storageAccount, IKeyResolver keyResolver)
 {
     _keyResolver     = keyResolver;
     _cloudBlobClient = storageAccount.CreateCloudBlobClient();
 }
        /// <summary>
        /// Uses the azure key vault encryption. Encryption key must be set for outgoing message
        /// encryption. The key resolver must be set for message decryption.
        /// </summary>
        /// <param name="configurator">The configurator.</param>
        /// <param name="encryptionKey">The encryption key.</param>
        /// <param name="keyResolver">The key resolver.</param>
        /// <exception cref="ArgumentNullException">configurator is null</exception>
        /// <exception cref="ArgumentException">encryptionKey and keyResolver are null</exception>
        public static void UseAzureKeyVaultEncryption(this IBusFactoryConfigurator configurator, IKey encryptionKey, IKeyResolver keyResolver)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException(nameof(configurator));
            }

            if (encryptionKey == null && keyResolver == null)
            {
                throw new ArgumentException($"{nameof(encryptionKey)} or {nameof(keyResolver)} must be set.");
            }

            configurator.AddBusFactorySpecification(new KeyVaultPipeSpecification(() => encryptionKey, () => keyResolver));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TableEncryptionPolicy"/> class with the specified key and resolver.
 /// </summary>
 /// <param name="key">An object of type <see cref="IKey"/> that is used to wrap/unwrap the content encryption key.</param>
 /// <param name="keyResolver">The key resolver used to select the correct key for decrypting existing table entities.</param>
 /// <remarks>If the generated policy is to be used for encryption, users are expected to provide a key at the minimum.
 /// The absence of key will cause an exception to be thrown during encryption.<br/>
 /// If the generated policy is intended to be used for decryption, users can provide a key resolver. The client library will:<br/>
 /// 1. Invoke the key resolver, if specified, to get the key.<br/>
 /// 2. If resolver is not specified but a key is specified, the client library will match the key ID against the key and use the key.</remarks> 
 public TableEncryptionPolicy(IKey key, IKeyResolver keyResolver)
 {
     this.Key = key;
     this.KeyResolver = keyResolver;
 }
 /// <summary>
 /// Encryption
 /// </summary>
 /// <param name="keyResolver">Key Resolver</param>
 /// <param name="logger">Logger</param>
 public Encryption(IKeyResolver keyResolver, ILogger logger) : this()
 {
     this.keyResolver = keyResolver;
     this.logger      = logger;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobEncryptionPolicy"/> class with the specified key and resolver.
 /// </summary>
 /// <param name="key">An object of type <see cref="IKey"/> that is used to wrap/unwrap the content key during encryption.</param>
 /// <param name="keyResolver">The key resolver used to select the correct key for decrypting existing blobs.</param>
 /// <remarks>If the generated policy is to be used for encryption, users are expected to provide a key at the minimum.
 /// The absence of key will cause an exception to be thrown during encryption.<br/>
 /// If the generated policy is intended to be used for decryption, users can provide a key resolver. The client library will:<br/>
 /// 1. Invoke the key resolver, if specified, to get the key.<br/>
 /// 2. If resolver is not specified but a key is specified, the client library will match the key ID against the key and use the key.</remarks> 
 public BlobEncryptionPolicy(IKey key, IKeyResolver keyResolver)
 {
     this.Key = key;
     this.KeyResolver = keyResolver;
     this.EncryptionMode = BlobEncryptionMode.FullBlob;
 }
示例#20
0
 public Modem(IKeyResolver<IDeviceState, DeviceState> states)
 {
     _states = states;
     SwitchOn();
 }
示例#21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlobEncryptionPolicy"/> class with the specified key and resolver.
 /// </summary>
 /// <param name="key">An object of type <see cref="IKey"/> that is used to wrap/unwrap the content key during encryption.</param>
 /// <param name="keyResolver">The key resolver used to select the correct key for decrypting existing blobs.</param>
 /// <remarks>If the generated policy is to be used for encryption, users are expected to provide a key at the minimum.
 /// The absence of key will cause an exception to be thrown during encryption.<br/>
 /// If the generated policy is intended to be used for decryption, users can provide a key resolver. The client library will:<br/>
 /// 1. Invoke the key resolver, if specified, to get the key.<br/>
 /// 2. If resolver is not specified but a key is specified, the client library will match the key ID against the key and use the key.</remarks>
 public BlobEncryptionPolicy(IKey key, IKeyResolver keyResolver)
 {
     this.Key            = key;
     this.KeyResolver    = keyResolver;
     this.EncryptionMode = BlobEncryptionMode.FullBlob;
 }
示例#22
0
 public NotificationService(ICacheClient cacheClient, IKeyResolver nameResolver)
 {
     this.cacheClient  = cacheClient;
     this.nameResolver = nameResolver;
 }