chore: deprecate standalone SecureStoreManager utility
Move SecureStoreManager project and tests to Deprecated folder and remove from solution. SecureStore functionality is now integrated into ConfigManager.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JdeScoping.SecureStoreManager.Services;
|
||||
|
||||
namespace JdeScoping.SecureStoreManager.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Secret CRUD use-case operations with logging.
|
||||
/// </summary>
|
||||
public class SecretUseCases
|
||||
{
|
||||
private readonly ISecureStoreManager _storeManager;
|
||||
private readonly ILogger<SecretUseCases> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SecretUseCases"/> class.
|
||||
/// </summary>
|
||||
/// <param name="storeManager">The secure store manager.</param>
|
||||
/// <param name="logger">The logger instance.</param>
|
||||
public SecretUseCases(ISecureStoreManager storeManager, ILogger<SecretUseCases> logger)
|
||||
{
|
||||
_storeManager = storeManager ?? throw new ArgumentNullException(nameof(storeManager));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a secret with the given key and value.
|
||||
/// </summary>
|
||||
/// <param name="key">The secret key.</param>
|
||||
/// <param name="value">The secret value.</param>
|
||||
public void SetSecret(string key, string value)
|
||||
{
|
||||
_logger.LogInformation("Setting secret {Key}", key);
|
||||
_storeManager.SetSecret(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a secret by key.
|
||||
/// </summary>
|
||||
/// <param name="key">The secret key to remove.</param>
|
||||
public void RemoveSecret(string key)
|
||||
{
|
||||
_logger.LogInformation("Removing secret {Key}", key);
|
||||
_storeManager.RemoveSecret(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all keys in the current store.
|
||||
/// </summary>
|
||||
public IReadOnlyList<string> GetKeys()
|
||||
{
|
||||
return _storeManager.GetKeys();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the value of a secret by key.
|
||||
/// </summary>
|
||||
/// <param name="key">The secret key.</param>
|
||||
/// <returns>The secret value.</returns>
|
||||
public string GetSecret(string key)
|
||||
{
|
||||
return _storeManager.GetSecret(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using JdeScoping.SecureStoreManager.Services;
|
||||
|
||||
namespace JdeScoping.SecureStoreManager.Application;
|
||||
|
||||
/// <summary>
|
||||
/// Store lifecycle use-case operations with logging.
|
||||
/// </summary>
|
||||
public class StoreUseCases
|
||||
{
|
||||
private readonly ISecureStoreManager _storeManager;
|
||||
private readonly ILogger<StoreUseCases> _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="StoreUseCases"/> class.
|
||||
/// </summary>
|
||||
/// <param name="storeManager">The secure store manager instance.</param>
|
||||
/// <param name="logger">The logger instance.</param>
|
||||
public StoreUseCases(ISecureStoreManager storeManager, ILogger<StoreUseCases> logger)
|
||||
{
|
||||
_storeManager = storeManager ?? throw new ArgumentNullException(nameof(storeManager));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new store with key file authentication.
|
||||
/// </summary>
|
||||
/// <param name="storePath">The path where the store will be created.</param>
|
||||
/// <param name="keyFilePath">The path to the key file.</param>
|
||||
public void CreateStore(string storePath, string keyFilePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyFilePath))
|
||||
throw new ArgumentException("Key file path must be provided.", nameof(keyFilePath));
|
||||
|
||||
_logger.LogInformation("Creating store at {StorePath}", storePath);
|
||||
_storeManager.CreateStore(storePath, keyFilePath);
|
||||
_logger.LogInformation("Store created with key file: {KeyFilePath}", keyFilePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens an existing store with key file authentication.
|
||||
/// </summary>
|
||||
/// <param name="storePath">The path to the existing store.</param>
|
||||
/// <param name="keyFilePath">The path to the key file.</param>
|
||||
public void OpenStore(string storePath, string keyFilePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyFilePath))
|
||||
throw new ArgumentException("Key file path must be provided.", nameof(keyFilePath));
|
||||
|
||||
_logger.LogInformation("Opening store at {StorePath}", storePath);
|
||||
_storeManager.OpenStore(storePath, keyFilePath);
|
||||
_logger.LogDebug("Store opened with key file");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the currently open store.
|
||||
/// </summary>
|
||||
public void CloseStore()
|
||||
{
|
||||
_logger.LogInformation("Closing store");
|
||||
_storeManager.CloseStore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves changes to the current store.
|
||||
/// </summary>
|
||||
public void Save()
|
||||
{
|
||||
_logger.LogInformation("Saving store");
|
||||
_storeManager.Save();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a new key file at the specified path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path where the key file will be generated.</param>
|
||||
public void GenerateKeyFile(string path)
|
||||
{
|
||||
_logger.LogInformation("Generating key file at {Path}", path);
|
||||
_storeManager.GenerateKeyFile(path);
|
||||
_logger.LogInformation("Key file generated successfully");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exports the current store's key to a file.
|
||||
/// </summary>
|
||||
/// <param name="path">The path where the key will be exported.</param>
|
||||
public void ExportKey(string path)
|
||||
{
|
||||
_logger.LogInformation("Exporting key to {Path}", path);
|
||||
_storeManager.ExportKey(path);
|
||||
_logger.LogInformation("Key exported successfully");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user