Package dev.dokimos.server.filter
Record Class Principal
java.lang.Object
java.lang.Record
dev.dokimos.server.filter.Principal
- Record Components:
id- stable identifier for the caller (an API key id, or"system"for the default unscoped principal)role- privilege level granted to the callertenantId- tenant the principal belongs to, ornullwhen no tenant applies
Authenticated caller.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PrincipalPrincipal for an unauthenticated reader in an authenticated deployment.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.booleanisSystem()Returns whether this is the system principal.role()Returns the value of therolerecord component.static Principalsystem()System principal used when no API key authentication is configured, or for reads in an open deployment.tenantId()Returns the value of thetenantIdrecord component.Resolves theTenantScopethis principal reads and writes under.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Method Details
-
system
System principal used when no API key authentication is configured, or for reads in an open deployment. CarriesRole.ADMINand no tenant so existing single-key and no-key deployments behave exactly as before. -
anonymous
Principal for an unauthenticated reader in an authenticated deployment. Carries the lowest role so open read endpoints still serve it, while endpoints that require a higher role (such as API key management) reject it. -
isSystem
public boolean isSystem()Returns whether this is the system principal. The system principal (no-key mode and the legacy singleDOKIMOS_API_KEY) is the only principal that maps to an unrestricted tenant scope, so existing single-tenant and no-key deployments keep seeing and stamping every row exactly as before.This is identified by the system id rather than
tenantId == null, because an anonymous keyless reader also carries a null tenant yet must resolve to shared-only, not unrestricted.- Returns:
- true when this is the system principal
-
tenantScope
Resolves theTenantScopethis principal reads and writes under. The system principal maps toTenantScope.unrestricted()(every row, null stamp); every other principal (a scoped key or an anonymous keyless reader) maps toTenantScope.scoped(String)on its own tenant, which for a null tenant collapses to shared-only.- Returns:
- the tenant scope for this principal
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
role
Returns the value of therolerecord component.- Returns:
- the value of the
rolerecord component
-
tenantId
Returns the value of thetenantIdrecord component.- Returns:
- the value of the
tenantIdrecord component
-