Package anbxj

Class AnB_Principal

java.lang.Object
anbxj.AnB_Principal

public class AnB_Principal extends Object
AnB Principal: A concrete principal for AnB/AnBx protocols.

This abstract class serves as a concrete implementation of a principal for AnB/AnBx protocols. It initialises AnB sessions based on provided key store settings, channel settings, aliases, and configuration. It also provides methods to run AnB protocols using the initialised sessions.

  • Field Details

    • exchange_identities

      protected boolean exchange_identities
      Flag to automatically exchange identities during session if set to true
    • lbs

      protected Map<String,AnB_Session> lbs
      Mapping agent identities and sessions
    • ee

      The cryptographic engine
    • aliases

      protected Map<String,String> aliases
      Mapping agent aliases
  • Constructor Details

    • AnB_Principal

      public AnB_Principal(Crypto_EncryptionEngine ee, String myAlias, Map<String,Channel_Settings> cs, Map<String,String> aliases, Crypto_Config config)
      Constructs a principal that reuses an already initialised cryptographic engine. This constructor is intended for scenarios where a single engine is created externally (e.g., in the command-line parser) and shared across all sessions of this principal, avoiding repeated warm-up and engine construction.
      Parameters:
      ee - the shared cryptographic engine (must not be null)
      myAlias - the alias of the local principal (must not be null)
      cs - a map from channel names to their settings; each entry defines how a session for that channel will be set up
      aliases - a map from role names to their corresponding aliases; may be null, in which case an empty map is used
      config - the cryptographic configuration (determines keystore usage, algorithm settings, etc.)
    • AnB_Principal

      public AnB_Principal(Crypto_EncryptionEngine ee, String myAlias, Map<String,Channel_Settings> cs, Map<String,String> aliases, Crypto_Config config, Channel_MessageSerializer serializer)
      Constructs a principal that creates all client sessions using the given serializer. This is used to switch to a length-delimited wire format (e.g., Protocol Buffers or Java blob serialisation) while keeping the rest of the generated role code unchanged.
      Parameters:
      ee - the shared cryptographic engine
      myAlias - the alias of the local principal
      cs - a map from channel names to their settings
      aliases - a map from role names to their corresponding aliases
      config - the cryptographic configuration
      serializer - the serializer to use for all client sessions
    • AnB_Principal

      public AnB_Principal(Crypto_KeyStoreSettings_Map kssd, Map<String,Channel_Settings> cs, Map<String,String> aliases, Crypto_Config config)
      Constructor for AnB_Principal with specified key store settings, channel settings, aliases, and configuration.
      Parameters:
      kssd - Crypto key store settings map.
      cs - Map of channel settings.
      aliases - Map of aliases.
      config - Crypto configuration.
    • AnB_Principal

      public AnB_Principal(Crypto_KeyStoreSettings_Map kssd, Map<String,Channel_Settings> cs, Map<String,String> aliases)
      Constructor for AnB_Principal with specified key store settings, channel settings, and aliases.
      Parameters:
      kssd - Crypto key store settings map.
      cs - Map of channel settings.
      aliases - Map of aliases.
    • AnB_Principal

      public AnB_Principal(String myAlias, String path, Map<String,Channel_Settings> cs, Map<String,String> aliases, Crypto_Config config)
      Constructor for AnB_Principal with specified alias, path, channel settings, aliases, and configuration.
      Parameters:
      myAlias - Alias of the principal.
      path - Path for key store settings.
      cs - Map of channel settings.
      aliases - Map of aliases.
      config - Crypto configuration.
    • AnB_Principal

      public AnB_Principal(String myAlias, String path, Map<String,Channel_Settings> cs, Map<String,String> aliases)
      Constructor for AnB_Principal with specified alias, path, channel settings, and aliases.
      Parameters:
      myAlias - Alias of the principal.
      path - Path for key store settings.
      cs - Map of channel settings.
      aliases - Map of aliases.
  • Method Details

    • init

      protected void init(Crypto_EncryptionEngine ee, String myAlias, Map<String,Channel_Settings> cs, Map<String,String> aliases, Crypto_Config config, Channel_MessageSerializer serializer)
      Single initialisation point for all session maps.

      For each channel in the given map cs:

      • With a serializer (Protobuf/JavaFramed): Client sessions use the serializer constructors of AnB_Session. Server sessions are wrapped in a Channel_ProtoServer and then an AnB_Session. If a remote alias is known (present in aliases), the remote identity is set immediately; otherwise identity exchange is governed by exchange_identities.
      • Without a serializer (traditional Java serialisation): Sessions are created via the engine-based non-serializer constructors of AnB_Session, with or without remote alias as appropriate.
      Parameters:
      ee - the shared cryptographic engine (must not be null)
      myAlias - the alias of the local principal (must not be null)
      cs - a map from channel names to their Channel_Settings
      aliases - a map from role names to their corresponding aliases
      config - the cryptographic configuration, used to determine whether keystore-based channel properties are needed
      serializer - the serialiser used for length-delimited framing on both client and server sides; may be null to fall back to standard Java object serialisation
    • run

      public <S extends Enum<?>, R extends Enum<?>, ST> void run(AnB_Protocol<S,R,ST> prot)
      Runs the specified AnB protocol (single session).
      Type Parameters:
      S - Enum representing the protocol's steps.
      R - Enum representing the protocol's roles.
      ST - Type of per-session state (ignored by the principal).
      Parameters:
      prot - AnB protocol to run.