Class DataCodec

java.lang.Object
org.geysermc.floodgate.core.crypto.DataCodec
Direct Known Subclasses:
AesDataCodec, DataCodecKeyPair

public abstract class DataCodec extends Object
Responsible for data integrity by either signing or encrypting the data.

Unlike KeyProducer, KeyCodec and Topping this class does have state. For every key a new instance should be made, or use init(Key) to reset that state.

  • Constructor Details

    • DataCodec

      public DataCodec()
  • Method Details

    • init

      public abstract void init(Key key)
      Initializes the instance by giving it the key it needs to sign/verify or encrypt/decrypt data
      Parameters:
      key - the key used to sign/verify or encrypt/decrypt data
    • encode

      public abstract List<ByteBuffer> encode(ByteBuffer plainText) throws Exception
      Encodes the given data using the Key provided in init(Key)
      Parameters:
      plainText - the data to encode
      Returns:
      the encoded data
      Throws:
      Exception - when the encoding failed
    • decode

      public abstract ByteBuffer decode(List<ByteBuffer> dataSections) throws Exception
      Decodes the given data using the Key provided in init(Key)
      Parameters:
      dataSections - the data sections to decode
      Returns:
      the decoded data
      Throws:
      Exception - when the decoding failed
    • ensureAlgorithm

      protected void ensureAlgorithm(String algorithm, Key key)
    • ensureSectionCount

      protected void ensureSectionCount(int expectedSectionCount, String name, List<ByteBuffer> sections)