Search in sources :

Example 6 with Ebms3From

use of com.helger.phase4.ebms3header.Ebms3From 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")));
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) PModeLegSecurity(com.helger.phase4.model.pmode.leg.PModeLegSecurity) MessageHelperMethods(com.helger.phase4.messaging.domain.MessageHelperMethods) EMEP(com.helger.phase4.model.EMEP) ErrorList(com.helger.commons.error.list.ErrorList) ETriState(com.helger.commons.state.ETriState) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Assert.assertNotSame(org.junit.Assert.assertNotSame) EPModeSendReceiptReplyPattern(com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Locale(java.util.Locale) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) PMode(com.helger.phase4.model.pmode.PMode) PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) ClassRule(org.junit.ClassRule) PModeLegErrorHandling(com.helger.phase4.model.pmode.leg.PModeLegErrorHandling) PhotonAppWebTestRule(com.helger.photon.app.mock.PhotonAppWebTestRule) Before(org.junit.Before) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) PModeLegProtocol(com.helger.phase4.model.pmode.leg.PModeLegProtocol) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) Assert.assertTrue(org.junit.Assert.assertTrue) EMEPBinding(com.helger.phase4.model.EMEPBinding) Test(org.junit.Test) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ignore(org.junit.Ignore) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) IPModeIDProvider(com.helger.phase4.model.pmode.IPModeIDProvider) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 7 with Ebms3From

use of com.helger.phase4.ebms3header.Ebms3From in project phase4 by phax.

the class CEFCompatibilityValidatorTwoWayFuncTest 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")));
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) PModeLegSecurity(com.helger.phase4.model.pmode.leg.PModeLegSecurity) MessageHelperMethods(com.helger.phase4.messaging.domain.MessageHelperMethods) EMEP(com.helger.phase4.model.EMEP) ErrorList(com.helger.commons.error.list.ErrorList) ETriState(com.helger.commons.state.ETriState) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Assert.assertNotSame(org.junit.Assert.assertNotSame) EPModeSendReceiptReplyPattern(com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Locale(java.util.Locale) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) PMode(com.helger.phase4.model.pmode.PMode) PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) ClassRule(org.junit.ClassRule) PModeLegErrorHandling(com.helger.phase4.model.pmode.leg.PModeLegErrorHandling) PhotonAppWebTestRule(com.helger.photon.app.mock.PhotonAppWebTestRule) Before(org.junit.Before) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) PModeLegProtocol(com.helger.phase4.model.pmode.leg.PModeLegProtocol) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) Assert.assertTrue(org.junit.Assert.assertTrue) EMEPBinding(com.helger.phase4.model.EMEPBinding) Test(org.junit.Test) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ignore(org.junit.Ignore) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) IPModeIDProvider(com.helger.phase4.model.pmode.IPModeIDProvider) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 8 with Ebms3From

use of com.helger.phase4.ebms3header.Ebms3From in project phase4 by phax.

the class ENTSOGCompatibilityValidator method validateUserMessage.

@Override
public void validateUserMessage(@Nonnull final Ebms3UserMessage aUserMsg, @Nonnull final ErrorList aErrorList) {
    ValueEnforcer.notNull(aUserMsg, "UserMsg");
    if (aUserMsg.getMessageInfo() == null) {
        aErrorList.add(_createError("MessageInfo is missing"));
    } else {
        if (StringHelper.hasNoText(aUserMsg.getMessageInfo().getMessageId()))
            aErrorList.add(_createError("MessageInfo/MessageId is missing"));
        if (StringHelper.hasText(aUserMsg.getMessageInfo().getRefToMessageId()))
            aErrorList.add(_createError("MessageInfo/RefToMessageId must not be set"));
    }
    if (aUserMsg.getPartyInfo() == null) {
        aErrorList.add(_createError("PartyInfo is missing"));
    } else {
        final Ebms3From aFrom = aUserMsg.getPartyInfo().getFrom();
        if (aFrom != null) {
            if (aFrom.getPartyIdCount() > 1)
                aErrorList.add(_createError("PartyInfo/From must contain no more than one PartyID"));
        }
        final Ebms3To aTo = aUserMsg.getPartyInfo().getTo();
        if (aTo != null) {
            if (aTo.getPartyIdCount() > 1)
                aErrorList.add(_createError("PartyInfo/To must contain no more than one PartyID"));
        }
    }
    if (aUserMsg.getCollaborationInfo() == null) {
        aErrorList.add(_createError("CollaborationInfo is missing"));
    } else {
        final Ebms3AgreementRef aAgreementRef = aUserMsg.getCollaborationInfo().getAgreementRef();
        if (StringHelper.hasNoText(aAgreementRef.getValue()))
            aErrorList.add(_createError("CollaborationInfo/AgreementRef value is missing"));
        if (aAgreementRef.getPmode() != null)
            aErrorList.add(_createError("CollaborationInfo/PMode has not to be set!"));
    }
}
Also used : Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3AgreementRef(com.helger.phase4.ebms3header.Ebms3AgreementRef)

