Record Class StrongAuthPolicy

java.lang.Object
java.lang.Record
com.iizix.user.StrongAuthPolicy
Record Components:
count - How many different strong factors one sign-in completes, 0 for off.
factors - The factors that may count, in the order of ALL_FACTORS; unmodifiable.
mandatory - The factors every sign-in must include, a subset of factors; unmodifiable.
device - What a client that cannot do the factors gets.
floor - The fewest strong factors a flexible sign-in may end with, 1 or more.
who - The users the policy binds.

public record StrongAuthPolicy(int count, Set<String> factors, Set<String> mandatory, StrongAuthPolicy.Device device, int floor, StrongAuthPolicy.Who who) extends Record
The strong authentication policy of an application (CC-SIGNIN-STRONG-POLICY; section 2 of the design of order 475, the owner's rulings SA-D-1..SA-D-11): how many different strong factors one sign-in completes, which factors may count, which every sign-in must include, what a client that cannot do them gets, the fewest a flexible sign-in may end with, and whom the policy binds.

The factors. A factor counts only when the server verifies it: FACTOR_TOTP (a code of the user's authenticator app), FACTOR_PASSKEY (a WebAuthn assertion with user verification) and FACTOR_BIOMETRIC (a signature of a hardware-bound, biometric- only device key of the iiziRun app). Their order is fixed, strongest first (SA-D-4). A password, a device token, a recovery code, an e-mail or SMS code is never a strong factor. In a Browser a passkey counts once, as passkey, whatever unlocked it (SA-D-1).

The supported maximum (CC-FIX-SIGNIN-STRONG-SUPPORTED-MAX, the owner's rule of 2026-11-07): a setting may never ask for more than this build fully supports today, StrongAuthSupport. The factor biometric is known to the code and its flow is written, but no client can do it until the device-key orders: it is not supported, so factors and mandatory may not name it and count and floor may not exceed the number of supported factors, 2. The parser refuses such a value where it is set, naming the value and the supported set; resolve(StrongAuthPolicy.Source...) refuses a source an application's code built with one. A test or a rig widens the supported set with the lab override of StrongAuthSupport; nothing a customer reaches does.

The setting. The same six keys at every level, after the prefix of the level (PREFIX after SignInPolicy.SERVER_PREFIX or SignInPolicy.APP_PREFIX):

The keys
KeyValuesDefaultMeaning
count0 to the supported maximum (StrongAuthSupport.maxCount(), 2 today; 3 is ALL THREE when the biometric device key is supported)0how many different strong factors one sign-in completes; 0 is off, v5's rules apply unchanged
factorsa list from the supported factors (passkey,totp today)every supported factorthe factors that may count
mandatorya list, a subset of factorsemptythe factors every sign-in must include: the device requirement
deviceflexible, strictflexiblestrict: a client that cannot complete count with every mandatory factor is refused before the password; flexible: such a client does what it can, never below floor
floor1 to count1the fewest strong factors a flexible sign-in may end with; what the client reports never pushes below it
whoall, administratorsallthe users the policy binds

Consistency (check()): mandatory is a subset of factors; count is at least the size of mandatory; factors holds at least count factors; floor is at most count. A policy that breaks a rule is refused where it is typed (checkSource(String, UnaryOperator)); when several sources, each consistent alone, combine into one that does, the application fails closed (resolve(StrongAuthPolicy.Source...) throws, and the caller refuses every sign-in).

Sources combine, the strictest wins field by field (SA-D-5 (a), StrongAuthPolicy.Source.combine(StrongAuthPolicy.Source)): count the maximum, factors the intersection of the sources that set it, mandatory the union, device strict when any source says strict, floor the maximum, who the widest. An application raises, through its settings or its code, and never lowers what the server, the environment or its definition sets. v5's own signIn.* keys keep their v5 behavior, "the application overrides" (SA-D-5 (b)); for a user this policy binds, count of 1 or more replaces v5's second-factor rule.

Author:
Christopher Mindus
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    What a client that cannot do the factors of the policy gets.
    static enum 
    The presets of ServerAdmin's dialog (section 2.2 of the design): a count, a device rule and a floor, every supported factor allowed, none mandatory, every user bound.
    static final record 
    What one source sets of the policy: a key it does not set is null, and takes part in the combination as unset.
    static enum 
    The users a policy binds.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Set<String>
    Every factor the code knows, strongest first (SA-D-4): the order of every set this class makes.
    static final String
    The factors, named as the methods of a proof are (MFAProof.METHOD_TOTP, MFAProof.METHOD_PASSKEY).
    static final String
    The factors, named as the methods of a proof are (MFAProof.METHOD_TOTP, MFAProof.METHOD_PASSKEY).
    static final String
    The factors, named as the methods of a proof are (MFAProof.METHOD_TOTP, MFAProof.METHOD_PASSKEY).
    static final List<String>
    The keys in their order, without their prefixes.
    static final StrongAuthPolicy
    The policy that is off: v5's rules apply unchanged.
    static final String
    The keys, without their prefixes.
    static final String
    The keys, without their prefixes.
    static final String
    The keys, without their prefixes.
    static final String
    The keys, without their prefixes.
    static final String
    The keys, without their prefixes.
    static final String
    The keys, without their prefixes.
    static final String
    The prefix of the keys after the prefix of the level: "strong.", so that the server setting is $signIn.strong.count and the application's signIn.strong.count.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StrongAuthPolicy(int count, Set<String> factors, Set<String> mandatory, StrongAuthPolicy.Device device, int floor, StrongAuthPolicy.Who who)
    Constructs the policy: the sets are copied, ordered and unmodifiable.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if a proof meets the policy on this server, as a hub member checks the proof a session transfer carries against its own resolved policy (section 2.6 of the design): the proof is verified and its methods meet the policy's count with every mandatory factor.
    boolean
    allows(String factor)
    Checks if a factor may count.
    Gets the policy as a source, every key set: what an application's code hands the server to raise its policy with.
    boolean
    binds(boolean administrator)
    Checks if the policy binds a user.
    Checks the consistency rules of section 2.2 of the design.
    static String
    Checks the six keys of one level where they are set - the server settings, an environment's custom application settings, an application's module settings - for everything that can be known of that level alone: each value in its range and within the supported maximum (StrongAuthPolicy.Source.parse(String, UnaryOperator)), and the consistency rules among the six keys (check()).
    int
    Returns the value of the count record component.
    Returns the value of the device record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the factors record component.
    int
    Returns the value of the floor record component.
    final int
    Returns a hash code value for this object.
    boolean
    isMet(Set<String> verified, int target)
    Checks if a set of verified factors meets a target: as many allowed factors as the target, every mandatory one among them.
    boolean
    Checks if the policy is off: v5's rules apply to everyone.
    boolean
    Checks if another policy is at least as strict as this one in every field: what an application may raise its policy to (SA-D-5 (a): raise, never lower).
    lacking(Set<String> clientCan)
    Gets the factors this client lacks for a sign-in to be possible at all, known from the policy and what the client can do alone - nothing about an account (section 2.5 of the design): every mandatory factor the client cannot do; and when the client cannot do as many allowed factors as it must end with - count under StrongAuthPolicy.Device.STRICT, floor under StrongAuthPolicy.Device.FLEXIBLE - the allowed factors it cannot do.
    Returns the value of the mandatory record component.
    int
    missing(Set<String> verified, int target)
    Gets what is still missing of a set of verified factors to meet a target: every mandatory factor not verified, and as many more allowed factors as the target needs.
    Gets the preset this policy is, for ServerAdmin's dialog and the applications table: the preset whose policy under the factors supported now (StrongAuthPolicy.Preset.policy()) is this one.
    reader(PropCnr settings)
    Makes the reader of the strong keys of a settings container: the text of a property of any type, as the settings editors may store a count as a number.
    remaining(Set<String> verified)
    Gets the allowed factors that are not verified yet, strongest first: what a sign-in asks next (SA-D-4), the mandatory ones first among them.
    Resolves the policy of the sources that set it, in the order of the design (S1 the server settings, S2 the environment, S3 the application definition, S4 the application's module settings, S5 the application's code), the strictest winning field by field, with the defaults for what no source sets.
    int
    target(Set<String> clientCan)
    Gets the target of a sign-in on a client: how many different strong factors it completes (section 2.2 of the design, step 2).
    Gets the policy as it is written in a log.
    Makes the policy of a combined source with the defaults for what is unset, unchecked.
    who()
    Returns the value of the who record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • reader

      public static UnaryOperator<String> reader(PropCnr settings)
      Makes the reader of the strong keys of a settings container: the text of a property of any type, as the settings editors may store a count as a number.
      Parameters:
      settings - The container, null for none.
      Returns:
      The reader: null for a key the container has not.
    • checkSource

      public static String checkSource(String prefix, UnaryOperator<String> values)
      Checks the six keys of one level where they are set - the server settings, an environment's custom application settings, an application's module settings - for everything that can be known of that level alone: each value in its range and within the supported maximum (StrongAuthPolicy.Source.parse(String, UnaryOperator)), and the consistency rules among the six keys (check()). The rules of the level combined with the other levels are the resolver's.
      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 problem in plain words - a refused value names its key with the prefix, a broken rule names the keys as check() does; null when there is none.
    • resolve

      public static StrongAuthPolicy resolve(StrongAuthPolicy.Source... sources)
      Resolves the policy of the sources that set it, in the order of the design (S1 the server settings, S2 the environment, S3 the application definition, S4 the application's module settings, S5 the application's code), the strictest winning field by field, with the defaults for what no source sets. The combination is checked: one that asks for more than is supported today (StrongAuthPolicy.Source.unsupportedProblem(): only a source built by code can, the parser refused it in every setting) or breaks a consistency rule is refused, and the application fails closed.
      Parameters:
      sources - The sources, null entries for none.
      Returns:
      The policy, OFF when no source sets a count or the count is 0.
      Throws:
      IllegalArgumentException - If the combination asks for more than is supported or breaks a consistency rule; the message says which, and check() of the unchecked policy lists all.
    • unchecked

      public static StrongAuthPolicy unchecked(StrongAuthPolicy.Source source)
      Makes the policy of a combined source with the defaults for what is unset, unchecked.
      Parameters:
      source - The source.
      Returns:
      The policy; OFF for a count that is unset or 0.
    • check

      public List<String> check()
      Checks the consistency rules of section 2.2 of the design. A policy that is off breaks none: its other keys decide nothing.
      Returns:
      The rules broken, in plain words; empty when none is.
    • isOff

      public boolean isOff()
      Checks if the policy is off: v5's rules apply to everyone.
      Returns:
      true for a count of 0.
    • binds

      public boolean binds(boolean administrator)
      Checks if the policy binds a user.
      Parameters:
      administrator - Whether the user is a member of the administrators group.
      Returns:
      true when the policy is on and binds the user: every user, or this administrator.
    • allows

      public boolean allows(String factor)
      Checks if a factor may count.
      Parameters:
      factor - The factor, null for none.
      Returns:
      true when the policy allows it.
    • lacking

      public Set<String> lacking(Set<String> clientCan)
      Gets the factors this client lacks for a sign-in to be possible at all, known from the policy and what the client can do alone - nothing about an account (section 2.5 of the design): every mandatory factor the client cannot do; and when the client cannot do as many allowed factors as it must end with - count under StrongAuthPolicy.Device.STRICT, floor under StrongAuthPolicy.Device.FLEXIBLE - the allowed factors it cannot do. A client that lacks one is answered STRONG_AUTH_CLIENT_REQUIRED before the password, with this set, so that SignIn names the client that works.
      Parameters:
      clientCan - The factors the client can do: enroll or use.
      Returns:
      The factors lacking, in the order of ALL_FACTORS; empty when the client can sign in.
    • target

      public int target(Set<String> clientCan)
      Gets the target of a sign-in on a client: how many different strong factors it completes (section 2.2 of the design, step 2). Under StrongAuthPolicy.Device.STRICT the count. Under StrongAuthPolicy.Device.FLEXIBLE the larger of the floor and the number of allowed factors the client can do, at most the count: the client does what it can, never below the floor (SA-D-8), and the user enrolls what is missing.
      Parameters:
      clientCan - The factors the client can do.
      Returns:
      The target, 0 when the policy is off.
    • missing

      public int missing(Set<String> verified, int target)
      Gets what is still missing of a set of verified factors to meet a target: every mandatory factor not verified, and as many more allowed factors as the target needs. The factors that are verified count only when the policy allows them.
      Parameters:
      verified - The factors that were verified.
      target - The target, see target(Set).
      Returns:
      The number of factors still to verify (the mandatory ones among them), 0 when the target is met.
    • isMet

      public boolean isMet(Set<String> verified, int target)
      Checks if a set of verified factors meets a target: as many allowed factors as the target, every mandatory one among them.
      Parameters:
      verified - The factors that were verified.
      target - The target.
      Returns:
      true when met.
    • accepts

      public boolean accepts(MFAProof proof)
      Checks if a proof meets the policy on this server, as a hub member checks the proof a session transfer carries against its own resolved policy (section 2.6 of the design): the proof is verified and its methods meet the policy's count with every mandatory factor. A policy that is off is met by every proof.
      Parameters:
      proof - The proof, null for none.
      Returns:
      true when the proof is enough for this policy; a proof that falls short is not accepted, and the user is asked the rest.
    • remaining

      public Set<String> remaining(Set<String> verified)
      Gets the allowed factors that are not verified yet, strongest first: what a sign-in asks next (SA-D-4), the mandatory ones first among them.
      Parameters:
      verified - The factors that were verified.
      Returns:
      The factors, ordered; empty when every allowed factor was verified.
    • isRaisedBy

      public boolean isRaisedBy(StrongAuthPolicy other)
      Checks if another policy is at least as strict as this one in every field: what an application may raise its policy to (SA-D-5 (a): raise, never lower).
      Parameters:
      other - The other policy.
      Returns:
      true when other lowers nothing: its count and floor are not less, its factors are within these, its mandatory factors include these, it is strict where this is, and it binds everyone this binds.
    • asSource

      public StrongAuthPolicy.Source asSource()
      Gets the policy as a source, every key set: what an application's code hands the server to raise its policy with.
      Returns:
      The source.
    • preset

      public StrongAuthPolicy.Preset preset()
      Gets the preset this policy is, for ServerAdmin's dialog and the applications table: the preset whose policy under the factors supported now (StrongAuthPolicy.Preset.policy()) is this one.
      Returns:
      The preset, null when the policy is none of them ("Custom").
    • toString

      public String toString()
      Gets the policy as it is written in a log. Nothing in it is a secret.
      Specified by:
      toString in class Record
      Returns:
      E.g. {count=2,factors=[passkey, totp],mandatory=[],device=flexible,floor=1,who=all}.
    • 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 the compare method from their corresponding wrapper classes.
      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 int 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 int 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