Package anbxj

Class AnBx_CommandLine_Parser<R extends Enum<?>,C extends Enum<?>>

java.lang.Object
anbxj.AnBx_CommandLine_Parser<R,C>
Type Parameters:
R - The type of role enumeration.
C - The type of channels enumerators.

public abstract class AnBx_CommandLine_Parser<R extends Enum<?>,C extends Enum<?>> extends Object
An abstract class for parsing command line arguments.
  • Field Details

    • ct

      protected static Channel_SSLChannelType ct
      Default SSL channel type, overridden by command line parameters.
    • layer

      protected AnBx_Layers layer
      The layer for the application.
    • keypath

      protected static String keypath
      Path to the key file, set via command line parameters.
    • sharepath

      protected static String sharepath
      Path to the shared resources, set via command line parameters.
    • myAlias

      protected static String myAlias
      Alias for identification, set via command line parameters.
    • crypto_config

      protected static Crypto_Config crypto_config
      Configuration for cryptography, set via command line parameters.
    • role

      protected R extends Enum<?> role
      Role enumeration, set via command line parameters.
    • configFile

      protected static Properties configFile
      Configuration file, set via command line parameters.
    • protname

      protected static String protname
      Name of the protocol, set via command line parameters.
    • sessions

      protected static long sessions
      Number of sessions for the protocol run, set via command line parameters.
    • vflag

      protected static boolean vflag
      Verbose flag, set via command line parameters.
  • Constructor Details

    • AnBx_CommandLine_Parser

      public AnBx_CommandLine_Parser(String[] args, String prot, String configName, Class<R> roles, boolean vflag)
      Create a AnBx_CommandLine_Parser
      Parameters:
      args - the command line arguments
      prot - the protocol name
      configName - the name of the config file
      roles - the protocol roles enumerator
      vflag - true = verbose mode, false = silent mode
    • AnBx_CommandLine_Parser

      public AnBx_CommandLine_Parser(String[] args, String prot, String configName, Class<R> roles, boolean vflag, boolean parseFullArgs)
      Create a AnBx_CommandLine_Parser
      Parameters:
      args - the command line arguments
      prot - the protocol name
      configName - the name of the config file
      roles - the protocol roles enumerator
      vflag - true = verbose mode, false = silent mode
      parseFullArgs - true = parsing a standard application (all arguments accepted), false = parsing a setup application (fewer arguments accepted)
  • Method Details

    • setLayer

      protected void setLayer(AnBx_Layers layer)
      Set the debug level
      Parameters:
      layer - the debugging layer
      See Also:
    • usage

      public static String usage()
      Computes the usage string for the given protocol
      Returns:
      the usage string
    • initProtocol

      protected abstract void initProtocol()
      Initialise the protocol
    • terminate

      protected static void terminate(String msg)
      Terminates the protocol after an error occurs and prints a message
      Parameters:
      msg - the error message to be printed
    • terminate

      protected static void terminate(String msg, String[] args)
      Terminates the protocol after an error occurs and prints a message along with the arguments passed.
      Parameters:
      msg - The error message to be printed.
      args - The array of arguments to be included in the error message.
    • getRole

      public String getRole()
      Get the role name
      Returns:
      the role name
    • isFirstRole

      protected boolean isFirstRole(C channel, R role)
      Get the sender role in a channel
      Parameters:
      channel - the specified channel
      role - the specified role
      Returns:
      true if R is the first role in channel C
    • getRoleShare

      protected R getRoleShare(Class<R> roles)
      Gets the role used to share information during the protocol setup
      Parameters:
      roles - the protocol roles enumerator
      Returns:
      the role used to share information prior protocol run
    • getConfigFile

      protected Properties getConfigFile()
      Loads the properties from the config file
      Returns:
      the properties object read from the config file
    • readConfigFile

      protected void readConfigFile(Map<String,String> aliases, Class<R> roles, R role)
      Reads the properties from the config file
      Parameters:
      aliases - mapping channel names to channel settings
      roles - the protocol roles enumerator
      role - the protocol role
    • initRole

      protected void initRole(Channel_SSLChannelType ct, R role, Map<String,Channel_Settings> cs, Map<String,String> aliases, Class<R> roles, Class<C> channels)
      Initialise the role
      Parameters:
      ct - the channel type
      role - the protocol role
      cs - mapping channel names to channel settings
      aliases - mapping role names with aliases (identifies)
      roles - the protocol roles enumerator
      channels - the protocol channels enumerator
    • getKeypath

      public static String getKeypath()
      Returns the path to the directory containing keystore files.

      This value is set during command line parsing from the configuration file (property keypath). If the property was not provided, the method may return null.

      Returns:
      the keystore directory path as a String, or null if not set.
    • getCryptoConfig

      public static Crypto_Config getCryptoConfig()
      Returns the cryptographic configuration object.

      The configuration is built from the properties file specified via the command line (option -f) and includes all cryptographic algorithm and provider settings. This object is used throughout the application to initialise the cryptographic engine.

      Returns:
      the Crypto_Config instance, or null if the configuration could not be loaded (e.g., missing config file).