40 lines
1007 B
C#
40 lines
1007 B
C#
using DigitalData.Core.Abstractions.Security;
|
|
using DigitalData.Core.Security.RSAKey.Base;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace DigitalData.Auth.Client;
|
|
|
|
/// <summary>
|
|
/// Represents a public RSA key, allowing dynamic updates and PEM import functionality.
|
|
/// </summary>
|
|
public class ClientPublicKey : RSAKeyBase, IAsymmetricTokenValidator, IUniqueSecurityContext
|
|
{
|
|
public required string Issuer { get; init; }
|
|
|
|
public required string Audience { get; init; }
|
|
|
|
private string _content = string.Empty;
|
|
|
|
public override string Content
|
|
{
|
|
get
|
|
{
|
|
return _content;
|
|
}
|
|
init
|
|
{
|
|
UpdateContent(value);
|
|
}
|
|
}
|
|
|
|
internal void UpdateContent(string content)
|
|
{
|
|
_content = content;
|
|
RSA.ImportFromPem(content);
|
|
SecurityKey = new RsaSecurityKey(RSA);
|
|
}
|
|
|
|
public SecurityKey SecurityKey { get; private set; } = new RsaSecurityKey(RSA.Create());
|
|
}
|