java.lang.Object
anbxj.AnB_Protocol<S,R,ST>
- Type Parameters:
S- class stepsR- roles classST- type of per-session state (used by generated roles)
AnB Protocol: an abstract class for defining AnB protocols
-
Field Summary
FieldsModifier and TypeFieldDescriptionMapping of aliases for protocol roles.protected Crypto_EncryptionEngineThe cryptographic engineprotected static final AnBx_LayersThe layer for debugging purposes.protected Map<String, AnB_Session> Mapping of session names to session instances.protected AnBx_Agentthe identity of the agentprotected StringThe name of the protocol.protected RThe role of the protocol.protected final AtomicLongPer-instance session ID counter (one per role instance).protected StringThe path for sharing data in the protocol.protected Crypto_ByteArrayA byte array of zeros used in the protocol. -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructorprotectedAnB_Protocol(R role, String name, String sharepath, Crypto_EncryptionEngine ee) Constructs a protocol instance with the specified role, agent name, shared‑data path, and cryptographic engine. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAbort the protocol with a specified error messageprotected voidAbort the protocol with a specified error message, exception, and session ID.protected abstract STcreateSessionState(long sessionID) Creates the per-session state object for a new protocol session.protected booleanChecks if two objects are equal without a specific label.protected booleanChecks if two objects are equal with a flag indicating possible failure.protected booleanChecks if two objects are equal with a specified label.protected booleanChecks if two objects are equal with a specified label and a flag indicating possible failure.protected abstract voidexecuteStep(AnB_Session session, ST state, S step) Abstract method to execute a step in the AnB protocol.protected StringgetAlias()Get the alias for the current role.protected longReturns the number of sessions that are currently being executed.protected abstract voidinit()Abstract method to initialise the AnB protocol.protected booleanPerform an inverse check without a label for a single object.protected booleanPerform an inverse check without a label for an object and a class.protected booleanPerform an inverse check without a label for two objects.protected booleanPerform an inverse check with a label for a single object.protected booleanPerform an inverse check with a label for an object and a class.protected booleanPerform an inverse check with a label for two objects.protected booleanGet the value of abortOnFail.protected booleanReturn the value of checkAnywayprotected longReturns the next unique session ID (thread-safe).protected booleannoteqCheck(Object obj1, Object obj2) Checks if two objects are not equal without a specific label.protected booleannoteqCheck(String label, Object obj1, Object obj2) Checks if two objects are not equal with a specified label.voidRuns the protocol with the given maps of sessions and aliases.protected voidrunProtocol(Map<String, AnB_Session> channelTemplates) Runs the protocol using the session count defined in the crypto configuration.protected voidrunProtocol(Map<String, AnB_Session> channelTemplates, long sessions) Runs the protocol using the supplied channel templates and session count.protected abstract voidrunSession(Map<String, AnB_Session> channelMap, ST state) Executes the complete protocol for one logical session.protected booleanChecks if the specified object has been seen.protected booleanChecks if the specified object has been seen with a given label.protected voidsetAbortOnFail(boolean abortOnFail) Set the value of abortOnFail.protected voidsetCheckAnyway(boolean checkAnyway) Set the value of checkAnyway.protected voidOutputs the status of the protocol with a specific step.protected voidOutputs the status of the protocol with a specific step and payload.protected voidstatusLabel(String label) Outputs the status label for a check with a given label.protected booleanChecks if the given object is a well-formed formula (WFF) without a specific label.protected booleanChecks if the given object is a well-formed formula (WFF) with a specified class type.protected booleanChecks if the given object is a well-formed formula (WFF) with a specified label.protected booleanChecks if the given object is a well-formed formula (WFF) with a specified label and class type.
-
Field Details
-
layer
The layer for debugging purposes. -
name
The name of the protocol. -
role
The role of the protocol. -
me
the identity of the agent -
ee
The cryptographic engine -
aliases
Mapping of aliases for protocol roles. -
lbs
Mapping of session names to session instances. -
sessionID
Per-instance session ID counter (one per role instance). -
zero
A byte array of zeros used in the protocol.
-
-
Constructor Details
-
AnB_Protocol
public AnB_Protocol()Default constructor -
AnB_Protocol
Constructs a protocol instance with the specified role, agent name, shared‑data path, and cryptographic engine.- Parameters:
role- the role this instance playsname- the agent namesharepath- the directory where shared variables are storedee- the pre‑configured cryptographic engine
-
-
Method Details
-
nextSessionID
protected long nextSessionID()Returns the next unique session ID (thread-safe).- Returns:
- the next unique session ID
-
run
Runs the protocol with the given maps of sessions and aliases.- Parameters:
lbs- Mapping of session names to session instances.aliases- Mapping of aliases for protocol roles.
-
executeStep
Abstract method to execute a step in the AnB protocol.- Parameters:
session- the session to usestate- the per-session state object (specific to the protocol)step- the step to execute
-
init
protected abstract void init()Abstract method to initialise the AnB protocol. -
createSessionState
Creates the per-session state object for a new protocol session.The returned object must be initialised with the given session identifier and any global (shared) variables that were loaded during
init(). This method is called once for each logical session beforerunSession(Map, Object).- Parameters:
sessionID- the unique identifier assigned to this session- Returns:
- a newly created session-state instance, never
null
-
runSession
Executes the complete protocol for one logical session.The supplied
channelMapcontains every channel required by the role, already opened and keyed by the channel name used in the protocol definition (e.g."ROLE_M_channel_ROLE_C_Server_Insecure"). Implementations must run all steps of the protocol on the appropriate channel(s), using the given session-state object.- Parameters:
channelMap- a mapping from channel name to an open session; nevernull, and no entry isnullstate- the per-session state previously created bycreateSessionState(long); nevernull
-
isAbortOnFail
protected boolean isAbortOnFail()Get the value of abortOnFail.- Returns:
- true if the protocol should abort on failure, false otherwise.
-
setAbortOnFail
protected void setAbortOnFail(boolean abortOnFail) Set the value of abortOnFail.- Parameters:
abortOnFail- The value to set for abortOnFail.
-
isCheckAnyway
protected boolean isCheckAnyway()Return the value of checkAnyway- Returns:
- the checkAnyway
-
setCheckAnyway
protected void setCheckAnyway(boolean checkAnyway) Set the value of checkAnyway.- Parameters:
checkAnyway- The value to set for checkAnyway.
-
abort
Abort the protocol with a specified error message- Parameters:
msg- The error message.
-
abort
Abort the protocol with a specified error message, exception, and session ID.- Parameters:
msg- The error message.e- The exception (can be null).sessionID- The session ID.
-
getAlias
Get the alias for the current role.- Returns:
- The alias for the current role.
-
invCheck
Perform an inverse check with a label for two objects.- Parameters:
label- The label for the check.obj1- The first object.obj2- The second object.- Returns:
- True if the check is successful, false otherwise.
-
invCheck
Perform an inverse check with a label for an object and a class.- Parameters:
label- The label for the check.obj- The object.cls- The class to check against.- Returns:
- True if the check is successful, false otherwise.
-
invCheck
Perform an inverse check with a label for a single object.- Parameters:
label- The label for the check.obj- The object.- Returns:
- True if the check is successful, false otherwise.
-
invCheck
Perform an inverse check without a label for two objects.- Parameters:
obj1- The first object.obj2- The second object.- Returns:
- True if the check is successful, false otherwise.
-
invCheck
Perform an inverse check without a label for an object and a class.- Parameters:
obj- The object.cls- The class to check against.- Returns:
- True if the check is successful, false otherwise.
-
invCheck
Perform an inverse check without a label for a single object.- Parameters:
obj- The object.- Returns:
- True if the check is successful, false otherwise.
-
wffCheck
Checks if the given object is a well-formed formula (WFF) with a specified label.- Parameters:
label- the label for the checkobj- the object to be checked- Returns:
- true if the object is a well-formed formula, false otherwise
-
wffCheck
Checks if the given object is a well-formed formula (WFF) with a specified label and class type.- Parameters:
label- the label for the checkobj- the object to be checkedcls- the expected class type for the object- Returns:
- true if the object is a well-formed formula, false otherwise
-
wffCheck
Checks if the given object is a well-formed formula (WFF) without a specific label.- Parameters:
obj- the object to be checked- Returns:
- true if the object is a well-formed formula, false otherwise
-
wffCheck
Checks if the given object is a well-formed formula (WFF) with a specified class type.- Parameters:
obj- the object to be checkedcls- the expected class type for the object- Returns:
- true if the object is a well-formed formula, false otherwise
-
noteqCheck
Checks if two objects are not equal with a specified label.- Parameters:
label- the label for the checkobj1- the first object to be comparedobj2- the second object to be compared- Returns:
- true if the objects are not equal, false otherwise
-
noteqCheck
Checks if two objects are not equal without a specific label.- Parameters:
obj1- the first object to be comparedobj2- the second object to be compared- Returns:
- true if the objects are not equal, false otherwise
-
eqCheck
Checks if two objects are equal with a specified label.- Parameters:
label- the label for the checkobj1- the first object to be comparedobj2- the second object to be compared- Returns:
- true if the objects are equal, false otherwise
-
eqCheck
Checks if two objects are equal with a specified label and a flag indicating possible failure.- Parameters:
label- the label for the checkobj1- the first object to be comparedobj2- the second object to be comparedmayfail- flag indicating whether the check may fail- Returns:
- true if the objects are equal, false otherwise
-
eqCheck
Checks if two objects are equal without a specific label.- Parameters:
obj1- the first object to be comparedobj2- the second object to be compared- Returns:
- true if the objects are equal, false otherwise
-
eqCheck
Checks if two objects are equal with a flag indicating possible failure.- Parameters:
obj1- the first object to be comparedobj2- the second object to be comparedmayfail- flag indicating whether the check may fail- Returns:
- true if the objects are equal, false otherwise
-
seen
Checks if the specified object has been seen with a given label.- Parameters:
label- the label for the checkobj- the object to be checked- Returns:
- true if the object has been seen before, false otherwise
-
seen
Checks if the specified object has been seen.- Parameters:
obj- the object to be checked- Returns:
- true if the object has been seen before, false otherwise
-
status
Outputs the status of the protocol with a specific step.- Parameters:
step- the step in the protocol
-
statusLabel
Outputs the status label for a check with a given label.- Parameters:
label- the label for the check
-
status
Outputs the status of the protocol with a specific step and payload.- Parameters:
step- the step in the protocolpayload- the payload associated with the step
-
getSessions
protected long getSessions()Returns the number of sessions that are currently being executed. This is a convenience proxy for the value stored in the crypto configuration.- Returns:
- the total session count
-
runProtocol
Runs the protocol using the session count defined in the crypto configuration.- Parameters:
channelTemplates- a map from channel name to its session template
-
runProtocol
Runs the protocol using the supplied channel templates and session count. Automatically chooses the execution mode (multi-threaded server, parallel clients, or single-threaded) based on the crypto configuration.- Parameters:
channelTemplates- a map from channel name to its session template (the sessions passed vialbs)sessions- the total number of sessions to execute
-