use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class UserMessageOneAttachmentTest method testUserMessageMimeSignedEncryptedSuccess.
@Test
public void testUserMessageMimeSignedEncryptedSuccess() 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 Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(), m_eSOAPVersion, aMsg.getMessagingID(), aAttachments, s_aResMgr, false, AS4SigningParams.createDefault());
final AS4MimeMessage aMimeMsg = AS4Encryptor.encryptMimeMessage(m_eSOAPVersion, aSignedDoc, 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(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadSignedMimeSuccess.
@Test
public void testUserMessageSOAPBodyPayloadSignedMimeSuccess() throws Exception {
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, null, s_aResMgr), null);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class TwoWayMEPTest method testReceiveUserMessageWithMimeAsResponseSuccessWithoutEncryption.
@Test
public void testReceiveUserMessageWithMimeAsResponseSuccessWithoutEncryption() throws Exception {
m_aPMode.getLeg2().getSecurity().setX509EncryptionAlgorithm(null);
MetaAS4Manager.getPModeMgr().createOrUpdatePMode(m_aPMode);
final 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 = modifyUserMessage(m_aPMode.getID(), null, null, 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("<dummy>This is a test XML</dummy>"));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA28.
/**
* Note: Only when using SBDH<br>
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile (One-Way/Push MEP). Producer submits two payloads, first
* being an SBDH document, second being an actual payload (non-XML payload).
* SMSH sends an AS4 User Message to the RMSH.<br>
* <br>
* Predicate: <br>
* Message has two additional MIME parts. The first mime part is the SBDH
* document and the second is the actual payload
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA28() 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));
aAttachments.add(WSS4JAttachment.createOutgoingFileAttachment(Phase4OutgoingAttachment.builder().data(ClassPathResource.getAsFile(AS4TestConstants.ATTACHMENT_TEST_IMG_JPG)).mimeType(CMimeType.IMAGE_JPG).build(), s_aResMgr));
final AS4MimeMessage aMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, MockMessages.createUserMessageNotSigned(m_eSoapVersion, null, aAttachments).getAsSoapDocument(), aAttachments);
final String sResponse = sendMimeMessage(new HttpMimeMessageEntity(aMsg), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
}
use of com.helger.phase4.http.HttpMimeMessageEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA13.
/**
* 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 send an AS4 User
* Message with compressed but damaged payloads. The SMSH sends the AS4 User
* Message to the RMSH.<br>
* <br>
* Predicate: <br>
* The RMSH sends back a synchronous error response with error code "Code =
* EBMS:0303, Short Description = DecompressionFailure, Severity = Failure,
* Category = Communication".
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA13() 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 AS4UserMessage aMsg = createTestUserMessageSoapNotSigned(m_aPayload, aAttachments);
// Damaged payload: txt file
aAttachments.get(0).setSourceStreamProvider(new ClassPathResource("attachment/CompressedPayload.txt"));
final AS4MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage(m_eSoapVersion, aMsg.getAsSoapDocument(m_aPayload), aAttachments);
sendMimeMessage(new HttpMimeMessageEntity(aMimeMsg), false, EEbmsError.EBMS_DECOMPRESSION_FAILURE.getErrorCode());
}
Aggregations