Search in sources :

Example 46 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class AS4eSENSCEFOneWayFuncTest method testEsens_TA03.

/**
 * Prerequisite:<br>
 * SMSH and RMSH are configured to exchange AS4 messages according to the
 * e-SENS profile: One-Way/Push MEP. SMSH and RMSH exchange several AS4 User
 * Messages.<br>
 * <br>
 * Predicate: <br>
 * Each exchanged AS4 message contains single ORIGIN and DESTINATION elements.
 * <br>
 * Goal: "Both UserMessage/PartyInfo/From and UserMessage/PartyInfo/To must
 * not include more than one PartyId element"
 *
 * @throws Exception
 *         In case of error
 */
@Test
public void testEsens_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);
    aEbms3PartyInfo.getTo().addPartyId(MessageHelperMethods.createEbms3PartyId("Second ID"));
    // Check if we added a second party id
    assertTrue(aEbms3PartyInfo.getTo().getPartyId().size() == 2);
    final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
    final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
    aUserMessage.setPartyInfo(aEbms3PartyInfo);
    aUserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aUserMessage.setMessageProperties(aEbms3MessageProperties);
    aUserMessage.setPayloadInfo(aEbms3PayloadInfo);
    aUserMessage.setMessageInfo(aEbms3MessageInfo);
    final Document aDoc = new AS4UserMessage(ESoapVersion.AS4_DEFAULT, aUserMessage).getAsSoapDocument(m_aPayload);
    sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) AS4UserMessage(com.helger.phase4.messaging.domain.AS4UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 47 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadSignedSuccess.

@Test
public void testUserMessageSOAPBodyPayloadSignedSuccess() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    final Document aDoc = MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, aAttachments, 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));
    assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
    assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
Also used : Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 48 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class UserMessageSoapBodyPayloadTest method testUserMessageSOAPBodyPayloadSignedEncryptedSuccess.

@Test
public void testUserMessageSOAPBodyPayloadSignedEncryptedSuccess() throws Exception {
    final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
    final ICommonsList<WSS4JAttachment> aAttachments = new CommonsArrayList<>();
    Document aDoc = MockMessages.createUserMessageSigned(m_eSoapVersion, aPayload, aAttachments, s_aResMgr);
    aDoc = AS4Encryptor.encryptSoapBodyPayload(m_aCryptoFactory, m_eSoapVersion, aDoc, false, m_aCryptParams);
    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));
    assertTrue(sResponse.contains(ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI()));
    assertTrue(sResponse.contains(ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI()));
}
Also used : Node(org.w3c.dom.Node) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Test(org.junit.Test)

Example 49 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class CEFProfileTest method testUserMessageFinalRecipientButNoOriginalSender.

@Test
public void testUserMessageFinalRecipientButNoOriginalSender() throws Exception {
    final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    aEbms3Properties.removeIf(x -> x.getName().equals(CAS4.ORIGINAL_SENDER));
    assertEquals(1, aEbms3Properties.size());
    aEbms3Properties.add(_createRandomProperty());
    aEbms3MessageProperties.setProperty(aEbms3Properties);
    m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
    final Document aDoc = AS4UserMessage.create(m_eSoapVersion, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, "'originalSender' property is empty or not existant but mandatory");
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Example 50 with HttpXMLEntity

use of com.helger.phase4.http.HttpXMLEntity in project phase4 by phax.

the class CEFProfileTest method testUserMessageOriginalSenderButNoFinalRecipient.

@Test
public void testUserMessageOriginalSenderButNoFinalRecipient() throws Exception {
    final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    aEbms3Properties.removeIf(x -> x.getName().equals(CAS4.FINAL_RECIPIENT));
    assertEquals(1, aEbms3Properties.size());
    aEbms3Properties.add(_createRandomProperty());
    aEbms3MessageProperties.setProperty(aEbms3Properties);
    m_aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
    final Document aDoc = AS4UserMessage.create(m_eSoapVersion, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
    sendPlainMessageAndWait(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, "'finalRecipient' property is empty or not existant but mandatory");
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) Document(org.w3c.dom.Document) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Test(org.junit.Test)

Aggregations

HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)65 Document (org.w3c.dom.Document)61 Test (org.junit.Test)60 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)30 Node (org.w3c.dom.Node)18 HttpEntity (org.apache.http.HttpEntity)16 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)10 NodeList (org.w3c.dom.NodeList)10 Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)9 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)8 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)7 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)7 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)7 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)7 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)6 DocumentBuilder (javax.xml.parsers.DocumentBuilder)6 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)6 WSS4JAttachment (com.helger.phase4.attachment.WSS4JAttachment)5 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)5 IAS4CryptoFactory (com.helger.phase4.crypto.IAS4CryptoFactory)4