Record Class StrongAuthPolicy.Source

java.lang.Object
java.lang.Record
com.iizix.user.StrongAuthPolicy.Source
Record Components:
count - The count, null for unset.
factors - The factors that may count, null for unset; unmodifiable.
mandatory - The mandatory factors, null for unset; unmodifiable.
device - The device rule, null for unset.
floor - The floor, null for unset.
who - Whom it binds, null for unset.
Enclosing class:
StrongAuthPolicy

public static record StrongAuthPolicy.Source(Integer count, Set<String> factors, Set<String> mandatory, StrongAuthPolicy.Device device, Integer floor, StrongAuthPolicy.Who who) extends Record
What one source sets of the policy: a key it does not set is null, and takes part in the combination as unset. The parsers refuse a value outside its range or above the supported maximum, and never a rule between keys: a source may set mandatory alone.
Author:
Christopher Mindus
  • Field Details

  • Constructor Details

  • Method Details

    • isEmpty

      public boolean isEmpty()
      Checks if the source sets nothing.
      Returns:
      true when every key is unset.
    • parse

      public static StrongAuthPolicy.Source parse(String prefix, UnaryOperator<String> values)
      Parses the six keys from a settings reader: the value of each key, with the prefixes of the level, or null for a key the level does not set.
      Parameters:
      prefix - The prefix of the level, e.g. $signIn.strong..
      values - The reader: the text of a key, null or blank for unset.
      Returns:
      The source, NONE when it sets nothing.
      Throws:
      IllegalArgumentException - If a value is outside its range or above the supported maximum; the message names the key with its prefix, the value and what is supported.
    • parse

      public static StrongAuthPolicy.Source parse(String prefix, PropCnr settings)
      Parses the six keys from a settings container, as the server settings and an application's moduleApp settings hold them: the text of a property of any type (the settings editors may store a count as a number), null for a key the container has not.
      Parameters:
      prefix - The prefix of the level, e.g. $signIn.strong..
      settings - The container, null for none.
      Returns:
      The source, NONE when it sets nothing.
      Throws:
      IllegalArgumentException - As parse(String,UnaryOperator).
    • of

      public static StrongAuthPolicy.Source of(String prefix, String count, String factors, String mandatory, String device, String floor, String who)
      Parses the six keys from their texts.
      Parameters:
      prefix - The prefix of the keys, for the message of a refusal; null for none.
      count - The count: 0 to the supported maximum; null or blank for unset.
      factors - The factors: names from the supported factors separated by commas, the letter case and blanks do not matter; null or blank for unset.
      mandatory - The mandatory factors, likewise; null or blank for unset. An empty list is written as a single dash: no factor is mandatory, whatever another source says.
      device - flexible or strict; null or blank for unset.
      floor - The floor: 1 to the supported maximum; null or blank for unset.
      who - all or administrators; null or blank for unset.
      Returns:
      The source, NONE when every text is unset.
      Throws:
      IllegalArgumentException - If a value is outside its range, names what is no factor, or asks for more than is supported today (a count or floor above StrongAuthSupport.maxCount(), a factor that is not supported); the message names the key, the value and what is supported.
    • unsupportedProblem

      public String unsupportedProblem()
      Checks a source built by code - what an application's code raises or asks a step-up with, which never went through the parser - for the supported maximum: the count and the floor at most StrongAuthSupport.maxCount(), every factor named in factors and mandatory a supported one. A source the parser made keeps it by construction.
      Returns:
      The problem, naming the key, the value and what is supported; null when the source asks for nothing above it.
    • combine

      Combines this source with another, the strictest winning field by field (SA-D-5 (a)): the count and the floor are the larger, the factors the intersection where both set them, the mandatory factors the union, the device strict when either is, whom it binds the wider. A key only one sets is that one's.
      Parameters:
      other - The other source, null for none.
      Returns:
      The combination.
    • toString

      public String toString()
      Gets the source as it is written in a log: the keys it sets.
      Specified by:
      toString in class Record
      Returns:
      E.g. {count=2,mandatory=[passkey]}; {} for NONE.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • count

      public Integer count()
      Returns the value of the count record component.
      Returns:
      the value of the count record component
    • factors

      public Set<String> factors()
      Returns the value of the factors record component.
      Returns:
      the value of the factors record component
    • mandatory

      public Set<String> mandatory()
      Returns the value of the mandatory record component.
      Returns:
      the value of the mandatory record component
    • device

      public StrongAuthPolicy.Device device()
      Returns the value of the device record component.
      Returns:
      the value of the device record component
    • floor

      public Integer floor()
      Returns the value of the floor record component.
      Returns:
      the value of the floor record component
    • who

      public StrongAuthPolicy.Who who()
      Returns the value of the who record component.
      Returns:
      the value of the who record component