예제 #1
0
        public override async Task <SecretStore> Create(string store, IEnumerable <string> allowedUsers)
        {
            // Create the root folder if it does not exist
            if (!Directory.Exists(_rootFolder))
            {
                Directory.CreateDirectory(_rootFolder);
            }

            // Check if there is already a secret store here
            string storeDirectory = Path.Combine(_rootFolder, store);

            if (Directory.Exists(storeDirectory))
            {
                throw new InvalidOperationException(String.Format(
                                                        CultureInfo.CurrentCulture,
                                                        Strings.DpapiSecretStoreProvider_StoreExists,
                                                        store));
            }
            Directory.CreateDirectory(storeDirectory);

            // Create the directory and the metadata file
            string metadataFile = Path.Combine(storeDirectory, "metadata.v1.pjson");
            var    metadata     = new SecretStoreMetadata()
            {
                AllowedUsers = allowedUsers,
                Datacenter   = store
            };

            // Encrypt and Save it!
            var protector = CreateProtector(allowedUsers, MetadataPurpose);

            await WriteSecretFile(metadataFile, JsonFormat.Serialize(metadata), protector);

            return(new DpapiSecretStore(storeDirectory, metadata));
        }
        public override async Task<SecretStore> Create(string store, IEnumerable<string> allowedUsers)
        {
            // Create the root folder if it does not exist
            if (!Directory.Exists(_rootFolder))
            {
                Directory.CreateDirectory(_rootFolder);
            }

            // Check if there is already a secret store here
            string storeDirectory = Path.Combine(_rootFolder, store);
            if (Directory.Exists(storeDirectory))
            {
                throw new InvalidOperationException(String.Format(
                    CultureInfo.CurrentCulture,
                    Strings.DpapiSecretStoreProvider_StoreExists,
                    store));
            }
            Directory.CreateDirectory(storeDirectory);

            // Create the directory and the metadata file
            string metadataFile = Path.Combine(storeDirectory, "metadata.v1.pjson");
            var metadata = new SecretStoreMetadata()
            {
                AllowedUsers = allowedUsers,
                Datacenter = store
            };

            // Encrypt and Save it!
            var protector = CreateProtector(allowedUsers, MetadataPurpose);
            await WriteSecretFile(metadataFile, JsonFormat.Serialize(metadata), protector);
            
            return new DpapiSecretStore(storeDirectory, metadata);
        }
예제 #3
0
        public DpapiSecretStore(string storeDirectory, SecretStoreMetadata metadata)
            : base(metadata)
        {
            StoreDirectory = storeDirectory;

            _protectionDescriptor = DpapiSecretStoreProvider.GetProtectionDescriptorString(metadata.AllowedUsers);
        }
예제 #4
0
        public DpapiSecretStore(string storeDirectory, SecretStoreMetadata metadata)
            : base(metadata)
        {
            StoreDirectory = storeDirectory;

            _protectionDescriptor = DpapiSecretStoreProvider.GetProtectionDescriptorString(metadata.AllowedUsers);
        }
예제 #5
0
 protected SecretStore(SecretStoreMetadata metadata)
 {
     Metadata = metadata;
 }
예제 #6
0
 protected SecretStore(SecretStoreMetadata metadata)
 {
     Metadata = metadata;
 }