-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPersistedGrantStore.cs
More file actions
69 lines (61 loc) · 2.27 KB
/
PersistedGrantStore.cs
File metadata and controls
69 lines (61 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using IdentityServer4.Models;
using IdentityServer4.Stores;
using OpenActive.FakeDatabase.NET;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace IdentityServer
{
public class AcmePersistedGrantStore : IPersistedGrantStore
{
public async Task<IEnumerable<PersistedGrant>> GetAllAsync(string subjectId)
{
var grants = await FakeBookingSystem.FakeDatabase.GetAllGrants(subjectId);
var persistedGrants = grants.Select(grant => new PersistedGrant
{
Key = grant.Key,
Type = grant.Type,
SubjectId = grant.SubjectId,
ClientId = grant.ClientId,
CreationTime = grant.CreationTime,
Expiration = grant.Expiration,
Data = grant.Data
}).ToList();
return persistedGrants;
}
public async Task<PersistedGrant> GetAsync(string key)
{
var grant = await FakeBookingSystem.FakeDatabase.GetGrant(key);
return grant != null ? new PersistedGrant
{
Key = grant.Key,
Type = grant.Type,
SubjectId = grant.SubjectId,
ClientId = grant.ClientId,
CreationTime = grant.CreationTime,
Expiration = grant.Expiration,
Data = grant.Data
} : null;
}
public Task RemoveAllAsync(string subjectId, string clientId)
{
FakeBookingSystem.FakeDatabase.RemoveGrant(subjectId, clientId);
return Task.CompletedTask;
}
public Task RemoveAllAsync(string subjectId, string clientId, string type)
{
FakeBookingSystem.FakeDatabase.RemoveGrant(subjectId, clientId, type);
return Task.CompletedTask;
}
public Task RemoveAsync(string key)
{
FakeBookingSystem.FakeDatabase.RemoveGrant(key);
return Task.CompletedTask;
}
public Task StoreAsync(PersistedGrant grant)
{
FakeBookingSystem.FakeDatabase.AddGrant(grant.Key, grant.Type, grant.SubjectId, grant.ClientId, grant.CreationTime, grant.Expiration, grant.Data);
return Task.CompletedTask;
}
}
}