35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using ln.types.net;
|
|
using ln.types.odb.attributes;
|
|
namespace skyspot.radius
|
|
{
|
|
public class RadiusSecretsStore
|
|
{
|
|
[DocumentID]
|
|
Guid ID = Guid.NewGuid();
|
|
|
|
public byte[] DefaultSecret { get; set; }
|
|
|
|
Dictionary<Endpoint4, byte[]> secrets = new Dictionary<Endpoint4, byte[]>();
|
|
|
|
public RadiusSecretsStore()
|
|
{
|
|
}
|
|
|
|
public bool ContainsEndpoint(Endpoint4 endpoint) => secrets.ContainsKey(endpoint);
|
|
public IEnumerable<Endpoint4> Endpoints => secrets.Keys;
|
|
|
|
public byte[] LookupSecret(Endpoint4 endpoint)
|
|
{
|
|
if (secrets.ContainsKey(endpoint))
|
|
return secrets[endpoint];
|
|
return DefaultSecret;
|
|
}
|
|
|
|
public byte[] GetSecret(Endpoint4 endpoint) => secrets[endpoint];
|
|
public void SetSecret(Endpoint4 endpoint, byte[] secret) => secrets[endpoint] = secret;
|
|
public void RemoveSecret(Endpoint4 endpoint) => secrets.Remove(endpoint);
|
|
}
|
|
}
|