org.apache.camel.converter.crypto
Class HMACAccumulator
java.lang.Object
org.apache.camel.converter.crypto.HMACAccumulator
public class HMACAccumulator
- extends Object
HMACAccumulator
is used to build Hash Message Authentication
Codes. It has two modes, one where all the data acquired is used to build the
MAC and a second that assumes that the last n bytes of the acquired data will
contain a MAC for all the data previous.
The first mode it used in an encryption phase to create a MAC for the
encrypted data. The second mode is used in the decryption phase and
recalculates the MAC taking into account that for cases where the encrypted
data MAC has been appended. Internally the accumulator uses a circular buffer
to simplify the housekeeping of avoiding the last n bytes.
It is assumed that the supplied buffersize is always greater than or equal to
the mac length.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
outputStream
protected OutputStream outputStream
HMACAccumulator
public HMACAccumulator(Key key,
String macAlgorithm,
String cryptoProvider,
int buffersize)
throws Exception
- Throws:
Exception
encryptUpdate
public void encryptUpdate(byte[] buffer,
int read)
- Update buffer with MAC. Typically used in the encryption phase where no
hmac is appended to the buffer.
decryptUpdate
public void decryptUpdate(byte[] buffer,
int read)
throws IOException
- Update buffer with MAC taking into account that a MAC is appended to the
buffer and should be precluded from the MAC calculation.
- Throws:
IOException
getCalculatedMac
public byte[] getCalculatedMac()
getAppendedMac
public byte[] getAppendedMac()
validate
public void validate()
getMaclength
public int getMaclength()
attachStream
public void attachStream(ByteArrayOutputStream outputStream)
Apache Camel