Search in sources :

Example 1 with DigestManager

use of org.apache.bookkeeper.proto.checksum.DigestManager in project bookkeeper by apache.

the class MockBookKeeperTestCase method extractEntryPayload.

private byte[] extractEntryPayload(long ledgerId, long entryId, ByteBufList toSend) throws BKException.BKDigestMatchException {
    ByteBuf toSendCopy = Unpooled.copiedBuffer(toSend.toArray());
    toSendCopy.resetReaderIndex();
    DigestManager macManager = null;
    try {
        macManager = getDigestType(ledgerId);
    } catch (GeneralSecurityException gse) {
        LOG.error("Initialize macManager fail", gse);
    }
    ByteBuf content = macManager.verifyDigestAndReturnData(entryId, toSendCopy);
    byte[] entry = new byte[content.readableBytes()];
    content.readBytes(entry);
    content.resetReaderIndex();
    content.release();
    return entry;
}
Also used : DigestManager(org.apache.bookkeeper.proto.checksum.DigestManager) GeneralSecurityException(java.security.GeneralSecurityException) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 GeneralSecurityException (java.security.GeneralSecurityException)1 DigestManager (org.apache.bookkeeper.proto.checksum.DigestManager)1