Table of Contents

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 string
email string
publicKey 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

string

Properties

Created

Date the identity was created.

[DataMember]
public DateTime Created { get; }

Property Value

DateTime

Email

User's email address.

[DataMember]
public string Email { get; }

Property Value

string

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

string

Remarks

Display name may not be unique.

PublicKey

User's public key.

[DataMember]
public ReadOnlyMemory<byte> PublicKey { get; }

Property Value

ReadOnlyMemory<byte>

Remarks

Globally unique identity.

X500DistinguishedName

Returns the X500 distinguished name for this identity.

public X500DistinguishedName X500DistinguishedName { get; }

Property Value

X500DistinguishedName

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 string

The display name of the new identity.

email string

The email address of the new identity.

duration TimeSpan

The duration for the certificate (default: 1 year).

keySizeInBits int

The 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

name string

The name of the identity.

email string

The email associated with the identity.

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 UserIdentity
i2 UserIdentity

Returns

bool

ToString()

public override string ToString()

Returns

string

TryCreateFromCert(X509Certificate2, out UserIdentity)

Creates a UserIdentity from a X509Certificate.

public static bool TryCreateFromCert(X509Certificate2 cert, out UserIdentity identity)

Parameters

cert X509Certificate2

The certificate from which to extract an identity.

identity UserIdentity

If 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.