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,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