Class FullSignedBabelMessageSerializer<T extends BabelMessage>
java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.BasicSignedBabelMessageSerializer<T>
pt.unl.fct.di.novasys.babel2.channels.FullSignedBabelMessageSerializer<T>
- Type Parameters:
T- the type of the innerBabelMessage
- All Implemented Interfaces:
BabelNetworkMessageSerializer<SignedBabelMessage<T>>, BabelNetworkSerializer<SignedBabelMessage<T>>
public class FullSignedBabelMessageSerializer<T extends BabelMessage>
extends BasicSignedBabelMessageSerializer<T>
Extended serializer for
SignedBabelMessage instances capable of both signing
outgoing messages and forwarding already-signed messages.
When serializing an unsigned message (where SignedBabelMessage.signature() is null),
this serializer uses the local PrivateKey and BabelNode identity to compute
a digital signature over the serialized inner message bytes and appends the sender and signature
to the output buffer. If the message already possesses a signature and sender, they are forwarded directly.
Deserialization and verification behavior are inherited from BasicSignedBabelMessageSerializer.
-
Constructor Summary
ConstructorsConstructorDescriptionFullSignedBabelMessageSerializer(PrivateKey key, BabelNode myself, BabelNetworkMessageSerializer<T> innerSerializer) Constructs a full signed message serializer with explicit private key and local node identity.FullSignedBabelMessageSerializer(BabelNetworkMessageSerializer<T> innerSerializer, Babel runtime) Constructs a full signed message serializer by extracting the private key and local identity from the activeBabelruntime. -
Method Summary
Modifier and TypeMethodDescriptiongetKey()Returns the private key used by this serializer to compute digital signatures.Returns the local node identity attached as the sender on outgoing messages.voidserialize(SignedBabelMessage<T> object, io.netty.buffer.ByteBuf out, NodeStore store) Encodesobjectand appends the resulting bytes toout.Methods inherited from class BasicSignedBabelMessageSerializer
deserialize, getEstimateSize, getId, getInnerSerializer, getObjectClassModifier and TypeMethodDescriptiondeserialize(io.netty.buffer.ByteBuf in, NodeStore store) Reads an instance ofTfrom the supplied buffer.intgetEstimateSize(SignedBabelMessage<T> object) Returns an estimated size in bytes for the given object.intgetId()Returns the unique numeric identifier for the message type handled by this serializer.protected BabelNetworkMessageSerializer<T> Returns the delegate serializer responsible for the inner message.Returns the class of objects handled by this serializer, used for registry lookup.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelNetworkSerializer
getEstimateSizeModifier and TypeMethodDescriptiondefault intgetEstimateSize(SignedBabelMessage<T> object, @Nullable NodeStore store) Returns a size estimate to fit the entire object in aByteBufwithout needing resizes.
-
Constructor Details
-
FullSignedBabelMessageSerializer
public FullSignedBabelMessageSerializer(PrivateKey key, BabelNode myself, BabelNetworkMessageSerializer<T> innerSerializer) Constructs a full signed message serializer with explicit private key and local node identity.- Parameters:
key- the private key used to compute signaturesmyself- the local node identityinnerSerializer- the delegate serializer for the inner message
-
FullSignedBabelMessageSerializer
public FullSignedBabelMessageSerializer(BabelNetworkMessageSerializer<T> innerSerializer, Babel runtime) Constructs a full signed message serializer by extracting the private key and local identity from the activeBabelruntime.- Parameters:
innerSerializer- the delegate serializer for the inner messageruntime- the Babel runtime containing node identity and key pair
-
-
Method Details
-
serialize
Description copied from interface:BabelNetworkSerializerEncodesobjectand appends the resulting bytes toout.- Specified by:
serializein interfaceBabelNetworkSerializer<T extends BabelMessage>- Overrides:
serializein classBasicSignedBabelMessageSerializer<T extends BabelMessage>- Parameters:
object- the object to serializeout- the destination bufferstore- the node store context for resolving node components
-
getKey
Returns the private key used by this serializer to compute digital signatures.- Returns:
- the private key
-
getMyself
Returns the local node identity attached as the sender on outgoing messages.- Returns:
- the local node identity
-