Exemple #1
0
        public async Task <Key> CreateKey(Guid vaultId, Key key)
        {
            if (key.Name == null)
            {
                throw new ArgumentException(
                          $"{nameof(Key)} has to have a non-NULL {nameof(key.Name)}");
            }

            if (key.Description == null)
            {
                throw new ArgumentException(
                          $"{nameof(Key)} has to have a non-NULL {nameof(key.Description)}");
            }

            if (!AllowedKeySpecs.Contains(key.Spec))
            {
                throw new ArgumentException(
                          $"Allowed key specs are: {string.Join(",", AllowedKeySpecs)}.");
            }

            if (!AllowedKeyTypes.Contains(key.Type))
            {
                throw new ArgumentException(
                          $"Allowed key types are: {string.Join(",", AllowedKeyTypes)}.");
            }

            if (_logger.IsDebug)
            {
                _logger.Debug($"Creating a key named {nameof(key.Name)} in the vault {vaultId}");
            }
            Key vaultKey = await _vaultService.CreateVaultKey(vaultId.ToString(), key);

            return(vaultKey);
        }
Exemple #2
0
        public async Task <Key> CreateKey(Guid vaultId, Key key)
        {
            if (key.Name == null)
            {
                throw new ArgumentException(
                          $"{nameof(Key)} has to have a non-NULL {nameof(key.Name)}");
            }

            if (key.Description == null)
            {
                throw new ArgumentException(
                          $"{nameof(Key)} has to have a non-NULL {nameof(key.Description)}");
            }

            if (_logger.IsDebug)
            {
                _logger.Debug($"Creating a key named {nameof(key.Name)} in the vault {vaultId}");
            }
            Key vaultKey = await _vaultService.CreateVaultKey(vaultId.ToString(), key);

            return(vaultKey);
        }