Class Assembler

java.lang.Object
de.das.encrypter.processors.Assembler

public class Assembler extends Object
An assembler is a class that provides the functionality to reassemble data fragments of a key that has been split by a splitter into one key again. It is expected that the fragmented key is also encrypted with another key known to the recipient. After receiving and assembling all fragmented parts, the first thing to do is to call the method for checking whether the received key is a valid key. This decrypts thereby also the received data (if the proper key is available), which can be used then as new key.

Another requirement for using this class is that the EncoderDecoder has previously been passed the list of available keys.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Assembler(int expectedSize, ProgressListener pl)
    Creates a new data assembler for assembling a fragmented key.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Return the received data independent on it is a key or any other data.
    byte[]
    Provides the received and decrypted key.
    boolean
    Checks if the received data is decryptable and after decryption if it is a valid key.
    void
    setData(byte[] fragment)
    Writes the received data fragment to the collection buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Assembler

      public Assembler(int expectedSize, ProgressListener pl)
      Creates a new data assembler for assembling a fragmented key. The prerequisite is that the fragments arrive at the assembler in the correct order.
      Parameters:
      expectedSize - the expected size of the whole data.
      pl - an instance implementing the interface ProgressListener or null if no progress listener is used.
  • Method Details

    • setData

      public void setData(byte[] fragment)
      Writes the received data fragment to the collection buffer.
      Parameters:
      fragment - the next part of the expected data.
    • isValidKey

      public boolean isValidKey()
      Checks if the received data is decryptable and after decryption if it is a valid key. The check includes verification of the correct data length and whether the required key for decryption is available. If the check is successful, the encrypted key is also available.
      Returns:
      true, if the received data is a valid decryptable key.
    • getKey

      public byte[] getKey()
      Provides the received and decrypted key. It is available if the validation check was successful.
      Returns:
      the received and decrypted key or null, if the key could not be assembled or decrypted.
    • getData

      public byte[] getData()
      Return the received data independent on it is a key or any other data.
      Returns:
      the received data independent on it is a key or any other data.