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 Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionSource(Integer count, Set<String> factors, Set<String> mandatory, StrongAuthPolicy.Device device, Integer floor, StrongAuthPolicy.Who who) Creates an instance of aSourcerecord class.Method Summary
Modifier and TypeMethodDescriptioncombine(StrongAuthPolicy.Source other) 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.count()Returns the value of thecountrecord component.device()Returns the value of thedevicerecord component.final booleanIndicates whether some other object is "equal to" this one.factors()Returns the value of thefactorsrecord component.floor()Returns the value of thefloorrecord component.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Checks if the source sets nothing.Returns the value of themandatoryrecord component.static StrongAuthPolicy.Sourceof(String prefix, String count, String factors, String mandatory, String device, String floor, String who) Parses the six keys from their texts.static StrongAuthPolicy.SourceParses the six keys from a settings container, as the server settings and an application'smoduleAppsettings 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.static StrongAuthPolicy.Sourceparse(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.toString()Gets the source as it is written in a log: the keys it sets.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 mostStrongAuthSupport.maxCount(), every factor named infactorsandmandatorya supported one.who()Returns the value of thewhorecord component.
Field Details
NONE
The source that sets nothing.
Constructor Details
Source
public Source(Integer count, Set<String> factors, Set<String> mandatory, StrongAuthPolicy.Device device, Integer floor, StrongAuthPolicy.Who who) Creates an instance of aSourcerecord class.- Parameters:
count- the value for thecountrecord componentfactors- the value for thefactorsrecord componentmandatory- the value for themandatoryrecord componentdevice- the value for thedevicerecord componentfloor- the value for thefloorrecord componentwho- the value for thewhorecord component
Method Details
isEmpty
public boolean isEmpty()Checks if the source sets nothing.- Returns:
- true when every key is unset.
parse
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,
NONEwhen 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
Parses the six keys from a settings container, as the server settings and an application'smoduleAppsettings 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,
NONEwhen it sets nothing. - Throws:
IllegalArgumentException- Asparse(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:0to 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-flexibleorstrict; null or blank for unset.floor- The floor:1to the supported maximum; null or blank for unset.who-alloradministrators; null or blank for unset.- Returns:
- The source,
NONEwhen 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 aboveStrongAuthSupport.maxCount(), a factor that is not supported); the message names the key, the value and what is supported.
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 mostStrongAuthSupport.maxCount(), every factor named infactorsandmandatorya 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
hashCode
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. All components in this record class are compared withObjects::equals(Object,Object).count
factors
mandatory
device
floor
who