Search in sources :

Example 31 with Ebms3UserMessage

use of com.helger.phase4.ebms3header.Ebms3UserMessage 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 32 with Ebms3UserMessage

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

the class CEFProfileTest method before.

@Before
public void before() {
    m_eSoapVersion = ESoapVersion.AS4_DEFAULT;
    m_aEbms3UserMessage = new Ebms3UserMessage();
    // Default Payload for testing
    m_aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    if (m_aPayload == null)
        LOGGER.warn("SOAPBodyPayload.xml could not be found no payload attached in PModeCheckTest setup");
    m_aEbms3UserMessage.setPayloadInfo(MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null));
    // Default MessageInfo for testing
    m_aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
    // Default CollaborationInfo for testing
    m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(DEFAULT_PARTY_ID + "12-" + DEFAULT_PARTY_ID + "12", DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
    // Default PartyInfo for testing
    m_aEbms3UserMessage.setPartyInfo(MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, DEFAULT_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, DEFAULT_PARTY_ID));
    // Default MessageProperties for testing
    m_aEbms3UserMessage.setMessageProperties(createDefaultProperties());
    AS4ProfileSelector.setCustomAS4ProfileID(AS4CEFProfileRegistarSPI.AS4_PROFILE_ID);
}
Also used : Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Before(org.junit.Before)

Example 33 with Ebms3UserMessage

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

the class PModeCheckTest method before.

@Before
public void before() {
    m_aEbms3UserMessage = new Ebms3UserMessage();
    // Default Payload for testing
    m_aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    if (m_aPayload == null)
        LOGGER.warn("SOAPBodyPayload.xml could not be found no payload attached in PModeCheckTest setup");
    m_aEbms3UserMessage.setPayloadInfo(MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null));
    // Default MessageInfo for testing
    m_aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
    // Default CollaborationInfo for testing
    m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(DEFAULT_PARTY_ID + "12-" + DEFAULT_PARTY_ID + "12", DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
    // Default PartyInfo for testing
    m_aEbms3UserMessage.setPartyInfo(MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, DEFAULT_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, DEFAULT_PARTY_ID));
    // Default MessageProperties for testing
    m_aEbms3UserMessage.setMessageProperties(createDefaultProperties());
}
Also used : Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Before(org.junit.Before)

Example 34 with Ebms3UserMessage

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

the class MockMessageProcessorCheckingStreamsSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nonnull final IPMode aPmode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    final Ebms3PullRequest aPR = aSignalMessage.getPullRequest();
    if (aPR != null && aPR.getMpc().equals("TWO-SPI")) {
        final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
        // Add properties
        final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
        final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
        final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
        final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
        final Ebms3CollaborationInfo aEbms3CollaborationInfo;
        final Ebms3PartyInfo aEbms3PartyInfo;
        aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
        aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
        final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
        final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
        aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
        aUserMessage.setMessageInfo(aEbms3MessageInfo);
        aUserMessage.setMessageProperties(aEbms3MessageProperties);
        aUserMessage.setPartyInfo(aEbms3PartyInfo);
        aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
        aUserMessage.setMpc(aSignalMessage.getPullRequest().getMpc());
        return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
    }
    return AS4SignalMessageProcessorResult.createSuccess();
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 35 with Ebms3UserMessage

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

the class MockMessageProcessorSPI method processAS4SignalMessage.

@Nonnull
public AS4SignalMessageProcessorResult processAS4SignalMessage(@Nonnull final IAS4IncomingMessageMetadata aMessageMetadata, @Nonnull final HttpHeaderMap aHttpHeaders, @Nonnull final Ebms3SignalMessage aSignalMessage, @Nullable final IPMode aPMode, @Nonnull final IAS4MessageState aState, @Nonnull final ICommonsList<Ebms3Error> aProcessingErrorMessages) {
    if (aSignalMessage.getReceipt() != null) {
        // Receipt - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    if (!aSignalMessage.getError().isEmpty()) {
        // Error - just acknowledge
        return AS4SignalMessageProcessorResult.createSuccess();
    }
    // Must be a pull-request
    final Ebms3PullRequest aPullRequest = aSignalMessage.getPullRequest();
    if (aPullRequest != null) {
        if (aPullRequest.getMpc().equals(MPC_FAILURE)) {
            return AS4SignalMessageProcessorResult.createFailure("Error in creating the usermessage - mock MPC 'failure' was used!");
        }
        // Empty MPC
        if (aPullRequest.getMpc().equals(MPC_EMPTY)) {
            return AS4SignalMessageProcessorResult.createSuccess();
        }
    }
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aMessageInfo = aSignalMessage.getMessageInfo();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(aMessageInfo.getMessageId());
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    final Ebms3PartyInfo aEbms3PartyInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo("PullPMode", DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, "pullinitiator", CAS4.DEFAULT_RESPONDER_URL, "pullresponder");
    final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aUserMessage.setMessageInfo(aEbms3MessageInfo);
    aUserMessage.setMessageProperties(aEbms3MessageProperties);
    aUserMessage.setPartyInfo(aEbms3PartyInfo);
    aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
    if (aPullRequest != null)
        aUserMessage.setMpc(aPullRequest.getMpc());
    return AS4SignalMessageProcessorResult.createSuccess(null, null, aUserMessage);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3PullRequest(com.helger.phase4.ebms3header.Ebms3PullRequest) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Aggregations

Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)26 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)15 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)14 Ebms3From (com.helger.phase4.ebms3header.Ebms3From)13 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)13 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)13 Nonnull (javax.annotation.Nonnull)13 Test (org.junit.Test)13 ErrorList (com.helger.commons.error.list.ErrorList)12 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)12 PModeLeg (com.helger.phase4.model.pmode.leg.PModeLeg)12 Locale (java.util.Locale)12 Before (org.junit.Before)10 ECryptoAlgorithmSign (com.helger.phase4.crypto.ECryptoAlgorithmSign)9 ECryptoAlgorithmSignDigest (com.helger.phase4.crypto.ECryptoAlgorithmSignDigest)9 Ebms3PartyId (com.helger.phase4.ebms3header.Ebms3PartyId)9 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)8 ETriState (com.helger.commons.state.ETriState)8 ECryptoAlgorithmCrypt (com.helger.phase4.crypto.ECryptoAlgorithmCrypt)8 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)8