Class UserIdentity
- Namespace
- MarymoorStudios.Core.Rpc.Identity
- Assembly
- MarymoorStudios.Core.Rpc.Identity.dll
The identity of an RPC peer.
[DataContract]
public sealed class UserIdentity
- Inheritance
-
UserIdentity
- Inherited Members
Constructors
UserIdentity(string, string, ReadOnlyMemory<byte>, DateTime)
Constructor.
public UserIdentity(string name, string email, ReadOnlyMemory<byte> publicKey, DateTime created)
Parameters
name
stringemail
stringpublicKey
ReadOnlyMemory<byte>created
DateTime
Fields
AuthScopeUri
URI that MUST appear as a claim in a SubjectAlternativeNameExtension of any valid certificate.
public static readonly Uri AuthScopeUri
Field Value
- Uri
AuthenticationId
The name of the MSC authentication protocol.
public const string AuthenticationId = "MarymoorStudios Authentication"
Field Value
Properties
Created
Date the identity was created.
[DataMember]
public DateTime Created { get; }
Property Value
User's email address.
[DataMember]
public string Email { get; }
Property Value
Remarks
Email may not be unique. May be attested, but still not unique. The same user can have multiple user identities with different public keys but the same email. (E.g. during certificate renewal.)
Name
User's display name.
[DataMember]
public string Name { get; }
Property Value
Remarks
Display name may not be unique.
PublicKey
User's public key.
[DataMember]
public ReadOnlyMemory<byte> PublicKey { get; }
Property Value
Remarks
Globally unique identity.
X500DistinguishedName
Returns the X500 distinguished name for this identity.
public X500DistinguishedName X500DistinguishedName { get; }
Property Value
Methods
CreateIdentityCertificate(string, string, TimeSpan, int)
Creates a new MarymoorStudios Authentication Identity certificate.
public static X509Certificate2 CreateIdentityCertificate(string name, string email, TimeSpan duration = default, int keySizeInBits = 2048)
Parameters
name
stringThe display name of the new identity.
email
stringThe email address of the new identity.
duration
TimeSpanThe duration for the certificate (default: 1 year).
keySizeInBits
intThe desired key size.
Returns
- X509Certificate2
The identity certificate.
MakeX500DistinguishedName(string, string)
Creates an appropriate X500DistinguishedName for an identity.
public static X500DistinguishedName MakeX500DistinguishedName(string name, string email)
Parameters
Returns
- X500DistinguishedName
The distinguished name.
PublicKeyEquals(UserIdentity, UserIdentity)
Returns true if the two user identities have the same public key.
public static bool PublicKeyEquals(UserIdentity i1, UserIdentity i2)
Parameters
i1
UserIdentityi2
UserIdentity
Returns
ToString()
public override string ToString()
Returns
TryCreateFromCert(X509Certificate2, out UserIdentity)
Creates a UserIdentity from a X509Certificate.
public static bool TryCreateFromCert(X509Certificate2 cert, out UserIdentity identity)
Parameters
cert
X509Certificate2The certificate from which to extract an identity.
identity
UserIdentityIf successful the identity extracted from the certificate.
Returns
- bool
True if a single identity was successfully determined from the provided certificate.
False if the certificate does not satisfy the MSC authentication protocol.