Files
Joseph Doherty 1e21e33ade chore: deprecate standalone SecureStoreManager utility
Move SecureStoreManager project and tests to Deprecated folder and remove
from solution. SecureStore functionality is now integrated into ConfigManager.
2026-01-27 07:26:40 -05:00

64 lines
2.0 KiB
C#

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);
}
}