Search in sources :

Example 1 with WSS4JAttachment

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

the class AS4CEFOneWayFuncTest method testAS4_TA11.

/**
 * 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 xml (UTF-8) payload and metadata information including payload
 * character set info.<br>
 * <br>
 * Predicate: <br>
 * The SMSH generates an AS4 message with the property "CharacterSet" present
 * and set to the value "UTF-8".
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA11() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    final WSS4JAttachment aAttachment = WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr);
    aAttachment.setCharset(StandardCharsets.UTF_8);
    aAttachments.add(aAttachment);
    final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
    NodeList aNL = aDoc.getElementsByTagName("eb:PartProperties");
    aNL = aNL.item(0).getChildNodes();
    boolean bHasCharset = false;
    for (int i = 0; i < aNL.getLength(); i++) {
        if (aNL.item(i).getAttributes().getNamedItem("name").getTextContent().equals("CharacterSet")) {
            if (aNL.item(i).getTextContent().equals("UTF-8"))
                bHasCharset = true;
        }
    }
    assertTrue(bHasCharset);
}
Also used : NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 2 with WSS4JAttachment

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

the class AS4CEFOneWayFuncTest method testAS4_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 with metadata
 * information and XML payload to the SMSH.<br>
 * <br>
 * Predicate: <br>
 * The SMSH generates an AS4 message with a gzip compressed payload.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA06() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeType(CMimeType.APPLICATION_XML).compression(EAS4CompressionMode.GZIP).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 3 with WSS4JAttachment

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

the class AS4CEFOneWayFuncTest method testAS4_TA19.

/**
 * Prerequisite:<br>
 * eSENS_TA14.<br>
 * The SMSH is simulated to send a compressed then encrypted AS4 message to
 * the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The RMSH sends back an AS4 non-repudiation receipt.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA19() 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 AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments);
    final AS4MimeMessage aMimeMsg = AS4Encryptor.encryptMimeMessage(m_eSoapVersion, aMsg.getAsSoapDocument(), aAttachments, m_aCryptoFactory, false, s_aResMgr, m_aCryptParams);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) 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)

Example 4 with WSS4JAttachment

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

the class AS4CEFOneWayFuncTest method testAS4_TA21.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile (One-Way/Push MEP). The SMSH sends an AS4 message with a
 * compressed then encrypted and signed payload to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The RMSH sends back an AS4 non-repudiation receipt.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA21() 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 AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments);
    final Document aDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(null), m_eSoapVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
    final AS4MimeMessage aMimeMsg = AS4Encryptor.encryptMimeMessage(m_eSoapVersion, aDoc, aAttachments, m_aCryptoFactory, false, s_aResMgr, m_aCryptParams);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) 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)

Example 5 with WSS4JAttachment

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

the class AS4CEFOneWayFuncTest method testAS4_TA07.

/**
 * 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 payload to the SMSH.<br>
 * <br>
 * Predicate: <br>
 * In the AS4 message generated by the SMSH, a property element with name
 * "CompressionType" and value set to "application/gzip" is present.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA07() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeType(CMimeType.APPLICATION_XML).compression(EAS4CompressionMode.GZIP).build(), s_aResMgr));
    final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
    final NodeList aNL = aDoc.getElementsByTagName("eb:PartProperties");
    assertNotNull(aNL);
    assertEquals(1, aNL.getLength());
    assertEquals("CompressionType", aNL.item(0).getLastChild().getAttributes().getNamedItem("name").getTextContent());
    assertEquals("application/gzip", aNL.item(0).getLastChild().getTextContent());
}
Also used : NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) 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