Class OlmMessage

java.lang.Object
io.github.fherbreteau.vodozemac.olm.OlmMessage

public final class OlmMessage extends Object
A structured Olm message, consisting of a MessageType and a base64-encoded ciphertext body.

An OlmMessage is produced by OlmSession.encrypt(byte[]) and consumed by OlmSession.decrypt(OlmMessage) and Account.createInboundSession(io.github.fherbreteau.vodozemac.types.Curve25519PublicKey, OlmMessage).

The message will either be a pre-key message or a normal message, depending on whether the session is fully established. A session is fully established once at least one message has been received and decrypted from the other side.

The toString() method produces a JSON representation compatible with the Matrix Olm message format ({"body":"<base64>","type":<int>}), which is what the native vodozemac layer expects for serialisation and deserialisation.

Author:
François HERBRETEAU
See Also:
  • Method Details

    • body

      public String body()
      Returns the base64-encoded ciphertext body of this message.
      Returns:
      the ciphertext body as a base64 string
    • type

      public MessageType type()
      Returns the type of this message.
      Returns:
      the MessageType (pre-key or normal)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toJson()
      Returns the JSON representation of this message, in the format {"body":"<base64>","type":<int>}.

      This format is compatible with the Matrix Olm message serialisation used by the native vodozemac layer.

      Returns:
      a JSON string representation of this message
    • toString

      public String toString()
      Overrides:
      toString in class Object