use of com.helger.phase4.ebms3header.Ebms3PartyInfo 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.ebms3header.Ebms3PartyInfo 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.ebms3header.Ebms3PartyInfo in project phase4 by phax.
the class AS4RequestHandler method _createReversedUserMessage.
/**
* Takes an UserMessage and switches properties to reverse the direction. So
* previously it was C1 => C4, now its C4 => C1 Also adds attachments if there
* are some that should be added.
*
* @param eSoapVersion
* of the message
* @param sResponseMessageID
* The AS4 message ID of the response
* @param aUserMessage
* the message that should be reversed
* @param aResponseAttachments
* attachment that should be added
* @return the reversed usermessage in document form
*/
@Nonnull
private static AS4UserMessage _createReversedUserMessage(@Nonnull final ESoapVersion eSoapVersion, @Nonnull @Nonempty final String sResponseMessageID, @Nonnull final Ebms3UserMessage aUserMessage, @Nonnull final ICommonsList<WSS4JAttachment> aResponseAttachments) {
// Use current time
final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo(sResponseMessageID, aUserMessage.getMessageInfo().getMessageId());
final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(false, aResponseAttachments);
// Invert from and to role from original user message
final Ebms3PartyInfo aEbms3PartyInfo = MessageHelperMethods.createEbms3ReversePartyInfo(aUserMessage.getPartyInfo());
// Should be exactly the same as incoming message
final Ebms3CollaborationInfo aEbms3CollaborationInfo = aUserMessage.getCollaborationInfo();
// Need to switch C1 and C4 around from the original usermessage
// TODO make customizable via profile
final Ebms3MessageProperties aEbms3MessageProperties = new Ebms3MessageProperties();
{
Ebms3Property aFinalRecipient = null;
Ebms3Property aOriginalSender = null;
for (final Ebms3Property aProp : aUserMessage.getMessageProperties().getProperty()) {
if (aProp.getName().equals(CAS4.ORIGINAL_SENDER))
aOriginalSender = aProp;
else if (aProp.getName().equals(CAS4.FINAL_RECIPIENT))
aFinalRecipient = aProp;
}
if (aOriginalSender == null)
throw new IllegalStateException("Failed to determine new OriginalSender");
if (aFinalRecipient == null)
throw new IllegalStateException("Failed to determine new FinalRecipient");
aFinalRecipient.setName(CAS4.ORIGINAL_SENDER);
aOriginalSender.setName(CAS4.FINAL_RECIPIENT);
aEbms3MessageProperties.addProperty(aFinalRecipient);
aEbms3MessageProperties.addProperty(aOriginalSender);
}
return AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, eSoapVersion);
}
use of com.helger.phase4.ebms3header.Ebms3PartyInfo in project phase4 by phax.
the class MessageHelperMethods method createEbms3PartyInfo.
@Nonnull
public static Ebms3PartyInfo createEbms3PartyInfo(@Nonnull @Nonempty final String sFromRole, @Nullable final String sFromPartyIDType, @Nonnull @Nonempty final String sFromPartyID, @Nonnull @Nonempty final String sToRole, @Nullable final String sToPartyIDType, @Nonnull @Nonempty final String sToPartyID) {
ValueEnforcer.notEmpty(sFromRole, "FromRole");
ValueEnforcer.notEmpty(sFromPartyID, "FromPartyID");
ValueEnforcer.notEmpty(sToRole, "ToRole");
ValueEnforcer.notEmpty(sToPartyID, "ToPartyID");
final Ebms3PartyInfo aEbms3PartyInfo = new Ebms3PartyInfo();
// From => Sender
final Ebms3From aEbms3From = new Ebms3From();
aEbms3From.setRole(sFromRole);
aEbms3From.addPartyId(createEbms3PartyId(sFromPartyIDType, sFromPartyID));
aEbms3PartyInfo.setFrom(aEbms3From);
// To => Receiver
final Ebms3To aEbms3To = new Ebms3To();
aEbms3To.setRole(sToRole);
aEbms3To.addPartyId(createEbms3PartyId(sToPartyIDType, sToPartyID));
aEbms3PartyInfo.setTo(aEbms3To);
return aEbms3PartyInfo;
}
use of com.helger.phase4.ebms3header.Ebms3PartyInfo in project phase4 by phax.
the class PeppolCompatibilityValidatorTest method testValidateUserMessageMoreThanOnePartyID.
@Test
public void testValidateUserMessageMoreThanOnePartyID() {
final Ebms3PartyId aFirstId = MessageHelperMethods.createEbms3PartyId("type", "value");
final Ebms3PartyId aSecondId = MessageHelperMethods.createEbms3PartyId("type2", "value2");
final Ebms3From aFromPart = new Ebms3From();
aFromPart.addPartyId(aFirstId);
aFromPart.addPartyId(aSecondId);
final Ebms3To aToPart = new Ebms3To();
aToPart.addPartyId(aFirstId);
aToPart.addPartyId(aSecondId);
final Ebms3PartyInfo aPartyInfo = new Ebms3PartyInfo();
aPartyInfo.setFrom(aFromPart);
aPartyInfo.setTo(aToPart);
final Ebms3UserMessage aUserMessage = new Ebms3UserMessage();
aUserMessage.setPartyInfo(aPartyInfo);
VALIDATOR.validateUserMessage(aUserMessage, m_aErrorList);
assertTrue(m_aErrorList.containsAny(x -> x.getErrorText(LOCALE).contains("must contain no more than one PartyID")));
}
Aggregations