Search in sources :

Example 31 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class CEFProfileTest method testUserMessageOriginalSenderButNoFinalRecipient.

@Test
public void testUserMessageOriginalSenderButNoFinalRecipient() throws Exception {
    final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    aEbms3Properties.removeIf(x -> x.getName().equals(CAS4.FINAL_RECIPIENT));
    assertEquals(1, aEbms3Properties.size());
    aEbms3Properties.add(_createRandomProperty());
    aEbms3MessageProperties.setProperty(aEbms3Properties);
    m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
    final Document aDoc = AS4UserMessage.create(m_eSoapVersion, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, "'finalRecipient' property is empty or not existant but mandatory");
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 32 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class PModeCheckTest method testPModeLegNullReject.

@Test
public void testPModeLegNullReject() throws Exception {
    final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
    aPMode.setLeg1(null);
    final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
    // Needed since different ids set in message and pmode otherwise
    m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(aPMode.getInitiatorID() + "-" + aPMode.getResponderID(), DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
    try {
        for (final String sPModeID : aPModeMgr.getAllIDs()) {
            aPModeMgr.deletePMode(sPModeID);
        }
        assertTrue(aPModeMgr.getAllIDs().isEmpty());
        aPModeMgr.createOrUpdatePMode(aPMode);
        final AS4UserMessage aMsg = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true);
        final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(m_aPayload), SOAP_VERSION, aMsg.getMessagingID(), null, s_aResMgr, false, AS4SigningParams.createDefault());
        sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
    } finally {
        // The MockPModeGenerator generates automatically a PMode, we need
        // too delete it after we are done with the test
        aPModeMgr.deletePMode(aPMode.getID());
    }
}
Also used : IPModeManager(com.helger.phase4.model.pmode.IPModeManager) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) PMode(com.helger.phase4.model.pmode.PMode) Test(org.junit.Test)

Example 33 with CAS4

use of com.helger.phase4.CAS4 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 CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class TwoWayAsyncPushPullTest method before.

@Before
public void before() {
    final PMode aPMode = CEFPMode.createCEFPMode(AS4TestConstants.TEST_INITIATOR, AS4TestConstants.TEST_RESPONDER, MockJettySetup.getServerAddressFromSettings(), (i, r) -> "pmode" + GlobalIDFactory.getNewPersistentLongID(), false);
    // Setting second leg to the same as first
    final PModeLeg aLeg2 = aPMode.getLeg1();
    // ESENS PMode is One Way on default settings need to change to two way
    m_aPMode = new PMode(aPMode.getID(), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), aPMode.getAgreement(), EMEP.TWO_WAY, EMEPBinding.PUSH_PULL, aPMode.getLeg1(), aLeg2, aPMode.getPayloadService(), aPMode.getReceptionAwareness());
    // Delete old PMode since it is getting created in the ESENS createPMode
    MetaAS4Manager.getPModeMgr().deletePMode(aPMode.getID());
    MetaAS4Manager.getPModeMgr().createOrUpdatePMode(m_aPMode);
}
Also used : PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) PMode(com.helger.phase4.model.pmode.PMode) CEFPMode(com.helger.phase4.profile.cef.CEFPMode) Before(org.junit.Before)

Example 35 with CAS4

use of com.helger.phase4.CAS4 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)

Aggregations

Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)20 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)20 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)18 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)18 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)18 Nonnull (javax.annotation.Nonnull)16 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)15 Test (org.junit.Test)14 Document (org.w3c.dom.Document)14 HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)12 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)12 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)11 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)10 PMode (com.helger.phase4.model.pmode.PMode)9 Node (org.w3c.dom.Node)8 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)5 PModeLeg (com.helger.phase4.model.pmode.leg.PModeLeg)5 Before (org.junit.Before)5 Ebms3From (com.helger.phase4.ebms3header.Ebms3From)4 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)4