API Reference
StreamSec.Snif.ServerAttributes
Secure Network Interface Framework - StreamSec.Snif.ServerAttributes
Feature notes: Snif remoting framework (concepts)
Classes, interfaces and records
classTsnifCustomAttribute
inherits from TCustomAttribute
(no public members)
classTsnifRolesAttribute
inherits from TsnifCustomAttribute
constructor Create(const aRoles: array of string); overload;
constructor Create(const aRole: string); overload;
destructor Destroy; override;
property Roles: TStrings read fRoles;
classInstanceKind
inherits from TsnifCustomAttribute
constructor Create(aKind: TsnifInstanceKind);
property Kind: TsnifInstanceKind read fKind;
classRoles
inherits from TsnifRolesAttribute
In order to be allowed to instantiate (OWN) a class, the context must hold EVERY role listed in the Roles attribute of the class, if present and non-empty - an AND gate (see TsnifClassDescriptor.CheckAccess, owner path). A colleague reaching an owner's instance through a viaRole mediator instead needs just ONE of the class roles (see MediatorKind); the owner-vs-colleague asymmetry is deliberate.
When the InstanceKind attribute of the class is perRole, and the Roles attribute is present and non-empty, only the roles listed in the latter attribute will get an instance of the class. If the user has more than one of the roles associated with the class and wants access to a perRole instance associated with a specific role, the role to be used should specified as part of the request.
When the Roles attribute is applied to a method, any context that attempts to call the method, must have at least one of the roles listed in the attribute of the method, in addition to any role that permits access to the instance of the class the method belongs to.
DENY BY DEFAULT (fail-safe): a class that carries NEITHER a Roles attribute NOR an Anonymous attribute is UNREACHABLE by any connection. This deliberately turns the easy coding mistake of FORGETTING a Roles attribute into a denial rather than a silent exposure of the class to everyone (including not-logged-in connections). An empty Roles attribute is treated the same as an absent one. To make a class reachable without authentication, mark it Anonymous.
(no public members)
classAnonymous
inherits from TsnifCustomAttribute
Opts a class OUT of the deny-by-default access rule: a class marked Anonymous is reachable by Snif-anonymous (not-logged-in) connections. Use it ONLY for classes deliberately meant to be callable without authentication or a role (e.g. a public status / handshake endpoint); any per-method Roles attributes still apply and are still enforced. A class with NEITHER Roles NOR Anonymous is unreachable (see the fail-safe note on Roles). Do not combine Anonymous with a class-level Roles attribute - Anonymous wins (the class becomes reachable by anyone).
(no public members)
inherits from TsnifCustomAttribute
constructor Create(aKind: TsnifMediatorKind);
property Kind: TsnifMediatorKind read fKind;
classColleagueRoles
inherits from TsnifRolesAttribute
The ColleagueRoles attribute might be applied to methods only.
The mediator will only allow the colleague to call methods with the ColleagueRoles attribute present. The colleague must have at least one of the roles listed in the attribute.
When a method is called by a colleague, the CurrentContext returned by the TsnifClassServer will be the one of the colleague, not of the instance owner.
(no public members)
Types (enumerations, sets, aliases)
typeTsnifInstanceKind
TsnifInstanceKind = (perCall, { A new instance is created for each call
to be processed. The instance is
automatically destroyed once the call
has returned. perCall might e.g. be
used for stateless server objects that
do not require costly initialization. }
perCallPooled, { The instance will be pooled in
accordance with the settings of the
TsnifClassServer component. A
connection that makes a call into a
method (of a class with this attribute
value), will acquire the instance only
for the duration of the call. The
instance will be released back to the
pool once the call has returned.
perCallPooled might e.g. be used for
classes that require initialization,
but are otherwise stateless (e.g.
classes with methods that return cached
read-only data.)
If the class has a parameterless Reset
method for which RTTI is generated,
this method will be called prior to
each call. }
perConnection, { A new instance will be created for each
connection that makes a call into a
method of the class. The instance will
be associated with the connection and
will be destroyed once the connection
is closed. perConnection might be used
for server objects that either have a
state that is associated with the
connection, or server objects with
methods that require costly
authentication. }
perConnectionPooled, { The instance will be pooled in
accordance with the settings of the
TsnifClassServer component. A
connection that makes a call into a
method (of a class with this attribute
value), will acquire the instance for
the duration of the connection. The
instance will be released back to the
pool once the connection is closed.
perConnectionPooled might e.g. be used
for classes that require initialization,
but should otherwise be used as
perConnection objects, e.g. objects
that access databases in a stateful
way.
If the class has a parameterless Reset
method for which RTTI is generated,
this method will be called prior to
a connection acquiring the object. }
perSession, { A new instance will be created for each
session that makes a call into a
method of the class. The instance will
be associated with the session and
will be destroyed once the session
times out. perSession might be used
for server objects that should be
TsnifMediatorKind = (viaNone, {Used internally only, the default for
classes without a MediatorKind attribute.}
viaSession, {The instance must have instance kind
perConnection or perConnectionPooled. The
mediator will allow the client of any
connection to call colleague methods of an
instance associated with any other connection
that belongs to the same session.}
viaUser, {The instance must have instance kind
perConnection, perConnectionPooled, perSession
or perSessionPooled. The mediator will allow
the client of any connection to call colleague
methods of an instance associated with any
other connection or session that belongs to
the same user.}
viaRole, {The instance must have instance kind
perConnection, perConnectionPooled, perSession,
perSessionPooled or perUser. The mediator will
allow the client of any connection to call
colleague methods of an instance associated
with any other connection, session or user
that has any of the instance roles. Beware
that each instance will be mediated by each of
the roles defined for the class.}
viaApplication {The instance must have instance kind
perConnection, perConnectionPooled, perSession,
perSessionPooled or perUser. The mediator will
allow the client of any connection to call
colleague methods of an instance associated
with any other connection, session or user
that connects to the application. Note that
defining a viaApplication mediator for a class
with instance kind perRole would have no
effects on privileges; there would be no
difference between owners and colleagues.});