@NotThreadSafe public class LazyMessageCryptoHandler extends Object implements MessageCryptoHandler
MessageCryptoHandler that delegates to another MessageCryptoHandler, which is created
at the last possible moment. Typically, this is used in order to defer the creation of the data
key (and associated request to the CryptoMaterialsManager
until the max message size is known.| Modifier and Type | Class and Description |
|---|---|
static class |
LazyMessageCryptoHandler.LateBoundInfo |
| Constructor and Description |
|---|
LazyMessageCryptoHandler(Function<LazyMessageCryptoHandler.LateBoundInfo,MessageCryptoHandler> delegateFactory) |
| Modifier and Type | Method and Description |
|---|---|
int |
doFinal(byte[] out,
int outOff)
Finish processing of the bytes.
|
int |
estimateFinalOutputSize()
Return the size of the output buffer required for a call to
CryptoHandler.doFinal(byte[], int). |
int |
estimateOutputSize(int inLen)
Return the size of the output buffer required for a
CryptoHandler.processBytes(byte[], int, int,
byte[], int) plus a CryptoHandler.doFinal(byte[], int) call with an input of inLen bytes. |
int |
estimatePartialOutputSize(int inLen)
Return the size of the output buffer required for a call to
CryptoHandler.processBytes(byte[], int,
int, byte[], int). |
Map<String,String> |
getEncryptionContext()
Return the encryption context used in the generation of the data key used for the encryption of
content.
|
CiphertextHeaders |
getHeaders() |
List<? extends MasterKey<?>> |
getMasterKeys()
All used
MasterKeys. |
boolean |
isComplete()
For decrypt and parsing flows returns
true when this has handled as many bytes as it
can. |
ProcessingSummary |
processBytes(byte[] in,
int inOff,
int inLen,
byte[] out,
int outOff)
Process a block of bytes from
in putting the result into out. |
void |
setMaxInputLength(long size)
Informs this handler of an upper bound on the input data size.
|
public LazyMessageCryptoHandler(Function<LazyMessageCryptoHandler.LateBoundInfo,MessageCryptoHandler> delegateFactory)
public void setMaxInputLength(long size)
MessageCryptoHandlerIf this method is called multiple times, the smallest bound will be used.
setMaxInputLength in interface MessageCryptoHandlersize - An upper bound on the input data size.public boolean isComplete()
CryptoHandlertrue when this has handled as many bytes as it
can. This usually means that it has reached the end of an object, file, or other delimited
stream.isComplete in interface CryptoHandlerpublic Map<String,String> getEncryptionContext()
MessageCryptoHandlerDuring decryption, this value should be obtained by parsing the ciphertext headers that encodes this value.
getEncryptionContext in interface MessageCryptoHandlerpublic CiphertextHeaders getHeaders()
getHeaders in interface MessageCryptoHandlerpublic ProcessingSummary processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff)
CryptoHandlerin putting the result into out.processBytes in interface CryptoHandlerin - the input byte array.inOff - the offset into the in array where the data to be processed starts.inLen - the number of bytes to be processed.out - the output buffer the processed bytes go into.outOff - the offset into the output byte array the processed data starts at.out and the number of bytes parsed.public List<? extends MasterKey<?>> getMasterKeys()
MessageCryptoHandlerMasterKeys. For encryption flows, these are all the MasterKeys used to protect the data. In the decryption flow, it is the single MasterKey actually used to decrypt the data.getMasterKeys in interface MessageCryptoHandlerpublic int doFinal(byte[] out,
int outOff)
CryptoHandlerdoFinal in interface CryptoHandlerout - the output buffer for copying any remaining output data.outOff - offset into out to start copying the output data.out.public int estimateOutputSize(int inLen)
CryptoHandlerCryptoHandler.processBytes(byte[], int, int,
byte[], int) plus a CryptoHandler.doFinal(byte[], int) call with an input of inLen bytes.
Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.
estimateOutputSize in interface CryptoHandlerinLen - the length of the input.CryptoHandler.doFinal(byte[],
int) with an input of size inLen bytes.public int estimatePartialOutputSize(int inLen)
CryptoHandlerCryptoHandler.processBytes(byte[], int,
int, byte[], int).
Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.
estimatePartialOutputSize in interface CryptoHandlerinLen - the length of the input.CryptoHandler.processBytes(byte[], int, int,
byte[], int) with an input of size inLen bytes.public int estimateFinalOutputSize()
CryptoHandlerCryptoHandler.doFinal(byte[], int).
Note this method is allowed to return an estimation of the output size that is greater than the actual size of the output. Returning an estimate that is lesser than the actual size of the output will result in underflow exceptions.
estimateFinalOutputSize in interface CryptoHandlerCryptoHandler.doFinal(byte[], int)Copyright © 2023. All rights reserved.