use of com.helger.phase4.CAS4 in project phase4 by phax.
the class Ebms3MessagingTest method testSendReceipt.
@Test
public void testSendReceipt() throws Exception {
// Fake an incoming message
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final String sPModeID = SOAP_12_PARTY_ID + "-" + SOAP_12_PARTY_ID;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, SOAP_12_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, SOAP_12_PARTY_ID);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
aEbms3UserMessage.setPartyInfo(aEbms3PartyInfo);
aEbms3UserMessage.setPayloadInfo(aEbms3PayloadInfo);
aEbms3UserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
// Now send receipt
final Document aDoc = MockMessages.createReceiptMessage(ESoapVersion.AS4_DEFAULT, aEbms3UserMessage, null).getAsSoapDocument();
// We've got our response
sendPlainMessage(new HttpXMLEntity(aDoc, SOAP_VERSION.getMimeType()), true, null);
}
use of com.helger.phase4.CAS4 in project phase4 by phax.
the class Ebms3MessagingTest method testUserMessageWithTooManyPartyIds.
@Test
public void testUserMessageWithTooManyPartyIds() throws Exception {
final Ebms3Messaging aEbms3Messaging = new Ebms3Messaging();
final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
// Message Info
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final String sPModeID = SOAP_12_PARTY_ID + "-" + SOAP_12_PARTY_ID;
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, null);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
final Ebms3PartyInfo aEbms3PartyInfo = new Ebms3PartyInfo();
// From => Sender
final Ebms3From aEbms3From = new Ebms3From();
aEbms3From.setRole(CAS4.DEFAULT_INITIATOR_URL);
aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3From.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3PartyInfo.setFrom(aEbms3From);
// To => Receiver
final Ebms3To aEbms3To = new Ebms3To();
aEbms3To.setRole(CAS4.DEFAULT_RESPONDER_URL);
aEbms3To.addPartyId(MessageHelperMethods.createEbms3PartyId(SOAP_12_PARTY_ID));
aEbms3PartyInfo.setTo(aEbms3To);
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
aEbms3UserMessage.setPartyInfo(aEbms3PartyInfo);
aEbms3UserMessage.setPayloadInfo(aEbms3PayloadInfo);
aEbms3UserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
aEbms3UserMessage.setMessageProperties(aEbms3MessageProperties);
aEbms3UserMessage.setMessageInfo(MessageHelperMethods.createEbms3MessageInfo());
aEbms3Messaging.addUserMessage(aEbms3UserMessage);
final HttpEntity aEntity = new HttpXMLEntity(_getMessagingAsSoapDocument(aEbms3Messaging), SOAP_VERSION.getMimeType());
sendPlainMessage(aEntity, false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.CAS4 in project phase4 by phax.
the class MockMessages method createUserMessageNotSigned.
@Nonnull
public static AS4UserMessage createUserMessageNotSigned(@Nonnull final ESoapVersion eSOAPVersion, @Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aAttachments) {
// Add properties
final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
final String sPModeID;
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, aAttachments);
final Ebms3CollaborationInfo aEbms3CollaborationInfo;
final Ebms3PartyInfo aEbms3PartyInfo;
if (eSOAPVersion.equals(ESoapVersion.SOAP_11)) {
sPModeID = SOAP_11_PARTY_ID + "-" + SOAP_11_PARTY_ID;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, SOAP_11_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, SOAP_11_PARTY_ID);
} else {
sPModeID = SOAP_12_PARTY_ID + "-" + SOAP_12_PARTY_ID;
aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(sPModeID, DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, AS4TestConstants.TEST_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
aEbms3PartyInfo = MessageHelperMethods.createEbms3PartyInfo(CAS4.DEFAULT_INITIATOR_URL, SOAP_12_PARTY_ID, CAS4.DEFAULT_RESPONDER_URL, SOAP_12_PARTY_ID);
}
final Ebms3MessageProperties aEbms3MessageProperties = MessageHelperMethods.createEbms3MessageProperties(aEbms3Properties);
return AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, eSOAPVersion).setMustUnderstand(true);
}
use of com.helger.phase4.CAS4 in project phase4 by phax.
the class UserMessageFailureForgeryTest method testUserMessageWithBodyPayloadOnlyNoInfo.
@Test
public void testUserMessageWithBodyPayloadOnlyNoInfo() throws Exception {
final Node aPayload = DOMReader.readXMLDOM(new ClassPathResource(AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final Document aDoc = MockMessages.createUserMessageNotSigned(m_eSoapVersion, aPayload, null).getAsSoapDocument(aPayload);
// Delete the added Payload in the soap body to confirm right behaviour when
// the payload is missing
Element aNext = XMLHelper.getFirstChildElementOfName(aDoc, "Envelope");
aNext = XMLHelper.getFirstChildElementOfName(aNext, "Header");
aNext = XMLHelper.getFirstChildElementOfName(aNext, CAS4.EBMS_NS, "Messaging");
aNext = XMLHelper.getFirstChildElementOfName(aNext, CAS4.EBMS_NS, AS4TestConstants.USERMESSAGE_ASSERTCHECK);
aNext = XMLHelper.getFirstChildElementOfName(aNext, CAS4.EBMS_NS, "PayloadInfo");
aNext.getParentNode().removeChild(aNext);
sendPlainMessage(new HttpXMLEntity(aDoc, m_eSoapVersion.getMimeType()), false, EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode());
}
use of com.helger.phase4.CAS4 in project phase4 by phax.
the class PModeCheckTest method testPModeWrongMPC.
@Test
public void testPModeWrongMPC() throws Exception {
final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
aPMode.getLeg1().getBusinessInfo().setMPCID("wrongmpc-id");
final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
try {
for (final String sPModeID : aPModeMgr.getAllIDs()) {
aPModeMgr.deletePMode(sPModeID);
}
assertTrue(aPModeMgr.getAllIDs().isEmpty());
aPModeMgr.createOrUpdatePMode(aPMode);
// Needed since different ids set in message and pmode otherwise
m_aEbms3UserMessage.setCollaborationInfo(MessageHelperMethods.createEbms3CollaborationInfo(aPMode.getInitiatorID() + "-" + aPMode.getResponderID(), DEFAULT_AGREEMENT, null, CAS4.DEFAULT_SERVICE_URL, CAS4.DEFAULT_ACTION_URL, AS4TestConstants.TEST_CONVERSATION_ID));
final Document aSignedDoc = AS4UserMessage.create(SOAP_VERSION, m_aEbms3UserMessage).setMustUnderstand(true).getAsSoapDocument(m_aPayload);
sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
} finally {
// The MockPModeGenerator generates automatically a PMode, we need
// too delete it after we are done with the test
MetaAS4Manager.getPModeMgr().deletePMode(aPMode.getID());
aPModeMgr.deletePMode(aPMode.getID());
}
}
Aggregations