Search in sources :

Example 1 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class ENTSOGPMode method createENTSOGPMode.

/**
 * One-Way Version of the CEF pmode uses one-way push
 *
 * @param sInitiatorID
 *        Initiator ID
 * @param sResponderID
 *        Responder ID
 * @param sResponderAddress
 *        Responder URL
 * @param aPModeIDProvider
 *        PMode ID provider
 * @param bPersist
 *        <code>true</code> to persist the PMode in the PModeManager,
 *        <code>false</code> to have it only in memory.
 * @return New PMode
 */
@Nonnull
public static PMode createENTSOGPMode(@Nonnull @Nonempty final String sInitiatorID, @Nonnull @Nonempty final String sResponderID, @Nullable final String sResponderAddress, @Nonnull final IPModeIDProvider aPModeIDProvider, final boolean bPersist) {
    final PModeParty aInitiator = new PModeParty(ENTSOG_PARTY_ID_TYPE, sInitiatorID, CAS4.DEFAULT_INITIATOR_URL, null, null);
    final PModeParty aResponder = new PModeParty(ENTSOG_PARTY_ID_TYPE, sResponderID, CAS4.DEFAULT_RESPONDER_URL, null, null);
    final PMode aPMode = new PMode(aPModeIDProvider.getPModeID(sInitiatorID, sResponderID), aInitiator, aResponder, DEFAULT_AGREEMENT_ID, EMEP.ONE_WAY, EMEPBinding.PUSH, generatePModeLeg(sResponderAddress), (PModeLeg) null, generatePModePayloadSevice(), generatePModeReceptionAwareness());
    if (bPersist) {
        // Ensure it is stored
        MetaAS4Manager.getPModeMgr().createOrUpdatePMode(aPMode);
    }
    return aPMode;
}
Also used : PModeParty(com.helger.phase4.model.pmode.PModeParty) PMode(com.helger.phase4.model.pmode.PMode) Nonnull(javax.annotation.Nonnull)

Example 2 with CAS4

use of com.helger.phase4.CAS4 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));
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) NodeList(org.w3c.dom.NodeList) 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 3 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class AbstractCEFTestSetUp method createTestUserMessageSoapNotSigned.

@Nonnull
protected AS4UserMessage createTestUserMessageSoapNotSigned(@Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aAttachments) {
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, aAttachments);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSOneWayPMode.getID(), DEFAULT_AGREEMENT, AS4TestConstants.TEST_SERVICE_TYPE, MockPModeGenerator.SOAP11_SERVICE, AS4TestConstants.TEST_ACTION, AS4TestConstants.TEST_CONVERSATION_ID);
    final Ebms3PartyInfo aEbms3PartyInfo;
    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);
    return AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 4 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class AbstractCEFTwoWayTestSetUp method testUserMessageSoapNotSigned.

@Nonnull
protected AS4UserMessage testUserMessageSoapNotSigned(@Nullable final Node aPayload, @Nullable final ICommonsList<WSS4JAttachment> aAttachments) {
    // Add properties
    final ICommonsList<Ebms3Property> aEbms3Properties = AS4TestConstants.getEBMSProperties();
    final Ebms3MessageInfo aEbms3MessageInfo = MessageHelperMethods.createEbms3MessageInfo();
    final Ebms3PayloadInfo aEbms3PayloadInfo = MessageHelperMethods.createEbms3PayloadInfo(aPayload != null, aAttachments);
    final Ebms3CollaborationInfo aEbms3CollaborationInfo;
    final Ebms3PartyInfo aEbms3PartyInfo;
    aEbms3CollaborationInfo = MessageHelperMethods.createEbms3CollaborationInfo(m_aESENSTwoWayPMode.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);
    return AS4UserMessage.create(aEbms3MessageInfo, aEbms3PayloadInfo, aEbms3CollaborationInfo, aEbms3PartyInfo, aEbms3MessageProperties, m_eSoapVersion).setMustUnderstand(true);
}
Also used : Ebms3MessageProperties(com.helger.phase4.ebms3header.Ebms3MessageProperties) Ebms3PayloadInfo(com.helger.phase4.ebms3header.Ebms3PayloadInfo) Ebms3CollaborationInfo(com.helger.phase4.ebms3header.Ebms3CollaborationInfo) Ebms3MessageInfo(com.helger.phase4.ebms3header.Ebms3MessageInfo) Ebms3PartyInfo(com.helger.phase4.ebms3header.Ebms3PartyInfo) Ebms3Property(com.helger.phase4.ebms3header.Ebms3Property) Nonnull(javax.annotation.Nonnull)

