/// <summary>
        ///
        /// </summary>
        /// <param name="keyId"></param>
        /// <param name="credential"></param>
        /// <param name="options"></param>
        public RemoteCryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options)
        {
            _keyId = keyId ?? throw new ArgumentNullException(nameof(keyId));

            options ??= new CryptographyClientOptions();

            this.ApiVersion = options.GetVersionString();

            _pipeline = HttpPipelineBuilder.Build(options,
                                                  new ChallengeBasedAuthenticationPolicy(credential));
        }
Example #2
0
        /// <summary>
        /// Creates a new KeyResolver instance
        /// </summary>
        /// <param name="credential">A <see cref="TokenCredential"/> capable of providing an OAuth token used to authenticate to Key Vault.</param>
        /// <param name="options">Options to configure the management of the requests sent to Key Vault for both the KeyResolver instance as well as all created instances of <see cref="CryptographyClient"/>.</param>
        public KeyResolver(TokenCredential credential, CryptographyClientOptions options)
        {
            Argument.AssertNotNull(credential, nameof(credential));

            options ??= new CryptographyClientOptions();

            _apiVersion = options.GetVersionString();

            _pipeline = HttpPipelineBuilder.Build(options,
                                                  new ChallengeBasedAuthenticationPolicy(credential));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CryptographyClient"/> class.
        /// </summary>
        /// <param name="keyId">The <see cref="KeyBase.Id"/> of the <see cref="Key"/> which will be used for cryptographic operations.</param>
        /// <param name="credential">A <see cref="TokenCredential"/> capable of providing an OAuth token.</param>
        /// <param name="options">Options to configure the management of the request sent to Key Vault.</param>
        /// <exception cref="ArgumentNullException"><paramref name="keyId"/> or <paramref name="credential"/> is null.</exception>
        /// <exception cref="NotSupportedException">The <see cref="CryptographyClientOptions.Version"/> is not supported.</exception>
        public CryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options)
        {
            Argument.AssertNotNull(keyId, nameof(keyId));
            Argument.AssertNotNull(credential, nameof(credential));

            _keyId = keyId;
            options ??= new CryptographyClientOptions();

            var remoteProvider = new RemoteCryptographyClient(keyId, credential, options);

            _pipeline       = remoteProvider.Pipeline;
            _remoteProvider = remoteProvider;
        }
        internal RemoteCryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options)
        {
            Argument.AssertNotNull(keyId, nameof(keyId));
            Argument.AssertNotNull(credential, nameof(credential));

            _keyId = keyId;
            options ??= new CryptographyClientOptions();
            string apiVersion = options.GetVersionString();

            HttpPipeline pipeline = HttpPipelineBuilder.Build(options,
                                                              new ChallengeBasedAuthenticationPolicy(credential));

            Pipeline = new KeyVaultPipeline(keyId, apiVersion, pipeline, new ClientDiagnostics(options));
        }
        /// <summary>
        /// Initializes a new instance of the CryptographyClient class.
        /// </summary>
        /// <param name="keyId">The <see cref="KeyBase.Id"/> of the <see cref="Key"/> which will be used for cryptographic operations</param>
        /// <param name="credential">Represents a credential capable of providing an OAuth token.</param>
        /// <param name="options">Options that allow to configure the management of the request sent to Key Vault.</param>
        public CryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options)
        {
            _keyId = keyId ?? throw new ArgumentNullException(nameof(keyId));
            if (credential is null)
            {
                throw new ArgumentNullException(nameof(credential));
            }

            options ??= new CryptographyClientOptions();

            var remoteProvider = new RemoteCryptographyClient(keyId, credential, options);

            _pipeline       = remoteProvider.Pipeline;
            _cryptoProvider = remoteProvider;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="keyId"></param>
        /// <param name="credential"></param>
        /// <param name="options"></param>
        public RemoteCryptographyClient(Uri keyId, TokenCredential credential, CryptographyClientOptions options)
        {
            KeyId = keyId ?? throw new ArgumentNullException(nameof(keyId));
            if (credential is null)
            {
                throw new ArgumentNullException(nameof(credential));
            }

            options ??= new CryptographyClientOptions();
            string apiVersion = options.GetVersionString();

            HttpPipeline pipeline = HttpPipelineBuilder.Build(options,
                                                              new ChallengeBasedAuthenticationPolicy(credential));

            Pipeline = new KeyVaultPipeline(keyId, apiVersion, pipeline);
        }