Class DataCodec
java.lang.Object
org.geysermc.floodgate.core.crypto.DataCodec
- Direct Known Subclasses:
AesDataCodec,DataCodecKeyPair
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ByteBufferdecode(List<ByteBuffer> dataSections) Decodes the given data using the Key provided ininit(Key)abstract List<ByteBuffer>encode(ByteBuffer plainText) Encodes the given data using the Key provided ininit(Key)protected voidensureAlgorithm(String algorithm, Key key) protected voidensureSectionCount(int expectedSectionCount, String name, List<ByteBuffer> sections) abstract voidInitializes the instance by giving it the key it needs to sign/verify or encrypt/decrypt data
-
Constructor Details
-
DataCodec
public DataCodec()
-
-
Method Details
-
init
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
Encodes the given data using the Key provided ininit(Key)- Parameters:
plainText- the data to encode- Returns:
- the encoded data
- Throws:
Exception- when the encoding failed
-
decode
Decodes the given data using the Key provided ininit(Key)- Parameters:
dataSections- the data sections to decode- Returns:
- the decoded data
- Throws:
Exception- when the decoding failed
-
ensureAlgorithm
-
ensureSectionCount
-