Skip to content

Commit

Permalink
Extended AS4UserMessage.create API to include MPC
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Sep 15, 2023
1 parent 323deb6 commit 1efb122
Show file tree
Hide file tree
Showing 37 changed files with 369 additions and 360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ public AS4ClientBuiltMessage buildMessage (@Nonnull @Nonempty final String sMess
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
null,
getSoapVersion ()).setMustUnderstand (true);

if (aCallback != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,38 @@ public final Ebms3UserMessage getEbms3UserMessage ()
}

@Nonnull
public static AS4UserMessage create (@Nonnull final ESoapVersion eSoapVersion, @Nonnull final Ebms3UserMessage aUserMessage)
public static AS4UserMessage create (@Nonnull final ESoapVersion eSoapVersion,
@Nonnull final Ebms3UserMessage aUserMessage)
{
return new AS4UserMessage (eSoapVersion, aUserMessage);
}

@Nonnull
@Deprecated (forRemoval = true, since = "2.3.0")
public static AS4UserMessage create (@Nonnull final Ebms3MessageInfo aEbms3MessageInfo,
@Nullable final Ebms3PayloadInfo aEbms3PayloadInfo,
@Nonnull final Ebms3CollaborationInfo aEbms3CollaborationInfo,
@Nonnull final Ebms3PartyInfo aEbms3PartyInfo,
@Nullable final Ebms3MessageProperties aEbms3MessageProperties,
@Nonnull final ESoapVersion eSoapVersion)
{
return create (aEbms3MessageInfo,
aEbms3PayloadInfo,
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
null,
eSoapVersion);
}

@Nonnull
public static AS4UserMessage create (@Nonnull final Ebms3MessageInfo aEbms3MessageInfo,
@Nullable final Ebms3PayloadInfo aEbms3PayloadInfo,
@Nonnull final Ebms3CollaborationInfo aEbms3CollaborationInfo,
@Nonnull final Ebms3PartyInfo aEbms3PartyInfo,
@Nullable final Ebms3MessageProperties aEbms3MessageProperties,
@Nullable final String sMPC,
@Nonnull final ESoapVersion eSoapVersion)
{
final Ebms3UserMessage aUserMessage = new Ebms3UserMessage ();

Expand All @@ -88,6 +108,9 @@ public static AS4UserMessage create (@Nonnull final Ebms3MessageInfo aEbms3Messa
// Message Info
aUserMessage.setMessageInfo (aEbms3MessageInfo);

return new AS4UserMessage (eSoapVersion, aUserMessage);
// MPC
aUserMessage.setMpc (sMPC);

return create (eSoapVersion, aUserMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ private static AS4UserMessage _createReversedUserMessage (@Nonnull final ESoapVe
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
null,
eSoapVersion);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static Document createErrorMessageSigned (@Nonnull final ESoapVersion eSo
{
final ICommonsList <Ebms3Error> aEbms3ErrorList = new CommonsArrayList <> (EEbmsError.EBMS_INVALID_HEADER.getAsEbms3Error (Locale.US,
null));
final AS4ErrorMessage aErrorMsg = AS4ErrorMessage.create (eSoapVersion, "srcmsgid", aEbms3ErrorList).setMustUnderstand (true);
final AS4ErrorMessage aErrorMsg = AS4ErrorMessage.create (eSoapVersion, "srcmsgid", aEbms3ErrorList)
.setMustUnderstand (true);
final Document aSignedDoc = AS4Signer.createSignedMessage (AS4CryptoFactoryProperties.getDefaultInstance (),
aErrorMsg.getAsSoapDocument (),
eSoapVersion,
Expand All @@ -113,8 +114,7 @@ public static Document createReceiptMessageSigned (@Nonnull final ESoapVersion e
MessageHelperMethods.createRandomMessageID (),
null,
aUserMessage,
true)
.setMustUnderstand (true);
true).setMustUnderstand (true);
final Document aDoc = aReceiptMsg.getAsSoapDocument ();

return AS4Signer.createSignedMessage (AS4CryptoFactoryProperties.getDefaultInstance (),
Expand All @@ -140,7 +140,8 @@ public static AS4UserMessage createUserMessageNotSigned (@Nonnull final ESoapVer
aEbms3Properties.add (MessageHelperMethods.createEbms3Property (CAS4.FINAL_RECIPIENT, "C4 FR"));

final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo ();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null, aAttachments);
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null,
aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo ("pmode-twoway",
DEFAULT_AGREEMENT,
"MyServiceTypes",
Expand All @@ -158,8 +159,8 @@ public static AS4UserMessage createUserMessageNotSigned (@Nonnull final ESoapVer
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
eSoapVersion)
.setMustUnderstand (true);
null,
eSoapVersion).setMustUnderstand (true);
return aDoc;
}

Expand All @@ -174,7 +175,8 @@ public static Document createUserMessageSoapNotSignedNotPModeConform (@Nonnull f
aEbms3Properties.add (MessageHelperMethods.createEbms3Property ("ContextID", "987654321"));

final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo ();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null, aAttachments);
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null,
aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo ("pm-esens-generic-resp",
DEFAULT_AGREEMENT,
"MyServiceTypes",
Expand All @@ -192,8 +194,8 @@ public static Document createUserMessageSoapNotSignedNotPModeConform (@Nonnull f
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
eSoapVersion)
.setMustUnderstand (true);
null,
eSoapVersion).setMustUnderstand (true);
return aDoc.getAsSoapDocument (aPayload);
}

Expand All @@ -210,7 +212,8 @@ public static Document createEmptyUserMessage (@Nonnull final ESoapVersion eSoap

// Use an empty message info by purpose
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo ();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null, aAttachments);
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo (aPayload != null,
aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo (null,
null,
null,
Expand All @@ -225,8 +228,8 @@ public static Document createEmptyUserMessage (@Nonnull final ESoapVersion eSoap
aEbms3CollaborationInfo,
aEbms3PartyInfo,
aEbms3MessageProperties,
eSoapVersion)
.setMustUnderstand (true);
null,
eSoapVersion).setMustUnderstand (true);
return aDoc.getAsSoapDocument (aPayload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@IsSPIImplementation
public final class AS4TestProfileRegistarSPI implements IAS4ProfileRegistrarSPI
{
public static final String AS4_PROFILE_ID_FOUR_CORNER = "test";
public static final String AS4_PROFILE_ID_MAY_SIGN_MAY_CRYPT = "test";

private static final Logger LOGGER = LoggerFactory.getLogger (AS4TestProfileRegistarSPI.class);

Expand All @@ -56,8 +56,8 @@ public void registerAS4Profile (@Nonnull final IAS4ProfileRegistrar aRegistrar)
false);

if (LOGGER.isDebugEnabled ())
LOGGER.debug ("Registering phase4 profile '" + AS4_PROFILE_ID_FOUR_CORNER + "'");
final AS4Profile aTestProfile = new AS4Profile (AS4_PROFILE_ID_FOUR_CORNER,
LOGGER.debug ("Registering phase4 profile '" + AS4_PROFILE_ID_MAY_SIGN_MAY_CRYPT + "'");
final AS4Profile aTestProfile = new AS4Profile (AS4_PROFILE_ID_MAY_SIGN_MAY_CRYPT,
"Unit Testing Profile",
TestProfileCompatibilityValidator::new,
aDefaultPModeProvider,
Expand Down
Loading

0 comments on commit 1efb122

Please sign in to comment.