use of org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferBackedDataInputImpl in project ignite by apache.
the class RecordDataV1Serializer method readEncryptedData.
/**
* Reads and decrypt data from {@code in} stream.
*
* @param in Input stream.
* @param readType If {@code true} plain record type will be read from {@code in}.
* @param readKeyId If {@code true} encryption key identifier will be read from {@code in}.
* @return Plain data stream, group id, plain record type,
* @throws IOException If failed.
* @throws IgniteCheckedException If failed.
*/
private T3<ByteBufferBackedDataInput, Integer, RecordType> readEncryptedData(ByteBufferBackedDataInput in, boolean readType, boolean readKeyId) throws IOException, IgniteCheckedException {
int grpId = in.readInt();
int encRecSz = in.readInt();
RecordType plainRecType = null;
if (readType)
plainRecType = RecordV1Serializer.readRecordType(in);
int keyId = readKeyId ? in.readUnsignedByte() : GridEncryptionManager.INITIAL_KEY_ID;
byte[] encData = new byte[encRecSz];
in.readFully(encData);
GroupKey grpKey = encMgr.groupKey(grpId, keyId);
if (grpKey == null)
return new T3<>(null, grpId, plainRecType);
byte[] clData = encSpi.decrypt(encData, grpKey.key());
return new T3<>(new ByteBufferBackedDataInputImpl().buffer(ByteBuffer.wrap(clData)), grpId, plainRecType);
}
use of org.apache.ignite.internal.processors.cache.persistence.wal.ByteBufferBackedDataInputImpl in project gridgain by gridgain.
the class RecordDataV1Serializer method readEncryptedData.
/**
* Reads and decrypt data from {@code in} stream.
*
* @param in Input stream.
* @param readType If {@code true} plain record type will be read from {@code in}.
* @param readKeyId If {@code true} encryption key identifier will be read from {@code in}.
* @return Plain data stream, group id, plain record type,
* @throws IOException If failed.
* @throws IgniteCheckedException If failed.
*/
private T3<ByteBufferBackedDataInput, Integer, RecordType> readEncryptedData(ByteBufferBackedDataInput in, boolean readType, boolean readKeyId) throws IOException, IgniteCheckedException {
int grpId = in.readInt();
int encRecSz = in.readInt();
RecordType plainRecType = null;
if (readType)
plainRecType = RecordV1Serializer.readRecordType(in);
int keyId = readKeyId ? in.readUnsignedByte() : GridEncryptionManager.INITIAL_KEY_ID;
byte[] encData = new byte[encRecSz];
in.readFully(encData);
GroupKey grpKey = encMgr.groupKey(grpId, keyId);
if (grpKey == null)
return new T3<>(null, grpId, plainRecType);
byte[] clData = encSpi.decrypt(encData, grpKey.key());
return new T3<>(new ByteBufferBackedDataInputImpl().buffer(ByteBuffer.wrap(clData)), grpId, plainRecType);
}
Aggregations