phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

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

Closed ihudedi closed 5 years ago

ihudedi commented 6 years ago

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 6 years ago

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

ihudedi commented 6 years ago

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

ihudedi commented 6 years ago

Is it fine or needs to change to something else?

phax commented 6 years ago

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?

ihudedi commented 6 years ago

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.

andrewjmaguire commented 5 years ago

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 5 years ago

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

ihudedi commented 5 years ago

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 5 years ago

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.

ihudedi commented 5 years ago

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?

ihudedi commented 5 years ago

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.