use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA04.
/**
* 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 message (User Message
* with payload) to the RMSH.<br>
* <br>
* Predicate: <br>
* The RMSH sends a non-repudiation receipt to the SMSH.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA04() throws Exception {
final Document aDoc = createTestSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr);
final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA20.
/**
* Prerequisite:<br>
* eSENS_TA14.<br>
* Simulated SMSH sends a signed AS4 User Message with an encrypted first,
* 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_TA20() throws Exception {
final AS4UserMessage aMsg = MockMessages.createUserMessageNotSigned(m_eSoapVersion, m_aPayload, null);
final Document aDoc = AS4Encryptor.encryptSoapBodyPayload(m_aCryptoFactory, m_eSoapVersion, aMsg.getAsSoapDocument(m_aPayload), true, m_aCryptParams);
final NodeList aNL = aDoc.getElementsByTagName("S12:Body");
final NonBlockingByteArrayOutputStream outputStream = new NonBlockingByteArrayOutputStream();
final Source xmlSource = new DOMSource(aNL.item(0));
final Result outputTarget = new StreamResult(outputStream);
TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);
final byte[] aSrc = outputStream.toByteArray();
// Compression
final NonBlockingByteArrayOutputStream aCompressedOS = new NonBlockingByteArrayOutputStream();
try (final InputStream aIS = new NonBlockingByteArrayInputStream(aSrc);
final OutputStream aOS = EAS4CompressionMode.GZIP.getCompressStream(aCompressedOS)) {
StreamHelper.copyInputStreamToOutputStream(aIS, aOS);
}
aNL.item(0).setTextContent(AS4XMLHelper.serializeXML(aDoc));
sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_FAILED_DECRYPTION.getErrorCode());
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4CEFOneWayFuncTest method testAS4_TA03.
/**
* 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 to the RMSH with parameter MESSAGEPROPERTIES containing: A property
* with attributes "name" and "type" present. A property with only attribute
* "name" present.<br>
* <br>
* Predicate: <br>
* The RMSH returns a non-repudiation receipt within a HTTP response with
* status code 2XX.
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA03() throws Exception {
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(m_aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final Ebms3PartyInfo aEbms3PartyInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, AS4TestConstants.CEF_INITIATOR_ID, CAS4.DEFAULT_RESPONDER_URL, AS4TestConstants.CEF_RESPONDER_ID);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final String sTrackerIdentifier = "trackingidentifier";
aEbms3MessageProperties.addProperty(MessageHelperMethods.createEbms3Property(sTrackerIdentifier, "tracker"));
// Can not do a Property without Value (type) since type does not exist
// final Ebms3Property aPropOnlyName = new Ebms3Property ();
// aPropOnlyName.setName ("OnlyName");
// aEbms3MessageProperties.addProperty (aPropOnlyName);
final AS4UserMessage aMsg = AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aMsg.getAsSoapDocument(m_aPayload), m_eSoapVersion, aMsg.getMessagingID(), null, s_aResMgr, false, AS4SigningParams.createDefault());
final NodeList aNL = aSignedDoc.getElementsByTagName("eb:MessageProperties");
assertEquals(aNL.item(0).getLastChild().getAttributes().getNamedItem("name").getTextContent(), sTrackerIdentifier);
final String sResponse = sendPlainMessage(new HttpXMLEntity(aSignedDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains(AS4TestConstants.NON_REPUDIATION_INFORMATION));
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4CEFTwoWayFuncTest method testAS4_TA01.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: Two-Way/Push-and-Push MEP. SMSH sends an AS4 User Message
* (M1) associated to a specific conversation through variable (element)
* CONVERSATIONIDM1 (set by the producer). The consumer replies to the message
* M1.<br>
* <br>
* Predicate: <br>
* The RMSH sends back a User Message (M2) with element CONVERSATIONIDM2 equal
* to ConversationIdM1 (set by the consumer).
*
* @throws Exception
* In case of error
*/
@Test
public void testAS4_TA01() throws Exception {
// Needs to be cleared so we can exactly see if two messages are contained
// in the duplicate manager
final IAS4DuplicateManager aIncomingDuplicateMgr = MetaAS4Manager.getIncomingDuplicateMgr();
aIncomingDuplicateMgr.clearCache();
assertTrue(aIncomingDuplicateMgr.isEmpty());
final Document aDoc = testSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr);
final String sResponse = sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
// Avoid stopping server to receive async response
LOGGER.info("Waiting for 1 second");
ThreadHelper.sleepSeconds(1);
// Step one assertion for the sync part
assertTrue(sResponse.contains(AS4TestConstants.RECEIPT_ASSERTCHECK));
final NodeList aNL = aDoc.getElementsByTagName("eb:MessageId");
// Should only be called once
final String aID = aNL.item(0).getTextContent();
assertNotNull(aIncomingDuplicateMgr.getItemOfMessageID(aID));
assertEquals(2, aIncomingDuplicateMgr.getAll().size());
}
use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.
the class AS4eSENSCEFTwoWayFuncTest method testEsens_TA02_PushPush.
/**
* Prerequisite:<br>
* SMSH and RMSH are configured to exchange AS4 messages according to the
* e-SENS profile: Two-Way/Push-and-Push MEP. SMSH sends an AS4 User Message
* (M1 with ID MessageId) that requires a consumer response to the RMSH. <br>
* <br>
* Predicate: <br>
* The RMSH sends back a User Message (M2) with element REFTOMESSAGEID set to
* MESSAGEID (of M1).
*
* @throws Exception
* In case of error
*/
@Test
public void testEsens_TA02_PushPush() throws Exception {
final Document aDoc = testSignedUserMessage(m_eSoapVersion, m_aPayload, null, s_aResMgr);
final NodeList nList = aDoc.getElementsByTagName("eb:MessageId");
// Should only be called once
final String aID = nList.item(0).getTextContent();
final String sResponse = sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), true, null);
assertTrue(sResponse.contains("eb:RefToMessageId"));
assertTrue(sResponse.contains(aID));
// Wait for async response to come in
// Otherwise indeterministic errors
ThreadHelper.sleepSeconds(2);
}
Aggregations