Class SignedBabelMessage<T extends BabelMessage>

java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.SignedBabelMessage<T>
Type Parameters:
T - the type of the inner message payload
All Implemented Interfaces:
BabelMessage

public final class SignedBabelMessage<T extends BabelMessage> extends Object implements BabelMessage
Wrapper for a BabelMessage that optionally carries a cryptographic signature and the identity of the sending node.

A signed message encapsulates an inner payload of type T alongside the BabelNode sender and its digital signature bytes. If the message is unsigned, both the sender and signature are null. Invariant: either both sender and signature are null, or both are non-null.

  • Constructor Details

    • SignedBabelMessage

      public SignedBabelMessage(T innerMessage)
      Constructs an unsigned wrapper around the specified inner message payload.
      Parameters:
      innerMessage - the message payload to wrap
    • SignedBabelMessage

      public SignedBabelMessage(T innerMessage, @Nullable BabelNode sender, @Nullable byte[] signature)
      Constructs a signed or unsigned message wrapper.
      Parameters:
      innerMessage - the message payload to wrap
      sender - the sender identity, or null if unsigned
      signature - the digital signature bytes, or null if unsigned
      Throws:
      IllegalArgumentException - if one of sender or signature is null while the other is non-null
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • innerMessage

      public T innerMessage()
      Returns the encapsulated inner message payload.
      Returns:
      the inner message payload
    • sender

      public @Nullable BabelNode sender()
      Returns the identity of the node that sent and signed this message, or null if this message is unsigned.
      Returns:
      the sender node identity, or null