2026-02-27 17:57:42 +00:00
|
|
|
using IdentityShroud.Core.Contracts;
|
|
|
|
|
using IdentityShroud.Core.Model;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
|
|
|
|
namespace IdentityShroud.Core.Services;
|
|
|
|
|
|
|
|
|
|
public class RealmContext(
|
|
|
|
|
IHttpContextAccessor accessor,
|
|
|
|
|
IRealmService realmService) : IRealmContext
|
|
|
|
|
{
|
|
|
|
|
public Realm GetRealm()
|
|
|
|
|
{
|
|
|
|
|
return (Realm)accessor.HttpContext.Items["RealmEntity"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<IList<RealmDek>> GetDeks(CancellationToken ct = default)
|
|
|
|
|
{
|
|
|
|
|
Realm realm = GetRealm();
|
2026-03-16 19:15:04 +01:00
|
|
|
if (realm.DataEncryptionKeys.Count == 0)
|
2026-02-27 17:57:42 +00:00
|
|
|
{
|
|
|
|
|
await realmService.LoadDeks(realm);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-16 19:15:04 +01:00
|
|
|
return realm.DataEncryptionKeys;
|
2026-02-27 17:57:42 +00:00
|
|
|
}
|
|
|
|
|
}
|