Table of Contents

Class AuthenticationToken

Namespace
Excalibur.A3.Authentication
Assembly
Excalibur.A3.dll

Represents an authentication token and provides methods to access claims and related information.

public class AuthenticationToken : IAuthenticationToken
Inheritance
AuthenticationToken
Implements
Inherited Members

Constructors

AuthenticationToken()

Initializes a new instance of the AuthenticationToken class with a default empty JWT.

public AuthenticationToken()

Fields

Anonymous

Represents an anonymous authentication token.

public static readonly IAuthenticationToken Anonymous

Field Value

IAuthenticationToken

Properties

AuthenticationState

Gets or sets the authentication state associated with this token.

public AuthenticationState AuthenticationState { get; set; }

Property Value

AuthenticationState

The authentication state associated with this token.

Claims

Gets or sets the claims for this authentication token.

public IEnumerable<Claim>? Claims { get; protected set; }

Property Value

IEnumerable<Claim>

The collection of claims, or null if no claims are set.

FirstName

Gets the first name claim value from the JWT, if available.

public string? FirstName { get; }

Property Value

string

The first name from the JWT claims, or null if not available.

FullName

Gets the full name claim value from the JWT, or "Anonymous" if not available.

public string FullName { get; }

Property Value

string

The full name from the JWT claims, or "Anonymous" if not available.

Jwt

Gets or sets the underlying JWT for this authentication token.

public JwtSecurityToken? Jwt { get; protected set; }

Property Value

JwtSecurityToken

The underlying JWT security token, or null if not set.

LastName

Gets the last name claim value from the JWT, if available.

public string? LastName { get; }

Property Value

string

The last name from the JWT claims, or null if not available.

Login

Gets the login (email) claim value from the JWT, if available.

public string? Login { get; }

Property Value

string

The login (email) from the JWT claims, or null if not available.

UserId

Gets the user identifier (UPN) claim value from the JWT, if available.

public string? UserId { get; }

Property Value

string

The user identifier from the JWT claims, or null if not available.

Methods

IsAnonymous()

Determines whether the provided authentication token represents an anonymous user.

public bool IsAnonymous()

Returns

bool

true if the token represents an anonymous user; otherwise, false .

IsAuthenticated()

Determines whether the provided authentication token represents an authenticated user.

public bool IsAuthenticated()

Returns

bool

true if the token represents an authenticated user; otherwise, false .

WillExpireBy(DateTime)

Determines whether the token will expire by the specified date and time.

public bool WillExpireBy(DateTime expiration)

Parameters

expiration DateTime

The date and time to check against the token's validity.

Returns

bool

true if the token will expire by the specified date and time; otherwise, false .