Class VortexMessage

java.lang.Object
net.messagevortex.asn1.AbstractBlock
net.messagevortex.asn1.VortexMessage
All Implemented Interfaces:
Serializable, Block, Dumpable

public class VortexMessage extends AbstractBlock implements Serializable

The main class representing the main message object.

This part is specified as vortexMessage in the file asn.1/messageBlocks.asn1

See Also:
  • Field Details

  • Constructor Details

    • VortexMessage

      public VortexMessage(InputStream is, AsymmetricKey dk) throws IOException

      Parses a byte array to a VortexMessage.

      Parameters:
      is - the input stream to be parsed
      dk - the decryptionKey required to decrypt the prefix
      Throws:
      IOException - if there was a problem parsing or decrypting the object
    • VortexMessage

      public VortexMessage(byte[] b, AsymmetricKey dk) throws IOException

      Parses a byte array to a VortexMessage.

      Parameters:
      b - the byte array to be parsed
      dk - the decryptionKey required to decrypt the prefix
      Throws:
      IOException - if there was a problem parsing or decrypting the object
    • VortexMessage

      public VortexMessage(PrefixBlock pre, InnerMessageBlock im) throws IOException

      Creates a new message block.

      Parameters:
      pre - the prefix block to use
      im - the inner message block to use
      Throws:
      IOException - if there was an error generating the kay
  • Method Details

    • getInnerMessage

      public final InnerMessageBlock getInnerMessage()

      gets the embedded inner message block.

      Returns:
      the message block
    • setInnerMessage

      public final InnerMessageBlock setInnerMessage(InnerMessageBlock im)

      Setter for the inner message block.

      Parameters:
      im - the new inner message block
      Returns:
      the previously set inner message block
    • getPrefix

      public final PrefixBlock getPrefix()

      Gets the embedded prefix block.

      Returns:
      the prefix block
    • setPrefix

      public final PrefixBlock setPrefix(PrefixBlock pre)

      Sets the embedded prefix block.

      Parameters:
      pre - the new prefix block
      Returns:
      the prefix block which was set prior to the operation
    • getDecryptionKey

      public final AsymmetricKey getDecryptionKey()

      Set the currently set encryption/decryption decryptionKey (asymmetric).

      Returns:
      the decryptionKey or null if not set
    • setDecryptionKey

      public final AsymmetricKey setDecryptionKey(AsymmetricKey dk) throws IOException

      Set the encryption/decryption decryptionKey.

      Parameters:
      dk - sets the decryption key
      Returns:
      the decryptionKey which has been set previously or null if the decryptionKey ha not been set
      Throws:
      IOException - if setting fails
    • parse

      protected final void parse(byte[] p) throws IOException
      Overrides:
      parse in class AbstractBlock
      Throws:
      IOException
    • parse

      protected void parse(InputStream is) throws IOException
      Throws:
      IOException
    • parse

      protected void parse(org.bouncycastle.asn1.ASN1Encodable p) throws IOException
      Specified by:
      parse in class AbstractBlock
      Throws:
      IOException
    • toAsn1Object

      public org.bouncycastle.asn1.ASN1Object toAsn1Object(DumpType dt) throws IOException

      Dumps the object a ASN1Object.

      This method is mainly useful for diagnostic purposes.

      Specified by:
      toAsn1Object in interface Dumpable
      Parameters:
      dt - the dumpType to apply
      Returns:
      the requested object as ASN1Object
      Throws:
      IOException - if any object or subobject can not be dumped
    • dumpValueNotation

      public String dumpValueNotation(String prefix) throws IOException

      Dumps an ASN.1 value notation of a vortexMessage (PUBLIC_ONLY dump type).

      Parameters:
      prefix - the line prefix to be used (typically "")
      Returns:
      an ASN.1 representation of the vortexMessage
      Throws:
      IOException - if message i not encodable due to an incomplete/invalid object state
    • dumpValueNotation

      public String dumpValueNotation(String prefix, DumpType dt) throws IOException

      Dumps a ASN.1 value notation of a vortexMessage.

      Specified by:
      dumpValueNotation in interface Block
      Parameters:
      prefix - the line prefix to be used (typically "")
      dt - specifies the type of dump.
      Returns:
      an ASN.1 representation of the vortexMessage
      Throws:
      IOException - if message i not encodable due to an incomplete/invalid object state
    • toBinary

      public byte[] toBinary(DumpType dt) throws IOException

      Build the binary represenattion for a vortexMessage.

      This method returns the binary (length prefixed) representation of a vortex message.

      Parameters:
      dt - specifies the type of dump. for sending use PUBLIC_ONLY
      Returns:
      the binary representation of the vortexMessage
      Throws:
      IOException - if dumping fails
    • getLongAsBytes

      public static byte[] getLongAsBytes(long i, int num)

      converts an unsigned long value into a byte array representation (LSB).

      Parameters:
      i - the long value to be converted
      num - the number of bytes to be returned
      Returns:
      the unsigned byte array representation
    • getLongAsBytes

      public static byte[] getLongAsBytes(long i)

      Converts an unsigned long value into a 32 bit byte array representation (LSB).

      Parameters:
      i - the long value to be converted
      Returns:
      the unsigned byte array of length 4 representation
    • getBytesAsLong

      public static long getBytesAsLong(byte[] b)

      Converts a number of bytes into a long representation (LSB).

      Parameters:
      b - the byte array to be converted to long
      Returns:
      the long representation of the byte array
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object