Class StrongOptions

java.lang.Object
com.iizix.server.StrongOptions

public final class StrongOptions extends Object
The six -strong* options of the server's command line (CC-SERVERADMIN-STRONG-AUTH, section 3.2 of the design of order 475, SA-D-6 (a)): after -app and before its -appjar or -project, in the one-parameter style of every other option, they set the strong authentication policy of that application - source S3 of the policy's resolution, as the six strong* properties of the application's definition in config.iiziServer do:
-app com.example.bank -strongcount 2 -strongmandatory passkey -strongdevice strict -appjar bank.jar

Every value goes through the policy's own parser (StrongAuthPolicy.Source.of(String, String, String, String, String, String, String)), so what the file refuses the command line refuses the same way: a value outside its range or above the supported maximum (CC-FIX-SIGNIN-STRONG-SUPPORTED-MAX) is refused where the option is read, naming the option, the value and what is supported, and the server does not start (exit 9 with one SEVERE, like the file); the rules among the six keys (StrongAuthPolicy.checkSource(String, UnaryOperator)) are checked when the application's definition is complete.

When the configuration file defines the application too, the command line's strong values are combined with the file's, the strictest winning field by field (SA-D-6 (a)): a command line can raise the protection of a deployed application and never lower it. The combination is made where the policy is resolved (SignInPolicies.strong, from the AppDefinition the command line built); the file's definition is never changed by it, so a later save of the configuration from ServerAdmin does not write what the command line said. decided(StrongAuthPolicy.Source, StrongAuthPolicy.Source) says which source decided each key, for the log.

Author:
Christopher Mindus
  • Field Details

    • PREFIX

      public static final String PREFIX
      The prefix of the options: "-strong", followed by the key (-strongcount, ...). The parser is handed it as the prefix of the keys, so a refusal names the option as it was typed.
      See Also:
    • OPTIONS

      public static final String[] OPTIONS
      The six options, lower case, in the order of StrongAuthPolicy.KEYS.
  • Constructor Details

    • StrongOptions

      public StrongOptions()
      Creates the options of one application, none given.
  • Method Details

    • isOption

      public static boolean isOption(String option)
      Checks if an option is one of the six.
      Parameters:
      option - The option, lower case.
      Returns:
      true for -strongcount, ..., -strongwho.
    • isEmpty

      public boolean isEmpty()
      Checks if any of the six was given.
      Returns:
      true when at least one option was set.
    • set

      public void set(String option, String value)
      Sets an option as it was typed: the value is parsed at once, so a bad one is refused where it stands.
      Parameters:
      option - One of the six options, lower case.
      value - Its parameter.
      Throws:
      IllegalArgumentException - If the option is none of the six, was given twice, or its value is outside its range or above the supported maximum; the message names the option, the value and what is supported.
    • build

      public StrongAuthPolicy.Source build()
      Builds the source of the options given, checked as one level (StrongAuthPolicy.checkSource(String, UnaryOperator): the rules among the six keys, a floor above the count, a mandatory factor outside the allowed ones).
      Returns:
      The source, StrongAuthPolicy.Source.NONE when no option was given.
      Throws:
      IllegalArgumentException - If the six break a rule among themselves; the message names the keys.
    • decided

      public static String decided(StrongAuthPolicy.Source file, StrongAuthPolicy.Source commandLine)
      Says which source decided each key of the combination of a file's definition with a command line's options, the strictest winning field by field (SA-D-6 (a)): for the log line of the start.
      Parameters:
      file - What the file's definition sets.
      commandLine - What the command line sets.
      Returns:
      E.g. count=2 (the command line), mandatory=[passkey] (the file), device=strict (both); the keys neither sets are left out; nothing when neither sets anything.