use of com.helger.phase4.ebms3header.Ebms3MessageProperties in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA20.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: One-Way/Push MEP. SMSH sends an AS4 User Message including
* a TRACKINGIDENTIFIER property set by the producer.<br>
* <br>
* Predicate: <br>
* The RMSH returns a non-repudiation receipt within a HTTP response with
* status code 2XX and the received AS4 message contains the
* TRACKINGIDENTIFIER property.
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA20() throws Exception {
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final Ebms3PartyInfo aEbms3PartyInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, AS4TestConstants.CEF_INITIATOR_ID, CAS4.DEFAULT_RESPONDER_URL, AS4TestConstants.CEF_RESPONDER_ID);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final String sTrackerIdentifier = "trackingidentifier";
aEbms3MessageProperties.addProperty(MessageHelperMethods.createEbms3Property(sTrackerIdentifier, "tracker"));
final AS4UserMessage aDoc = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aDoc.getAsSoapDocument(m_aPayload), m_eSoapVersion, aDoc.getMessagingID(), null, s_aResMgr, false, AS4SigningParams.createDefault());
final NodeList aNL = aSignedDoc.getElementsByTagName("eb:MessageProperties");
assertEquals(aNL.item(0).getLastChild().getAttributes().getNamedItem("name").getTextContent(), sTrackerIdentifier);
final String sResponse = sendPlainMessage(new HttpXMLEntity(aSignedDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
use of com.helger.phase4.ebms3header.Ebms3MessageProperties in project phase4 by phax.
the class AS4eSENSCEFOneWayFuncTest method testEsens_TA03.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: One-Way/Push MEP. SMSH and RMSH exchange several AS4 User
* Messages.<br>
* <br>
* Predicate: <br>
* Each exchanged AS4 message contains single ORIGIN and DESTINATION elements.
* <br>
* Goal: "Both UserMessage/PartyInfo/From and UserMessage/PartyInfo/To must
* not include more than one PartyId element"
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA03() throws Exception {
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final Ebms3PartyInfo aEbms3PartyInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, AS4TestConstants.CEF_INITIATOR_ID, CAS4.DEFAULT_RESPONDER_URL, AS4TestConstants.CEF_RESPONDER_ID);
aEbms3PartyInfo.getTo().addPartyId(MessageHelperMethods.createEbms3PartyId("Second ID"));
// Check if we added a second party id
assertTrue(aEbms3PartyInfo.getTo().getPartyId().size() == 2);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
aUserMessage.setPartyInfo(aEbms3PartyInfo);
aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
aUserMessage.setMessageProperties(aEbms3MessageProperties);
aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
aUserMessage.setMessageInfo(aEbms3MessageInfo);
final Document aDoc = new AS4UserMessage(ESoapVersion.AS4_DEFAULT, aUserMessage).getAsSoapDocument(m_aPayload);
sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.ebms3header.Ebms3MessageProperties in project phase4 by phax.
the class AS4_NETFuncTest method testSendToAS4_NET.
@Test
public void testSendToAS4_NET() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
// New message ID
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, COLLABORATION_INFO_SERVICE_TYPE, COLLABORATION_INFO_SERVICE, COLLABORATION_INFO_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "phase4-sender", CAS4.DEFAULT_RESPONDER_URL, TO_PARTY_ID);
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = new CommonsArrayList<>(MessageHelperMethods.createEbms3Property(CAS4.ORIGINAL_SENDER, null, "C1"), MessageHelperMethods.createEbms3Property(CAS4.FINAL_RECIPIENT, null, "C4"));
aEbms3Properties.add(MessageHelperMethods.createEbms3Property("trackingidentifier", "tracker"));
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final AS4UserMessage aUserMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
// Sign payload document
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aUserMsg.getAsSoapDocument(), m_eSoapVersion, aUserMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aSignedDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
}
use of com.helger.phase4.ebms3header.Ebms3MessageProperties in project phase4 by phax.
the class HolodeckFuncTest method testSendToHolodeck.
@Test
public void testSendToHolodeck() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().build(), s_aResMgr));
// New message ID
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(true ? null : m_aESENSOneWayPMode.getID(), true ? null : DEFAULT_AGREEMENT, COLLABORATION_INFO_SERVICE_TYPE, COLLABORATION_INFO_SERVICE, COLLABORATION_INFO_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "phase4-sender", CAS4.DEFAULT_RESPONDER_URL, TO_PARTY_ID);
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = new CommonsArrayList<>(MessageHelperMethods.createEbms3Property(CAS4.ORIGINAL_SENDER, null, "C1"), MessageHelperMethods.createEbms3Property(CAS4.FINAL_RECIPIENT, null, "C4"));
aEbms3Properties.add(MessageHelperMethods.createEbms3Property("trackingidentifier", "tracker"));
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final AS4UserMessage aUserMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
// Sign payload document
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aUserMsg.getAsSoapDocument(), m_eSoapVersion, aUserMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aSignedDoc, aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
}
use of com.helger.phase4.ebms3header.Ebms3MessageProperties in project phase4 by phax.
the class AbstractUserMessageTestSetUpExt method modifyUserMessage.
/**
* Modify the standard user message to try special cases or provoke failure
* messages.
*
* @param sAnotherOrWrongPModeID
* @param sAnotherOrWrongPartyIdInitiator
* @param sAnotherOrWrongPartyIdResponder
* @param aEbms3MessageProperties
* Default should be with _defaultProperties(), only if you do not want
* them change this
* @return
* @throws Exception
*/
@Nonnull
protected static final Document modifyUserMessage(@Nullable final String sAnotherOrWrongPModeID, @Nullable final String sAnotherOrWrongPartyIdInitiator, @Nullable final String sAnotherOrWrongPartyIdResponder, @Nullable final Ebms3MessageProperties aEbms3MessageProperties, @Nullable final ICommonsList<WSS4JAttachment> aAttachments, @Nullable final String sReferenceToMessageID, @Nullable final Consumer<String> aMessagingIDConsumer) throws Exception {
// If argument is set replace the default one
final String sSetPartyIDInitiator = sAnotherOrWrongPartyIdInitiator == null ? DEFAULT_PARTY_ID : sAnotherOrWrongPartyIdInitiator;
final String sSetPartyIDResponder = sAnotherOrWrongPartyIdResponder == null ? DEFAULT_PARTY_ID : sAnotherOrWrongPartyIdResponder;
Ebms3PayloadInfo aEbms3PayloadInfo;
Node aPayload = null;
if (aAttachments == null) {
aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
} else {
aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aAttachments);
}
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(sReferenceToMessageID);
final Ebms3CollaborationInfo aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sAnotherOrWrongPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, sSetPartyIDInitiator, CAS4.DEFAULT_RESPONDER_URL, sSetPartyIDResponder);
final AS4UserMessage aMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, ESoapVersion.AS4_DEFAULT).setMustUnderstand(true);
if (aMessagingIDConsumer != null)
aMessagingIDConsumer.accept(aMsg.getMessagingID());
return aAttachments != null ? aMsg.getAsSoapDocument(null) : aMsg.getAsSoapDocument(aPayload);
}
Aggregations