Package com.tnsai.security
Record Class SecurityFeatures
java.lang.Object
java.lang.Record
com.tnsai.security.SecurityFeatures
- Record Components:
encryptParams- whetherStringparameters are encrypted before the bodyencryptResult- whether aStringresult is encrypted after the bodysecurityTimeout- the time limit for the body in milliseconds, or0for noneaudit- the audit levelsensitive- whether audit entries mask every parameter and the resultmaskFields- the parameters audit entries mask
public record SecurityFeatures(boolean encryptParams, boolean encryptResult, int securityTimeout, Security.AuditLevel audit, boolean sensitive, List<String> maskFields)
extends Record
The
@Security encryption, timeout and audit features an action's dispatch applies.
They merge every @Security that AccessDeclaration resolves for the action's access gate:
on the target's class and on each of its superclasses and interfaces, on the action method, and on each
ancestor method it overrides. As at the gate, no declaration replaces another. An encryptParams,
encryptResult or sensitive set on any of them applies, the shortest positive
securityTimeout applies, the highest audit level applies, and the mask fields are the union.
- Since:
- 0.18.3
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSecurityFeatures(boolean encryptParams, boolean encryptResult, int securityTimeout, Security.AuditLevel audit, boolean sensitive, List<String> maskFields) Creates an instance of aSecurityFeaturesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionaudit()Returns the value of theauditrecord component.booleanaudited()static AuditLogResolves the@AuditLogof an action on its target: the action method's own, else the first found on a method it overrides, walking the target's class and each superclass up the chain, then the interfaces of those classes from the topmost superclass's down to the target class's own, each class's interfaces in declaration order, depth-first through the interfaces each extends, skipping an interface already walked, asof(Object, Method)walks them.booleandeclared()booleanReturns the value of theencryptParamsrecord component.booleanReturns the value of theencryptResultrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of themaskFieldsrecord component.static SecurityFeaturesMerges declarations asof(Object, Method)does.static SecurityFeaturesResolves the features of an action on its target.intReturns the value of thesecurityTimeoutrecord component.booleanReturns the value of thesensitiverecord component.booleantimed()final StringtoString()Returns a string representation of this record class.
-
Field Details
-
NONE
No feature declared.
-
-
Constructor Details
-
SecurityFeatures
public SecurityFeatures(boolean encryptParams, boolean encryptResult, int securityTimeout, Security.AuditLevel audit, boolean sensitive, List<String> maskFields) Creates an instance of aSecurityFeaturesrecord class.- Parameters:
encryptParams- the value for theencryptParamsrecord componentencryptResult- the value for theencryptResultrecord componentsecurityTimeout- the value for thesecurityTimeoutrecord componentaudit- the value for theauditrecord componentsensitive- the value for thesensitiverecord componentmaskFields- the value for themaskFieldsrecord component
-
-
Method Details
-
of
Resolves the features of an action on its target.- Parameters:
target- the object containing the actionmethod- the action method, ornullfor the target's class-level declarations only- Returns:
- the merged features
-
auditLog
Resolves the@AuditLogof an action on its target: the action method's own, else the first found on a method it overrides, walking the target's class and each superclass up the chain, then the interfaces of those classes from the topmost superclass's down to the target class's own, each class's interfaces in declaration order, depth-first through the interfaces each extends, skipping an interface already walked, asof(Object, Method)walks them. One@AuditLogapplies; the ones found later are not added to it.- Parameters:
target- the object containing the actionmethod- the action method, ornull- Returns:
- the
@AuditLogthat applies, ornullwhen none is declared
-
merge
Merges declarations asof(Object, Method)does.- Parameters:
declarations- the@Securitydeclarations, in any order- Returns:
- the merged features
-
timed
public boolean timed()- Returns:
- whether the body runs under a time limit
-
audited
public boolean audited()- Returns:
- whether a level audit entry is written
-
declared
public boolean declared()- Returns:
- whether any encryption, timeout or audit level is declared
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
encryptParams
public boolean encryptParams()Returns the value of theencryptParamsrecord component.- Returns:
- the value of the
encryptParamsrecord component
-
encryptResult
public boolean encryptResult()Returns the value of theencryptResultrecord component.- Returns:
- the value of the
encryptResultrecord component
-
securityTimeout
public int securityTimeout()Returns the value of thesecurityTimeoutrecord component.- Returns:
- the value of the
securityTimeoutrecord component
-
audit
Returns the value of theauditrecord component.- Returns:
- the value of the
auditrecord component
-
sensitive
public boolean sensitive()Returns the value of thesensitiverecord component.- Returns:
- the value of the
sensitiverecord component
-
maskFields
Returns the value of themaskFieldsrecord component.- Returns:
- the value of the
maskFieldsrecord component
-