use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class UserMessageFailureForgeryTest method testUserMessageWithMoreAttachmentsThenPartInfo.
@Test
public void testUserMessageWithMoreAttachmentsThenPartInfo() 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 Document aSoapDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments).getAsSoapDocument();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).build(), s_aResMgr));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG2_JPG)).mimeType(CMimeType.IMAGE_JPG).build(), s_aResMgr));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aSoapDoc, aAttachments);
aMimeMsg.saveChanges();
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_EXTERNAL_PAYLOAD_ERROR.getErrorCode());
}
use of com.helger.phase4.attachment.WSS4JAttachment 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());
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class UserMessageFailureForgeryTest method testUserMessageWithAttachmentPartInfoOnly.
@Test
public void testUserMessageWithAttachmentPartInfoOnly() throws Exception {
final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_XML_GZ)).mimeTypeXML().build(), s_aResMgr));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments).getAsSoapDocument(), aAttachments);
final SoapMimeMultipart aMultipart = (SoapMimeMultipart) aMimeMsg.getContent();
// Since we want to remove the attachment
aMultipart.removeBodyPart(1);
aMimeMsg.saveChanges();
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_EXTERNAL_PAYLOAD_ERROR.getErrorCode());
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class UserMessageManyAttachmentTest method testUserMessageManyAttachmentsEncryptedMimeSuccess.
@Test
public void testUserMessageManyAttachmentsEncryptedMimeSuccess() throws WSSecurityException, 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));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).build(), s_aResMgr));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML2_XML)).mimeTypeXML().build(), s_aResMgr));
final AS4MimeMessage aMimeMsg = AS4Encryptor.encryptMimeMessage(m_eSOAPVersion, MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments).getAsSoapDocument(), aAttachments, m_aCryptoFactory, false, s_aResMgr, m_aCryptParams);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.
the class UserMessageManyAttachmentTest method testUserMessageManyAttachmentsMimeSuccess.
@Test
public void testUserMessageManyAttachmentsMimeSuccess() throws IOException, MessagingException {
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));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).build(), s_aResMgr));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML2_XML)).mimeTypeXML().build(), s_aResMgr));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments).getAsSoapDocument(), aAttachments);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
Aggregations