Search in sources :

Example 61 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class Ebms3MessagingTest method testUserMessageNoMessageProperties.

@Test
public void testUserMessageNoMessageProperties() throws Exception {
    final Ebms3Messaging aEbms3Messaging = new Ebms3Messaging();
    final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
    // Message Info
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final String sPModeID = SOAP_12_PARTY_ID + "-" + SOAP_12_PARTY_ID;
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    final Ebms3PartyInfo aEbms3PartyInfo = new Ebms3PartyInfo();
    // From => Sender
    final Ebms3From aEbms3From = new Ebms3From();
    aEbms3From.setRole(CAS4.DEFAULT_INITIATOR_URL);
    aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
    aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
    aEbms3PartyInfo.setFrom(aEbms3From);
    // To => Receiver
    final Ebms3To aEbms3To = new Ebms3To();
    aEbms3To.setRole(CAS4.DEFAULT_RESPONDER_URL);
    aEbms3To.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
    aEbms3PartyInfo.setTo(aEbms3To);
    aEbms3UserMessage.setPartyInfo(aEbms3PartyInfo);
    aEbms3UserMessage.setPayloadInfo(aEbms3PayloadInfo);
    aEbms3UserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aEbms3UserMessage.setMessageProperties(MessageHelperMethods.createEbms3MessageProperties(null));
    aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
    aEbms3Messaging.addUserMessage(aEbms3UserMessage);
    final HttpEntity aEntity = new HttpXMLEntity(_getMessagingAsSoapDocument(aEbms3Messaging), SOAP_VERSION.getMimeType());
    sendPlainMessage(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) HttpEntity(org.apache.http.HttpEntity) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 62 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class ReceiptMessageTest method testReceiptReceivedFromUserMessageWithWSSecurity.

@Test
public void testReceiptReceivedFromUserMessageWithWSSecurity() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final Document aDoc = MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, null, s_aResMgr);
    final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
Also used : Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 63 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageFailureForgeryTest method testUserMessageWithPayloadInfoOnly.

@Test
public void testUserMessageWithPayloadInfoOnly() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final Document aDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, aPayload, null).getAsSoapDocument(aPayload);
    // Delete the added Payload in the soap body to confirm right behaviour when
    // the payload is missing
    final NodeList nList = aDoc.getElementsByTagName(m_eSoapVersion.getNamespacePrefix() + ":Body");
    for (int i = 0; i < nList.getLength(); i++) {
        final Node nNode = nList.item(i);
        final Element aElement = (Element) nNode;
        XMLHelper.removeAllChildElements(aElement);
    }
    sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 64 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageFailureForgeryTest method testUserMessageWithNoPartyIDShouldFail.

@Test
public void testUserMessageWithNoPartyIDShouldFail() throws Exception {
    final DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    // never forget this!
    domFactory.setNamespaceAware(true);
    final DocumentBuilder builder = domFactory.newDocumentBuilder();
    final Document aDoc = builder.parse(new ClassPathResource("testfiles/UserMessageNoPartyID.xml").getInputStream());
    sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_INVALID_HEADER.getErrorCode());
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Example 65 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageFailureForgeryTest method testForceFailureFromSPI.

@Test
public void testForceFailureFromSPI() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final Document aDoc = MockMessages.testUserMessageNotSignedNotPModeConform(m_eSoapVersion, aPayload, null);
    sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_OTHER.getErrorCode());
}
Also used : Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Aggregations

HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)65 Document (org.w3c.dom.Document)61 Test (org.junit.Test)60 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)30 Node (org.w3c.dom.Node)18 HttpEntity (org.apache.http.HttpEntity)16 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)10 NodeList (org.w3c.dom.NodeList)10 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)9 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)8 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)7 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)7 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)7 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)7 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)5 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)5 IAS4CryptoFactory (com.helger.phase4.crypto.IAS4CryptoFactory)4