コード例 #1
0
        public virtual async Task <Response <Key> > CreateEcKeyAsync(EcKeyCreateOptions ecKey, CancellationToken cancellationToken = default)
        {
            if (ecKey == default)
            {
                throw new ArgumentNullException(nameof(ecKey));
            }

            var parameters = new KeyRequestParameters(ecKey);

            return(await SendRequestAsync(HttpPipelineMethod.Put, parameters, () => new Key(ecKey.Name), cancellationToken, KeysPath, ecKey.Name, "create"));
        }
コード例 #2
0
        public virtual Response <Key> CreateRsaKey(RsaKeyCreateOptions rsaKey, CancellationToken cancellationToken = default)
        {
            if (rsaKey == default)
            {
                throw new ArgumentNullException(nameof(rsaKey));
            }

            var parameters = new KeyRequestParameters(rsaKey);

            return(SendRequest(HttpPipelineMethod.Put, parameters, () => new Key(rsaKey.Name), cancellationToken, KeysPath, rsaKey.Name, "create"));
        }
コード例 #3
0
        /// <summary>
        /// Creates and stores a new RSA key in Key Vault.
        /// </summary>
        /// <remarks>
        /// If the named key already exists, Azure Key Vault creates a new
        /// version of the key. It requires the keys/create permission.
        /// </remarks>
        /// <param name="rsaKey">The key options object containing information about the RSA key being created.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual async Task <Response <Key> > CreateRsaKeyAsync(RsaKeyCreateOptions rsaKey, CancellationToken cancellationToken = default)
        {
            if (rsaKey == default)
            {
                throw new ArgumentNullException(nameof(rsaKey));
            }

            var parameters = new KeyRequestParameters(rsaKey);

            return(await SendRequestAsync(RequestMethod.Post, parameters, () => new Key(rsaKey.Name), cancellationToken, KeysPath, rsaKey.Name, "/create").ConfigureAwait(false));
        }
コード例 #4
0
        /// <summary>
        /// Creates and stores a new Elliptic Curve key in Key Vault.
        /// </summary>
        /// <remarks>
        /// If the named key already exists, Azure Key Vault creates a new
        /// version of the key. It requires the keys/create permission.
        /// </remarks>
        /// <param name="ecKey">The key options object containing information about the Elliptic Curve key being created.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual Response <Key> CreateEcKey(EcKeyCreateOptions ecKey, CancellationToken cancellationToken = default)
        {
            if (ecKey == default)
            {
                throw new ArgumentNullException(nameof(ecKey));
            }

            var parameters = new KeyRequestParameters(ecKey);

            return(SendRequest(RequestMethod.Post, parameters, () => new Key(ecKey.Name), cancellationToken, KeysPath, ecKey.Name, "/create"));
        }
コード例 #5
0
        public virtual async Task <Response <Key> > UpdateKeyAsync(KeyBase key, IEnumerable <KeyOperations> keyOperations, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(key?.Version))
            {
                throw new ArgumentException($"{nameof(key.Version)} can't be empty or null");
            }

            var parameters = new KeyRequestParameters(key, keyOperations);

            return(await SendRequestAsync(HttpPipelineMethod.Patch, parameters, () => new Key(key.Name), cancellationToken, KeysPath, key.Name, "/", key.Version));
        }
コード例 #6
0
        public virtual async Task <Response <Key> > CreateKeyAsync(string name, KeyType keyType, KeyCreateOptions keyOptions = default, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException($"{nameof(name)} can't be empty or null");
            }
            if (keyType == default)
            {
                throw new ArgumentNullException(nameof(keyType));
            }

            var parameters = new KeyRequestParameters(keyType, keyOptions);

            return(await SendRequestAsync(HttpPipelineMethod.Put, parameters, () => new Key(name), cancellationToken, KeysPath, name, "create"));
        }
コード例 #7
0
        /// <summary>
        /// Creates and stores a new key in Key Vault.
        /// </summary>
        /// <remarks>
        /// The create key operation can be used to create any key type in Azure Key
        /// Vault. If the named key already exists, Azure Key Vault creates a new
        /// version of the key. It requires the keys/create permission.
        /// </remarks>
        /// <param name="name">The name of the key.</param>
        /// <param name="keyType">The type of key to create. See <see cref="KeyType"/> for valid values.</param>
        /// <param name="keyOptions">Specific attributes with information about the key.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual Response <Key> CreateKey(string name, KeyType keyType, KeyCreateOptions keyOptions = default, CancellationToken cancellationToken = default)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException($"{nameof(name)} can't be empty or null");
            }
            if (keyType == default)
            {
                throw new ArgumentNullException(nameof(keyType));
            }

            var parameters = new KeyRequestParameters(keyType, keyOptions);

            return(SendRequest(RequestMethod.Post, parameters, () => new Key(name), cancellationToken, KeysPath, name, "/create"));
        }
コード例 #8
0
        public virtual Response <Key> UpdateKey(KeyBase key, IEnumerable <KeyOperations> keyOperations, CancellationToken cancellationToken = default)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (key.Version == null)
            {
                throw new ArgumentNullException($"{nameof(key)}.{nameof(key.Version)}");
            }
            if (keyOperations == null)
            {
                throw new ArgumentNullException(nameof(keyOperations));
            }

            var parameters = new KeyRequestParameters(key, keyOperations);

            return(SendRequest(HttpPipelineMethod.Patch, parameters, () => new Key(key.Name), cancellationToken, KeysPath, key.Name, "/", key.Version));
        }
コード例 #9
0
        /// <summary>
        /// The update key operation changes specified attributes of a stored key and
        /// can be applied to any key type and key version stored in Azure Key Vault.
        /// </summary>
        /// <remarks>
        /// In order to perform this operation, the key must already exist in the Key
        /// Vault. Note: The cryptographic material of a key itself cannot be changed.
        /// This operation requires the keys/update permission.
        /// </remarks>
        /// <param name="key">The <see cref="KeyBase"/> object with updated properties.</param>
        /// <param name="keyOperations">List of supported <see cref="KeyOperations"/>.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual async Task <Response <Key> > UpdateKeyAsync(KeyBase key, IEnumerable <KeyOperations> keyOperations, CancellationToken cancellationToken = default)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (key.Version == null)
            {
                throw new ArgumentNullException($"{nameof(key)}.{nameof(key.Version)}");
            }
            if (keyOperations == null)
            {
                throw new ArgumentNullException(nameof(keyOperations));
            }

            var parameters = new KeyRequestParameters(key, keyOperations);

            return(await SendRequestAsync(RequestMethod.Patch, parameters, () => new Key(key.Name), cancellationToken, KeysPath, key.Name, "/", key.Version).ConfigureAwait(false));
        }