Example 9 with Ebms3From

use of com.helger.phase4.ebms3header.Ebms3From in project phase4 by phax.

the class ENTSOGCompatibilityValidatorTest 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")));
}
Also used : Ebms3SignalMessage(com.helger.phase4.ebms3header.Ebms3SignalMessage) PModeLegSecurity(com.helger.phase4.model.pmode.leg.PModeLegSecurity) MessageHelperMethods(com.helger.phase4.messaging.domain.MessageHelperMethods) EMEP(com.helger.phase4.model.EMEP) ErrorList(com.helger.commons.error.list.ErrorList) ETriState(com.helger.commons.state.ETriState) ESoapVersion(com.helger.phase4.soap.ESoapVersion) Assert.assertNotSame(org.junit.Assert.assertNotSame) EPModeSendReceiptReplyPattern(com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern) ECryptoAlgorithmSign(com.helger.phase4.crypto.ECryptoAlgorithmSign) Locale(java.util.Locale) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) PMode(com.helger.phase4.model.pmode.PMode) PModeLeg(com.helger.phase4.model.pmode.leg.PModeLeg) ClassRule(org.junit.ClassRule) PModeLegErrorHandling(com.helger.phase4.model.pmode.leg.PModeLegErrorHandling) PhotonAppWebTestRule(com.helger.photon.app.mock.PhotonAppWebTestRule) Before(org.junit.Before) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) PModeLegProtocol(com.helger.phase4.model.pmode.leg.PModeLegProtocol) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) ECryptoAlgorithmSignDigest(com.helger.phase4.crypto.ECryptoAlgorithmSignDigest) EWSSVersion(com.helger.phase4.wss.EWSSVersion) Assert.assertTrue(org.junit.Assert.assertTrue) EMEPBinding(com.helger.phase4.model.EMEPBinding) Test(org.junit.Test) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) ECryptoAlgorithmCrypt(com.helger.phase4.crypto.ECryptoAlgorithmCrypt) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ignore(org.junit.Ignore) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) IPModeIDProvider(com.helger.phase4.model.pmode.IPModeIDProvider) Ebms3PartyId(com.helger.phase4.ebms3header.Ebms3PartyId) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Example 10 with Ebms3From

use of com.helger.phase4.ebms3header.Ebms3From in project phase4 by phax.

the class Ebms3MessagingTest method testUserMessageNoMessageProperties.

@Test
public void testUserMessageNoMessageProperties() throws Exception {
    final Ebms3Messaging aEbms3Messaging = new Ebms3Messaging();
    final Ebms3UserMessage aEbms3UserMessage = new Ebms3UserMessage();
    // Message Info
    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);
    aEbms3UserMessage.setPartyInfo(aEbms3PartyInfo);
    aEbms3UserMessage.setPayloadInfo(aEbms3PayloadInfo);
    aEbms3UserMessage.setCollaborationInfo(aEbms3CollaborationInfo);
    aEbms3UserMessage.setMessageProperties(MessageHelperMethods.createEbms3MessageProperties(null));
    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());
}
Also used : Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3From(com.helger.phase4.ebms3header.Ebms3From) HttpEntity(org.apache.http.HttpEntity) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3To(com.helger.phase4.ebms3header.Ebms3To) Node(org.w3c.dom.Node) Ebms3UserMessage(com.helger.phase4.ebms3header.Ebms3UserMessage) Ebms3Messaging(com.helger.phase4.ebms3header.Ebms3Messaging) HttpXMLEntity(com.helger.phase4.http.HttpXMLEntity) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Test(org.junit.Test)

Aggregations

Ebms3From (com.helger.phase4.ebms3header.Ebms3From)10 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)10 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)7 ErrorList (com.helger.commons.error.list.ErrorList)6 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)6 Test (org.junit.Test)6 ETriState (com.helger.commons.state.ETriState)4 ECryptoAlgorithmCrypt (com.helger.phase4.crypto.ECryptoAlgorithmCrypt)4 ECryptoAlgorithmSign (com.helger.phase4.crypto.ECryptoAlgorithmSign)4 ECryptoAlgorithmSignDigest (com.helger.phase4.crypto.ECryptoAlgorithmSignDigest)4 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)4 Ebms3PartyId (com.helger.phase4.ebms3header.Ebms3PartyId)4 Ebms3SignalMessage (com.helger.phase4.ebms3header.Ebms3SignalMessage)4 MessageHelperMethods (com.helger.phase4.messaging.domain.MessageHelperMethods)4 EMEP (com.helger.phase4.model.EMEP)4 EMEPBinding (com.helger.phase4.model.EMEPBinding)4 IPModeIDProvider (com.helger.phase4.model.pmode.IPModeIDProvider)4 PMode (com.helger.phase4.model.pmode.PMode)4 EPModeSendReceiptReplyPattern (com.helger.phase4.model.pmode.leg.EPModeSendReceiptReplyPattern)4 PModeLeg (com.helger.phase4.model.pmode.leg.PModeLeg)4