Record Class SecurityFeatures

java.lang.Object
java.lang.Record
com.tnsai.security.SecurityFeatures
Record Components:
encryptParams - whether String parameters are encrypted before the body
encryptResult - whether a String result is encrypted after the body
securityTimeout - the time limit for the body in milliseconds, or 0 for none
audit - the audit level
sensitive - whether audit entries mask every parameter and the result
maskFields - 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 Details

  • Constructor Details

    • SecurityFeatures

      public SecurityFeatures(boolean encryptParams, boolean encryptResult, int securityTimeout, Security.AuditLevel audit, boolean sensitive, List<String> maskFields)
      Creates an instance of a SecurityFeatures record class.
      Parameters:
      encryptParams - the value for the encryptParams record component
      encryptResult - the value for the encryptResult record component
      securityTimeout - the value for the securityTimeout record component
      audit - the value for the audit record component
      sensitive - the value for the sensitive record component
      maskFields - the value for the maskFields record component
  • Method Details

    • of

      public static SecurityFeatures of(Object target, Method method)
      Resolves the features of an action on its target.
      Parameters:
      target - the object containing the action
      method - the action method, or null for the target's class-level declarations only
      Returns:
      the merged features
    • auditLog

      public static AuditLog auditLog(Object target, Method method)
      Resolves the @AuditLog of 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, as of(Object, Method) walks them. One @AuditLog applies; the ones found later are not added to it.
      Parameters:
      target - the object containing the action
      method - the action method, or null
      Returns:
      the @AuditLog that applies, or null when none is declared
    • merge

      public static SecurityFeatures merge(List<Security> declarations)
      Merges declarations as of(Object, Method) does.
      Parameters:
      declarations - the @Security declarations, 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

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • encryptParams

      public boolean encryptParams()
      Returns the value of the encryptParams record component.
      Returns:
      the value of the encryptParams record component
    • encryptResult

      public boolean encryptResult()
      Returns the value of the encryptResult record component.
      Returns:
      the value of the encryptResult record component
    • securityTimeout

      public int securityTimeout()
      Returns the value of the securityTimeout record component.
      Returns:
      the value of the securityTimeout record component
    • audit

      public Security.AuditLevel audit()
      Returns the value of the audit record component.
      Returns:
      the value of the audit record component
    • sensitive

      public boolean sensitive()
      Returns the value of the sensitive record component.
      Returns:
      the value of the sensitive record component
    • maskFields

      public List<String> maskFields()
      Returns the value of the maskFields record component.
      Returns:
      the value of the maskFields record component