phax/as2-lib

AS2MDNReceiverHandler - can't get async mdn because no found partnership in massage object and in mdn object

ihudedi opened this issue · 11 comments

Hi Philip,
In AS2MDNReceiverHandler class receiveMDN method:

The following code in this method:

  // get the MDN partnership info
      aMDN.partnership ().setSenderAS2ID (aMDN.getHeader (CHttpHeader.AS2_FROM));
      aMDN.partnership ().setReceiverAS2ID (aMDN.getHeader (CHttpHeader.AS2_TO));
      // Set the appropriate keystore aliases
      aMDN.partnership ().setSenderX509Alias (aMsg.partnership ().getReceiverX509Alias ());
      aMDN.partnership ().setReceiverX509Alias (aMsg.partnership ().getSenderX509Alias ());
      // Update the partnership
      getModule ().getSession ().getPartnershipFactory ().updatePartnership (aMDN, false);

The issue is the no partnership exist in message object only dummy with empty values.
Therefore the senderX509alias is empty and the recieverX509alias is empty.
The line getModule ().getSession ().getPartnershipFactory ().updatePartnership (aMDN, false);
return no partnership found exception due to the no alias found in the partnership and exist in partnership in config.xml.
How can we fill the partnership of message and mdn that the code will work.
Thanks,
Itay

phax commented

That depends on the implementation of IPartnershipFactory you are using. What have you configured in config.xml?

Hi Philip,
I am using the default config.xml located at as2-server project.
Thanks,
Itay

Is it fine or needs to change to something else?

phax commented

Okay, so you are using the default ServerXMLPartnershipFactory which stores files in %home%/partnerships.xml.
Can you confirm, that you have such a file.
By default you need to configure each partnership separately inside this file. Did you do that?

Hi Philip,
Yes I am using the default partnership.xml.I am testing the client server but I have the partnership but as I wrote above the alias is missing in the partnership object and it fails becsuse you set the alias from message partnership to mdn partnership and in this module it is empty.

I have just reported the same issue, note #79 with reference to the same two lines of code.
I am also using the com.helger.as2.app.partner.ServerXMLPartnershipFactory for the partnerships.xml file and have defined x509_alias= attributes in each of the settings. This is required presumably so that the certificates can be found by their aliases.

phax commented

Please change from class com.helger.as2.app.partner.ServerXMLPartnershipFactory to class com.helger.as2.app.partner.ServerSelfFillingXMLPartnershipFactory which handles exactly this case.
The difference is, that the "SelfFilling" factory is based on class SelfFillingXMLPartnershipFactory that supports dynamic partnerships. hth

Hi philp,
Beacause the alias for sender and reciever is arrived empty value the selffill wont fix the issue.we dont get the alias in this code.you should remove the settinh for alias of sender and reciever in this situation.
Thanks,
Itay

phax commented

You mean, because the alias is empty, this check doesn't work for you?
In that case you must override onBeforeAddPartnership method so that it fits your needs. Sorry.

Hi,
In async mdn the alias gets empty always.You can check it.
Why we need to populate the alias and not take from the xml?

I would like the alias be fetched from the file in case it's not arrived in the partnership and the value is empty or null.