Example 5 with CAS4

use of com.helger.phase4.CAS4 in project phase4 by phax.

the class PeppolPMode method createPeppolPMode.

/**
 * One-Way Version of the PEPPOL pmode uses one-way push
 *
 * @param sInitiatorID
 *        Initiator ID. May neither be <code>null</code> nor empty.
 * @param sResponderID
 *        Responder ID. May neither be <code>null</code> nor empty.
 * @param sAddress
 *        Endpoint address URL. May be <code>null</code>.
 * @param aPModeIDProvider
 *        PMode ID provider. May not be <code>null</code>.
 * @param bPersist
 *        <code>true</code> to persist the PMode in the PModeManager,
 *        <code>false</code> to have it only in memory.
 * @return New PMode and never <code>null</code>.
 */
@Nonnull
public static PMode createPeppolPMode(@Nonnull @Nonempty final String sInitiatorID, @Nonnull @Nonempty final String sResponderID, @Nullable final String sAddress, @Nonnull final IPModeIDProvider aPModeIDProvider, final boolean bPersist) {
    final PModeParty aInitiator = createParty(sInitiatorID, CAS4.DEFAULT_INITIATOR_URL);
    final PModeParty aResponder = createParty(sResponderID, CAS4.DEFAULT_RESPONDER_URL);
    final PMode aPMode = new PMode(aPModeIDProvider.getPModeID(sInitiatorID, sResponderID), aInitiator, aResponder, DEFAULT_AGREEMENT_ID, EMEP.ONE_WAY, EMEPBinding.PUSH, generatePModeLeg(sAddress), (PModeLeg) null, (PModePayloadService) null, generatePModeReceptionAwareness());
    if (bPersist) {
        // Ensure it is stored
        MetaAS4Manager.getPModeMgr().createOrUpdatePMode(aPMode);
    }
    return aPMode;
}
Also used : PModeParty(com.helger.phase4.model.pmode.PModeParty) PMode(com.helger.phase4.model.pmode.PMode) Nonnull(javax.annotation.Nonnull)

Aggregations

Ebms3MessageProperties (com.helger.phase4.ebms3header.Ebms3MessageProperties)20 Ebms3Property (com.helger.phase4.ebms3header.Ebms3Property)20 Ebms3CollaborationInfo (com.helger.phase4.ebms3header.Ebms3CollaborationInfo)18 Ebms3PartyInfo (com.helger.phase4.ebms3header.Ebms3PartyInfo)18 Ebms3PayloadInfo (com.helger.phase4.ebms3header.Ebms3PayloadInfo)18 Nonnull (javax.annotation.Nonnull)16 Ebms3MessageInfo (com.helger.phase4.ebms3header.Ebms3MessageInfo)15 Test (org.junit.Test)14 Document (org.w3c.dom.Document)14 HttpXMLEntity (com.helger.phase4.http.HttpXMLEntity)12 AS4UserMessage (com.helger.phase4.messaging.domain.AS4UserMessage)12 Ebms3UserMessage (com.helger.phase4.ebms3header.Ebms3UserMessage)11 ClassPathResource (com.helger.commons.io.resource.ClassPathResource)10 PMode (com.helger.phase4.model.pmode.PMode)9 Node (org.w3c.dom.Node)8 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)5 PModeLeg (com.helger.phase4.model.pmode.leg.PModeLeg)5 Before (org.junit.Before)5 Ebms3From (com.helger.phase4.ebms3header.Ebms3From)4 Ebms3To (com.helger.phase4.ebms3header.Ebms3To)4