Skip to content

Commit

Permalink
Calculate MIC only if MDN is requested; #58
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Aug 27, 2018
1 parent 973ed99 commit cb13085
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ protected void onReceivedMDNError (@Nonnull final AS2Message aMsg,

private void _sendViaHTTP (@Nonnull final AS2Message aMsg,
@Nonnull final MimeBodyPart aSecuredMimePart,
@Nonnull final String sMIC) throws OpenAS2Exception, IOException, MessagingException
@Nullable final String sMIC) throws OpenAS2Exception, IOException, MessagingException
{
final Partnership aPartnership = aMsg.partnership ();

Expand Down Expand Up @@ -793,6 +793,8 @@ public final void write (final byte [] aBytes, final int nOfs, final int nLen) t
if (aPartnership.getAS2ReceiptDeliveryOption () == null)
{
// go ahead to receive sync MDN
// Note: If an MDN is requested, a MIC is present
assert sMIC != null;
receiveSyncMDN (aMsg, aConn, sMIC);

if (LOGGER.isInfoEnabled ())
Expand Down Expand Up @@ -840,7 +842,11 @@ public void handle (@Nonnull final String sAction,

// Calculate MIC after compress/sign/crypt was handled, because the
// message data might change if compression before signing is active.
final String sMIC = calculateAndStoreMIC (aMsg);
final String sMIC;
if (aMsg.isRequestingMDN ())
sMIC = calculateAndStoreMIC (aMsg);
else
sMIC = null;

if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Setting message content type to '" + aSecuredData.getContentType () + "'");
Expand Down

0 comments on commit cb13085

Please sign in to comment.