Package de.das.encrypter.processors
Class Assembler
java.lang.Object
de.das.encrypter.processors.Assembler
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.
Another requirement for using this class is that the EncoderDecoder has previously been passed the list of available keys.
-
Constructor Summary
ConstructorsConstructorDescriptionAssembler(int expectedSize, ProgressListener pl) Creates a new data assembler for assembling a fragmented key. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Return the received data independent on it is a key or any other data.byte[]getKey()Provides the received and decrypted key.booleanChecks if the received data is decryptable and after decryption if it is a valid key.voidsetData(byte[] fragment) Writes the received data fragment to the collection buffer.
-
Constructor Details
-
Assembler
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.
-