Package anbxj
Class AnB_Principal
java.lang.Object
anbxj.AnB_Principal
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 Summary
FieldsModifier and TypeFieldDescriptionMapping agent aliasesprotected Crypto_EncryptionEngineThe cryptographic engineprotected booleanFlag to automatically exchange identities during session if set to trueprotected Map<String, AnB_Session> Mapping agent identities and sessions -
Constructor Summary
ConstructorsConstructorDescriptionAnB_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.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.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.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.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.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. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinit(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.run(AnB_Protocol<S, R, ST> prot) Runs the specified AnB protocol (single session).
-
Field Details
-
exchange_identities
protected boolean exchange_identitiesFlag to automatically exchange identities during session if set to true -
lbs
Mapping agent identities and sessions -
ee
The cryptographic engine -
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 benull)myAlias- the alias of the local principal (must not benull)cs- a map from channel names to their settings; each entry defines how a session for that channel will be set upaliases- a map from role names to their corresponding aliases; may benull, in which case an empty map is usedconfig- 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 enginemyAlias- the alias of the local principalcs- a map from channel names to their settingsaliases- a map from role names to their corresponding aliasesconfig- the cryptographic configurationserializer- 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 byexchange_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 benull)myAlias- the alias of the local principal (must not benull)cs- a map from channel names to theirChannel_Settingsaliases- a map from role names to their corresponding aliasesconfig- the cryptographic configuration, used to determine whether keystore-based channel properties are neededserializer- the serialiser used for length-delimited framing on both client and server sides; may benullto fall back to standard Java object serialisation
- 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
-
run
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.
-