phax / as2-lib

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

PartnershipNotFoundException: Partnership not found: when handling an ASync MDN message #79

Closed andrewjmaguire closed 5 years ago

andrewjmaguire commented 5 years ago

Hi,

I have been trialling an AS2 communication with Async MDN but, when I send an ASync MDN to as2-server, I get PartnershipNotFoundException: Partnership not found: [Partnership@0x1f1333b2: name=auto-created-dummy; senderIDs=[{as2_id=SENDER, x509_alias=null}]; receiverIDs=[{as2_id=RECEIVER, x509_alias=null}]; attributes=[{}]]

I have found that if I comment out the following in AS2MDNReceiverHandler.java lines 186 and 187: aMDN.getPartnership ().setSenderX509Alias (aMsg.partnership ().getReceiverX509Alias ()); aMDN.getPartnership ().setReceiverX509Alias (aMsg.partnership ().getSenderX509Alias ());

Then the ASync MDN message works. I have tried to look through the code to work out how an ASync Mssage, aMsg would have the X509 aliases present. Looking at the git blame history, these lines appear to have been added trying to find a solution for 'note #4 '. But that issue only affected Sync MDN messages not Async.

I am curious to know whether my configuration is still incomplete given that the ASync MDN code presumably works for others?

Thanks Andrew

ihudedi commented 5 years ago

Hi Philip, Are you going to fix this issue in 4.3? same issue I opened in issue #63 Thanks, Itay

phax commented 5 years ago

Pls see the comment at #63 for details.

ihudedi commented 5 years ago

Hi Philip, According to the code

 // Ensure the X509 key is contained for certificate store alias retrieval
    if (!aPartnership.containsSenderX509Alias ())
      aPartnership.setSenderX509Alias (aPartnership.getSenderAS2ID ());

    if (!aPartnership.containsReceiverX509Alias ())
      aPartnership.setReceiverX509Alias (aPartnership.getReceiverAS2ID ());

You create now new parnership with wrong alias - the alias isn't the as2id.Is it only that the program will continue? becuase if we need those params it's failed?

phax commented 5 years ago

Yes correct. The alias is needed, and this is solution I chose for the scenario I needed it. You can of course overwrite the protected method onBeforeAddPartnership to change the programming logic to your requirements.