Search in sources :

Example 51 with AS4UserMessage

use of com.helger.phase4.messaging.domain.AS4UserMessage in project phase4 by phax.

the class UserMessageFailureForgeryTest method testWrongAttachmentIDShouldFail.

@Test
public void testWrongAttachmentIDShouldFail() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_XML_GZ)).mimeType(CMimeType.APPLICATION_GZIP).build(), s_aResMgr));
    final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments);
    final Document aDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(), m_eSoapVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
    final NodeList nList = aDoc.getElementsByTagName("eb:PartInfo");
    for (int i = 0; i < nList.getLength(); i++) {
        final Node nNode = nList.item(i);
        final Element aElement = (Element) nNode;
        if (aElement.hasAttribute("href"))
            aElement.setAttribute("href", MessageHelperMethods.PREFIX_CID + "invalid" + i);
    }
    final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
    sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Aggregations

AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)45 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)20 Test (org.junit.Test)19 Document (org.w3c.dom.Document)19 AS4MimeMessage (com.helger.phase4.messaging.mime.AS4MimeMessage)17 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)16 IAS4ClientBuildMessageCallback (com.helger.phase4.client.IAS4ClientBuildMessageCallback)16 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)16 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)16 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)16 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)16 HttpMimeMessageEntity (com.helger.phase4.http.HttpMimeMessageEntity)16 AbstractAS4Message (com.helger.phase4.messaging.domain.AbstractAS4Message)16 File (java.io.File)16 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)15 AS4IncomingDumperFileBased (com.helger.phase4.dump.AS4IncomingDumperFileBased)15 AS4OutgoingDumperFileBased (com.helger.phase4.dump.AS4OutgoingDumperFileBased)15 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)15 ESimpleUserMessageSendResult (com.helger.phase4.sender.AbstractAS4UserMessageBuilder.ESimpleUserMessageSendResult)15 Nonnull (javax.annotation.Nonnull)15