code: private void handleEndOfStream() throws StreamIntegrityException {
      if (endOfStreamHandled) {
        return;
      }
  
      endOfStreamHandled = true;
  
      byte[] originalHMAC = trailerIn.getTrailer();
      byte[] calculateHMAC = mac.doFinal();
  
      if (! AES256JNCryptor.arraysEqual(originalHMAC, calculateHMAC)) {
        throw new StreamIntegrityException("MAC validation failed.");
      }
    }
docs: Verifies the HMAC value and throws an exception if it fails.
  
  @throws IOException
  if the HMAC value is incorrect