Search in sources :

Example 16 with Ebms3PartyInfo

use of com.helger.phase4.ebms3header.Ebms3PartyInfo in project phase4 by phax.

the class CEFCompatibilityValidatorTwoWayFuncTest method testValidateUserMessageMoreThanOnePartyID.

@Test
public void testValidateUserMessageMoreThanOnePartyID() {
    final Ebms3PartyId aFirstId = MessageHelperMethods.createEbms3PartyId("type", "value");
    final Ebms3PartyId aSecondId = MessageHelperMethods.createEbms3PartyId("type2", "value2");
    final Ebms3From aFromPart = new Ebms3From();
    aFromPart.addPartyId(aFirstId);
    aFromPart.addPartyId(aSecondId);
    final Ebms3To aToPart = new Ebms3To();
    aToPart.addPartyId(aFirstId);
    aToPart.addPartyId(aSecondId);
    final Ebms3PartyInfo aPartyInfo = new Ebms3PartyInfo();
    aPartyInfo.setFrom(aFromPart);
    aPartyInfo.setTo(aToPart);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setPartyInfo(aPartyInfo);
    VALIDATOR.validateUserMessage(aUserMessage, m_aErrorList);
    assertTrue(m_aErrorList.containsAny(x -> x.getErrorText(LOCALE).contains("must contain no more than one PartyID")));
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) PModeLegSecurity(com.helger.phase4.model.pmode.leg.PModeLegSecurity) MessageHelperMethods(com.helger.phase4.messaging.domain.MessageHelperMethods) EMEP(com.helger.phase4.model.EMEP) ErrorList(com.helger.commons.error.list.ErrorList) ETriState(com.helger.commons.state.ETriState) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Assert.assertNotSame(org.junit.Assert.assertNotSame) EPModeSendReceiptReplyPattern(com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Locale(java.util.Locale) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) PMode(com.helger.phase4.model.pmode.PMode) PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) ClassRule(org.junit.ClassRule) PModeLegErrorHandling(com.helger.phase4.model.pmode.leg.PModeLegErrorHandling) PhotonAppWebTestRule(com.helger.photon.app.mock.PhotonAppWebTestRule) Before(org.junit.Before) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) PModeLegProtocol(com.helger.phase4.model.pmode.leg.PModeLegProtocol) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) Assert.assertTrue(org.junit.Assert.assertTrue) EMEPBinding(com.helger.phase4.model.EMEPBinding) Test(org.junit.Test) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ignore(org.junit.Ignore) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) IPModeIDProvider(com.helger.phase4.model.pmode.IPModeIDProvider) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 17 with Ebms3PartyInfo

use of com.helger.phase4.ebms3header.Ebms3PartyInfo in project phase4 by phax.

the class ENTSOGCompatibilityValidatorTest method testValidateUserMessageMoreThanOnePartyID.

@Test
public void testValidateUserMessageMoreThanOnePartyID() {
    final Ebms3PartyId aFirstId = MessageHelperMethods.createEbms3PartyId("type", "value");
    final Ebms3PartyId aSecondId = MessageHelperMethods.createEbms3PartyId("type2", "value2");
    final Ebms3From aFromPart = new Ebms3From();
    aFromPart.addPartyId(aFirstId);
    aFromPart.addPartyId(aSecondId);
    final Ebms3To aToPart = new Ebms3To();
    aToPart.addPartyId(aFirstId);
    aToPart.addPartyId(aSecondId);
    final Ebms3PartyInfo aPartyInfo = new Ebms3PartyInfo();
    aPartyInfo.setFrom(aFromPart);
    aPartyInfo.setTo(aToPart);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setPartyInfo(aPartyInfo);
    VALIDATOR.validateUserMessage(aUserMessage, m_aErrorList);
    assertTrue(m_aErrorList.containsAny(x -> x.getErrorText(LOCALE).contains("must contain no more than one PartyID")));
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) PModeLegSecurity(com.helger.phase4.model.pmode.leg.PModeLegSecurity) MessageHelperMethods(com.helger.phase4.messaging.domain.MessageHelperMethods) EMEP(com.helger.phase4.model.EMEP) ErrorList(com.helger.commons.error.list.ErrorList) ETriState(com.helger.commons.state.ETriState) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Assert.assertNotSame(org.junit.Assert.assertNotSame) EPModeSendReceiptReplyPattern(com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Locale(java.util.Locale) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) PMode(com.helger.phase4.model.pmode.PMode) PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) ClassRule(org.junit.ClassRule) PModeLegErrorHandling(com.helger.phase4.model.pmode.leg.PModeLegErrorHandling) PhotonAppWebTestRule(com.helger.photon.app.mock.PhotonAppWebTestRule) Before(org.junit.Before) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) PModeLegProtocol(com.helger.phase4.model.pmode.leg.PModeLegProtocol) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) Assert.assertTrue(org.junit.Assert.assertTrue) EMEPBinding(com.helger.phase4.model.EMEPBinding) Test(org.junit.Test) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ignore(org.junit.Ignore) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) IPModeIDProvider(com.helger.phase4.model.pmode.IPModeIDProvider) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 18 with Ebms3PartyInfo

use of com.helger.phase4.ebms3header.Ebms3PartyInfo 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));
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) NodeList(org.w3c.dom.NodeList) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 19 with Ebms3PartyInfo

use of com.helger.phase4.ebms3header.Ebms3PartyInfo 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());
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 20 with Ebms3PartyInfo

use of com.helger.phase4.ebms3header.Ebms3PartyInfo 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);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Document(org.w3c.dom.Document) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Aggregations

Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)26 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)22 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)21 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)21 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)19 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)18 Nonnull (javax.annotation.Nonnull)15 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)12 Test (org.junit.Test)12 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)11 Ebms3From (com.helger.phase4.ebms3header.Ebms3From)7 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)7 HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)7 Document (org.w3c.dom.Document)7 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)6 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)6 Node (org.w3c.dom.Node)6 ErrorList (com.helger.commons.error.list.ErrorList)4 ETriState (com.helger.commons.state.ETriState)4 ECryptoAlgorithmCrypt (com.helger.phase4.crypto.ECryptoAlgorithmCrypt)4