Search in sources :

Example 36 with AS4MimeMessage

use of com.helger.phase4.messaging.mime.AS4MimeMessage in project phase4 by phax.

the class UserMessageOneAttachmentTest method testUserMessageOneAttachmentSignedMimeSuccess.

@Test
public void testUserMessageOneAttachmentSignedMimeSuccess() throws 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));
    final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments);
    final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(), m_eSOAPVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault()), aAttachments);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
    assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
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 37 with AS4MimeMessage

use of com.helger.phase4.messaging.mime.AS4MimeMessage in project phase4 by phax.

the class TwoWayMEPTest method testReceiveUserMessageWithMimeAsResponseSuccess.

@Test
public void testReceiveUserMessageWithMimeAsResponseSuccess() throws 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));
    final Document aDoc = modifyUserMessage(m_aPMode.getID(), (String) null, // Alias for encryption
    "ph-as4", createDefaultProperties(), aAttachments, null, null);
    final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
    final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
    assertTrue(sResponse.contains(AS4TestConstants.USERMESSAGE_ASSERTCHECK));
    assertFalse(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
    assertTrue(sResponse.contains(m_aPMode.getLeg2().getSecurity().getX509SignatureAlgorithm().getAlgorithmURI()));
    // Checking if he adds the attachment to the response message, the mock spi
    // just adds the xml that gets sent in the original message and adds it to
    // the response
    assertTrue(sResponse.contains(m_aPMode.getLeg2().getSecurity().getX509EncryptionAlgorithm().getAlgorithmURI()));
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) 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 38 with AS4MimeMessage

use of com.helger.phase4.messaging.mime.AS4MimeMessage in project phase4 by phax.

the class AS4CEFOneWayFuncTest method testAS4_TA15.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile (One-Way/Push MEP). SMSH sends an AS4 User Message with a
 * compressed payload to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The RMSH delivers the message with decompressed payload to the consumer.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA15() 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 AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aDoc, aAttachments);
    sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
// How to check message if it is decompressed hmm?
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) 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 39 with AS4MimeMessage

use of com.helger.phase4.messaging.mime.AS4MimeMessage in project phase4 by phax.

the class AS4CEFOneWayFuncTest method testAS4_TA18.

/**
 * Prerequisite:<br>
 * eSENS_TA13<br>
 * Simulated SMSH sends a signed AS4 User Message with a signed then
 * compressed payload to the RMSH.<br>
 * <br>
 * Predicate: <br>
 * The SMSH receives a WS-Security SOAP Fault.
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testAS4_TA18() throws Exception {
    // signed then compressed
    // Should return an error because the uncompressed attachment was signed and
    // not the compressed one
    ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_SHORTXML_XML)).mimeTypeXML().build(), s_aResMgr));
    final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, aAttachments, s_aResMgr);
    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, aDoc, aAttachments);
    sendMimeMessage(new HttpMimeMessageEntity(aMsg), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : AS4MimeMessage(com.helger.phase4.messaging.mime.AS4MimeMessage) 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 40 with AS4MimeMessage

use of com.helger.phase4.messaging.mime.AS4MimeMessage in project phase4 by phax.

the class UserMessageCompressionTest method testUserMessageWithCompressedAttachmentSuccessful.

@Category(IHolodeckTests.class)
@Test
public void testUserMessageWithCompressedAttachmentSuccessful() throws Exception {
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML)).mimeTypeXML().compressionGZIP().build(), s_aResMgr));
    final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSOAPVersion, MockMessages.createUserMessageNotSigned(m_eSOAPVersion, null, aAttachments).getAsSoapDocument(), aAttachments);
    sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), true, null);
}
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) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

AS4MimeMessage (com.helger.phase4.messaging.mime.AS4MimeMessage)46 HttpMimeMessageEntity (com.helger.phase4.http.HttpMimeMessageEntity)43 Test (org.junit.Test)42 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)39 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)37 Document (org.w3c.dom.Document)22 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)16 Nonnull (javax.annotation.Nonnull)5 IStringMap (com.helger.commons.collection.attr.IStringMap)3 StringMap (com.helger.commons.collection.attr.StringMap)3 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)3 ScopedConfig (com.helger.phase4.ScopedConfig)3 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)3 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)3 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)3 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)3 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)3 HttpProxyServer (org.littleshoot.proxy.HttpProxyServer)3 DefaultHttpProxyServer (org.littleshoot.proxy.impl.DefaultHttpProxyServer)3 Node (org.w3c.dom.Node)3