2026-02-27 17:57:42 +00:00
|
|
|
using IdentityShroud.Core.Contracts;
|
|
|
|
|
using IdentityShroud.Core.Security.Keys;
|
|
|
|
|
|
|
|
|
|
namespace IdentityShroud.Core.Services;
|
|
|
|
|
|
|
|
|
|
public class KeyService(
|
2026-03-16 19:15:04 +01:00
|
|
|
IKeyProviderFactory keyProviderFactory) : IKeyService
|
2026-02-27 17:57:42 +00:00
|
|
|
{
|
2026-03-16 19:15:04 +01:00
|
|
|
public CreateKeyResponse CreateKey(KeyPolicy policy)
|
2026-02-27 17:57:42 +00:00
|
|
|
{
|
|
|
|
|
IKeyProvider provider = keyProviderFactory.CreateProvider(policy.KeyType);
|
2026-03-16 19:15:04 +01:00
|
|
|
KeyData plainKey = provider.CreateKey(policy);
|
2026-02-27 17:57:42 +00:00
|
|
|
|
2026-03-16 19:15:04 +01:00
|
|
|
return new CreateKeyResponse(policy.KeyType, plainKey);
|
2026-02-27 17:57:42 +00:00
|
|
|
}
|
|
|
|
|
}
|