corda / net.corda.core.context / InvocationContext

InvocationContext

data class InvocationContext

Models the information needed to trace an invocation in Corda. Includes initiating actor, origin, trace information, and optional external trace information to correlate clients' IDs.

Constructors

<init>

InvocationContext(origin: InvocationOrigin, trace: Trace, actor: Actor?, externalTrace: Trace? = null, impersonatedActor: Actor? = null)

Models the information needed to trace an invocation in Corda. Includes initiating actor, origin, trace information, and optional external trace information to correlate clients' IDs.

Properties

actor

val actor: Actor?

Acting agent of the invocation, used to derive the security principal.

externalTrace

val externalTrace: Trace?

Optional external invocation trace for cross-system logs correlation.

impersonatedActor

val impersonatedActor: Actor?

Optional impersonated actor, used for logging but not for authorisation.

origin

val origin: InvocationOrigin

Origin of the invocation.

trace

val trace: Trace

Corda invocation trace.

Functions

principal

fun principal(): Principal

Associated security principal.

Companion Object Functions

newInstance

fun newInstance(origin: InvocationOrigin, trace: Trace = Trace.newInstance(), actor: Actor? = null, externalTrace: Trace? = null, impersonatedActor: Actor? = null): InvocationContext

Creates an InvocationContext with a Trace that defaults to a java.util.UUID as value and java.time.Instant.now timestamp.

peer

fun peer(party: CordaX500Name, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null, impersonatedActor: Actor? = null): InvocationContext

Creates an InvocationContext with InvocationOrigin.Peer origin.

rpc

fun rpc(actor: Actor, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null, impersonatedActor: Actor? = null): InvocationContext

Creates an InvocationContext with InvocationOrigin.RPC origin.

scheduled

fun scheduled(scheduledState: ScheduledStateRef, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext

Creates an InvocationContext with InvocationOrigin.Scheduled origin.

service

fun service(serviceClassName: String, owningLegalIdentity: CordaX500Name, trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext

Creates an InvocationContext with InvocationOrigin.Service origin.

shell

fun shell(trace: Trace = Trace.newInstance(), externalTrace: Trace? = null): InvocationContext

Creates an InvocationContext with InvocationOrigin.Shell origin.

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.