Record Class SecurityContext
java.lang.Object
java.lang.Record
org.j7m.middleware.security.api.SecurityContext
- Record Components:
principal- caller principalcallerRuntimeId- caller runtime idtrustDomain- caller trust domaincredential- credential descriptorcorrelationId- correlation idinvocationId- invocation idremoteEndpoint- remote endpoint when knownauthenticated- whether caller authentication succeededtransportSecurityLevel- transport security levelroles- caller rolesrequestMetadata- safe request metadatacreatedAt- context creation time
- All Implemented Interfaces:
Serializable
public record SecurityContext(Principal principal, String callerRuntimeId, TrustDomain trustDomain, Credential credential, String correlationId, String invocationId, String remoteEndpoint, boolean authenticated, TransportSecurityLevel transportSecurityLevel, Set<String> roles, Map<String,String> requestMetadata, Instant createdAt)
extends Record
implements Serializable
Immutable per-operation security context.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSecurityContext(Principal principal, String callerRuntimeId, TrustDomain trustDomain, Credential credential, String correlationId, String invocationId, String remoteEndpoint, boolean authenticated, TransportSecurityLevel transportSecurityLevel, Set<String> roles, Map<String, String> requestMetadata, Instant createdAt) Creates immutable context fields. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theauthenticatedrecord component.Returns the value of thecallerRuntimeIdrecord component.Returns the value of thecorrelationIdrecord component.Returns the value of thecreatedAtrecord component.Returns the value of thecredentialrecord component.final booleanIndicates whether some other object is "equal to" this one.static SecurityContextfromInvocationOptions(InvocationOptions options, String fallbackRuntimeId) Decodes an untrusted security context from invocation options.static SecurityContextfromTrustedBoundary(SecurityContext trusted, InvocationOptions options) Returns a trusted transport context with invocation metadata attached.final inthashCode()Returns a hash code value for this object.Returns the value of theinvocationIdrecord component.Returns the value of theprincipalrecord component.Returns the value of theremoteEndpointrecord component.Returns the value of therequestMetadatarecord component.roles()Returns the value of therolesrecord component.static SecurityContextReturns a development context for a runtime.Encodes this context into invocation metadata.final StringtoString()Returns a string representation of this record class.Returns the value of thetransportSecurityLevelrecord component.Returns the value of thetrustDomainrecord component.
-
Constructor Details
-
SecurityContext
public SecurityContext(Principal principal, String callerRuntimeId, TrustDomain trustDomain, Credential credential, String correlationId, String invocationId, String remoteEndpoint, boolean authenticated, TransportSecurityLevel transportSecurityLevel, Set<String> roles, Map<String, String> requestMetadata, Instant createdAt) Creates immutable context fields.
-
-
Method Details
-
system
Returns a development context for a runtime.- Parameters:
runtimeId- runtime id- Returns:
- system context
-
toMetadata
-
fromInvocationOptions
public static SecurityContext fromInvocationOptions(InvocationOptions options, String fallbackRuntimeId) Decodes an untrusted security context from invocation options.Public invocation metadata is caller controlled. Keys in the
sec.namespace are retained only as request metadata for audit redaction and are not trusted as authentication, principal, role, credential, trust-domain, or transport-security evidence.- Parameters:
options- invocation optionsfallbackRuntimeId- fallback caller runtime- Returns:
- decoded context
-
fromTrustedBoundary
public static SecurityContext fromTrustedBoundary(SecurityContext trusted, InvocationOptions options) Returns a trusted transport context with invocation metadata attached.This method is intended only for local or transport-authenticated boundaries that have already validated peer identity outside public invocation metadata.
- Parameters:
trusted- trusted context supplied by the transport or local boundaryoptions- invocation options whose public metadata remains untrusted- Returns:
- trusted context for dispatch
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
principal
-
callerRuntimeId
Returns the value of thecallerRuntimeIdrecord component.- Returns:
- the value of the
callerRuntimeIdrecord component
-
trustDomain
Returns the value of thetrustDomainrecord component.- Returns:
- the value of the
trustDomainrecord component
-
credential
Returns the value of thecredentialrecord component.- Returns:
- the value of the
credentialrecord component
-
correlationId
Returns the value of thecorrelationIdrecord component.- Returns:
- the value of the
correlationIdrecord component
-
invocationId
Returns the value of theinvocationIdrecord component.- Returns:
- the value of the
invocationIdrecord component
-
remoteEndpoint
Returns the value of theremoteEndpointrecord component.- Returns:
- the value of the
remoteEndpointrecord component
-
authenticated
public boolean authenticated()Returns the value of theauthenticatedrecord component.- Returns:
- the value of the
authenticatedrecord component
-
transportSecurityLevel
Returns the value of thetransportSecurityLevelrecord component.- Returns:
- the value of the
transportSecurityLevelrecord component
-
roles
-
requestMetadata
Returns the value of therequestMetadatarecord component.- Returns:
- the value of the
requestMetadatarecord component
-
createdAt
-