/*
* Licensed under the Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
* See https://github.com/openiddict/openiddict-core for more information concerning
* the license and the contributors participating to this project.
*/
using System.Security.Claims;
namespace OpenIddict.Client;
public static partial class OpenIddictClientEvents
{
///
/// Represents an event called for each request to the introspection endpoint
/// to give the user code a chance to add parameters to the introspection request.
///
public sealed class PrepareIntrospectionRequestContext : BaseExternalContext
{
///
/// Creates a new instance of the class.
///
public PrepareIntrospectionRequestContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the token sent to the introspection endpoint.
///
public string? Token
{
get => Request.Token;
set => Request.Token = value;
}
///
/// Gets or sets the token type sent to the introspection endpoint.
///
public string? TokenTypeHint
{
get => Request.TokenTypeHint;
set => Request.TokenTypeHint = value;
}
}
///
/// Represents an event called for each request to the introspection endpoint
/// to send the introspection request to the remote authorization server.
///
public sealed class ApplyIntrospectionRequestContext : BaseExternalContext
{
///
/// Creates a new instance of the class.
///
public ApplyIntrospectionRequestContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
}
///
/// Represents an event called for each introspection response
/// to extract the response parameters from the server response.
///
public sealed class ExtractIntrospectionResponseContext : BaseExternalContext
{
///
/// Creates a new instance of the class.
///
public ExtractIntrospectionResponseContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response, or if it wasn't extracted yet.
///
public OpenIddictResponse? Response
{
get => Transaction.Response;
set => Transaction.Response = value;
}
}
///
/// Represents an event called for each introspection response.
///
public sealed class HandleIntrospectionResponseContext : BaseExternalContext
{
///
/// Creates a new instance of the class.
///
public HandleIntrospectionResponseContext(OpenIddictClientTransaction transaction)
: base(transaction)
{
}
///
/// Gets or sets the request.
///
public OpenIddictRequest Request
{
get => Transaction.Request!;
set => Transaction.Request = value;
}
///
/// Gets or sets the response.
///
public OpenIddictResponse Response
{
get => Transaction.Response!;
set => Transaction.Response = value;
}
///
/// Gets or sets the token sent to the introspection endpoint.
///
public string? Token { get; set; }
///
/// Gets or sets the principal containing the claims resolved from the introspection response.
///
public ClaimsPrincipal? Principal { get; set; }
}
}