Search in sources :

Example 6 with WSS4JAttachment

use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.

the class AS4CEFOneWayFuncTest method testAS4_TA09.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile (One-Way/Push MEP). The SMSH is simulated to send an AS4
 * message without property "MimeType" present to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The RMSH sends a synchronous ebMS error response.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA09() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
    final NodeList aNL = aDoc.getElementsByTagName("eb:PartProperties");
    aNL.item(0).removeChild(aNL.item(0).getFirstChild());
    final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
    sendMimeMessage(new HttpMimeMessageEntity(aMsg), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 7 with WSS4JAttachment

use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.

the class AS4eSENSCEFOneWayFuncTest method testEsens_TA06.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile. (One-Way/Push MEP) Producer submits a message to the SMSH
 * with metadata information, an XML payload (leading business document) and
 * other payloads (XML and non XML). SMSH generates an AS4 message to send to
 * the RMSH.<br>
 * <br>
 * Predicate: <br>
 * In the AS4 message created by the SMSH, the compressed payloads are carried
 * in separate MIME parts and the soap body is empty.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testEsens_TA06() throws Exception {
    // same stuff as TA05 only one step further
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).compressionGZIP().build(), s_aResMgr));
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML2_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr), aAttachments);
    final Multipart aMultipart = (Multipart) aMsg.getContent();
    // 3 attachments + 1 Main/Bodypart
    assertTrue(aMultipart.getCount() == 4);
}
Also used : Multipart(javax.mail.Multipart) AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 8 with WSS4JAttachment

use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.

the class AS4eSENSCEFOneWayFuncTest method testEsens_TA05.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile. (One-Way/Push MEP)Producer submits a message with metadata
 * information and an XML payload to the SMSH. SMSH generates an AS4 message
 * to send to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * In the AS4 message created by the SMSH, the compressed payload is carried
 * in a separate MIME part and the soap body is empty. <br>
 * <br>
 * Goal:"Due to the mandatory use of the AS4 compression feature in this
 * profile (see section 2.2.3.3), XML payloads MAY be converted to binary
 * data, which is carried in separate MIME parts and not in the SOAP Body.
 * Compliant AS4 message always have an empty SOAP Body. "
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testEsens_TA05() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr), aAttachments);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 9 with WSS4JAttachment

use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.

the class AS4eSENSCEFOneWayFuncTest method testEsens_TA07.

/**
 * Prerequisite:<br>
 * eSENS_TA06<br>
 * SMSH sends an AS4 message to the RMSH. <br>
 * <br>
 * Predicate: <br>
 * The RMSH successfully processes the AS4 message and sends a non-repudiation
 * receipt to the SMSH.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testEsens_TA07() throws Exception {
    // same stuff as TA05 only one step further
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).compressionGZIP().build(), s_aResMgr));
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML2_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr), aAttachments);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 10 with WSS4JAttachment

use of com.helger.phase4.attachment.WSS4JAttachment in project phase4 by phax.

the class AS4eSENSCEFOneWayFuncTest method testEsens_TA04.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile. (One-Way/Push MEP) SMSH is simulated to produce
 * uncompressed payloads. The SMSH sends the AS4 message to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The RMSH returns a non-repudiation receipt and delivers the message to the
 * consumer. <br>
 * <br>
 * k Goal: Do not throw an error if a uncompressed payload gets sent, also
 * check if compressed payloads are acceptable aswell.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testEsens_TA04() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().build(), s_aResMgr));
    final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr), aAttachments);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) HttpMimeMessageEntity(com.helger.phase4.http.HttpMimeMessageEntity) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Aggregations

WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)57 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)56 Test (org.junit.Test)44 AS4MimeMessage (com.helger.phase4.messaging.mime.AS4MimeMessage)39 HttpMimeMessageEntity (com.helger.phase4.http.HttpMimeMessageEntity)36 Document (org.w3c.dom.Document)36 Nonnull (javax.annotation.Nonnull)29 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)23 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)15 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)13 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)13 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)13 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)12 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)11 IOException (java.io.IOException)11 Node (org.w3c.dom.Node)11 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)9 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)7 Phase4Exception (com.helger.phase4.util.Phase4Exception)7 MessagingException (javax.mail.MessagingException)7