use of com.helger.phase4.model.pmode.leg.PModeLeg in project phase4 by phax.
the class PModeJsonConverter method convertToNative.
@Nonnull
public static PMode convertToNative(@Nonnull final IJsonObject aElement) {
final IJsonObject aInit = aElement.getAsObject(ELEMENT_INITIATOR);
final PModeParty aInitiator = aInit == null ? null : PModePartyJsonConverter.convertToNative(aInit);
final IJsonObject aResp = aElement.getAsObject(ELEMENT_RESPONDER);
final PModeParty aResponder = aResp == null ? null : PModePartyJsonConverter.convertToNative(aResp);
final String sAgreement = aElement.getAsString(ATTR_AGREEMENT);
final String sMEP = aElement.getAsString(ATTR_MEP);
final EMEP eMEP = EMEP.getFromIDOrNull(sMEP);
if (eMEP == null)
throw new IllegalStateException("Failed to resolve MEP '" + sMEP + "'");
final String sMEPBinding = aElement.getAsString(ATTR_MEP_BINDING);
final EMEPBinding eMEPBinding = EMEPBinding.getFromIDOrNull(sMEPBinding);
if (eMEPBinding == null)
throw new IllegalStateException("Failed to resolve MEPBinding '" + sMEPBinding + "'");
final IJsonObject aL1 = aElement.getAsObject(ELEMENT_LEG1);
final PModeLeg aLeg1 = aL1 == null ? null : PModeLegJsonConverter.convertToNative(aL1);
final IJsonObject aL2 = aElement.getAsObject(ELEMENT_LEG2);
final PModeLeg aLeg2 = aL2 == null ? null : PModeLegJsonConverter.convertToNative(aL2);
final IJsonObject aPS = aElement.getAsObject(ELEMENT_PAYLOADSERVICE);
final PModePayloadService aPayloadService = aPS == null ? null : PModePayloadServiceJsonConverter.convertToNative(aPS);
final IJsonObject aRA = aElement.getAsObject(ELEMENT_RECEPETIONAWARENESS);
final PModeReceptionAwareness aReceptionAwareness = aRA == null ? null : PModeReceptionAwarenessJsonConverter.convertToNative(aRA);
return new PMode(getStubObject(aElement), aInitiator, aResponder, sAgreement, eMEP, eMEPBinding, aLeg1, aLeg2, aPayloadService, aReceptionAwareness);
}
use of com.helger.phase4.model.pmode.leg.PModeLeg in project phase4 by phax.
the class PModeCheckTest method testPModeLegProtocolAddressReject.
/**
* Is ESENS specific, EBMS3 specification is the protocol an optional element.
* Maybe refactoring into a test if http and SMTP addresses later on get
* converted right
*
* @throws Exception
* In case of an error
*/
@Test
@Ignore("The PMode leg protocol address is curently not used, therefore the wrong address never pops up")
public void testPModeLegProtocolAddressReject() throws Exception {
final String sInvalidPModeID = "pmode-" + GlobalIDFactory.getNewPersistentIntID();
final PMode aPMode = MockPModeGenerator.getTestPMode(SOAP_VERSION);
aPMode.setLeg1(new PModeLeg(PModeLegProtocol.createForDefaultSoapVersion("TestsimulationAddressWrong"), null, null, null, null));
final IPModeManager aPModeMgr = MetaAS4Manager.getPModeMgr();
try {
aPModeMgr.createOrUpdatePMode(aPMode);
final Wrapper<String> aMsgID = new Wrapper<>();
final Document aDoc = modifyUserMessage(sInvalidPModeID, null, null, createDefaultProperties(), null, null, x -> aMsgID.set(x));
final Document aSignedDoc = AS4Signer.createSignedMessage(m_aCryptoFactory, aDoc, SOAP_VERSION, aMsgID.get(), null, s_aResMgr, false, AS4SigningParams.createDefault());
sendPlainMessageAndWait(new HttpXMLEntity(aSignedDoc, SOAP_VERSION.getMimeType()), false, EEbmsError.EBMS_PROCESSING_MODE_MISMATCH.getErrorCode());
} finally {
aPModeMgr.deletePMode(aPMode.getID());
}
}
use of com.helger.phase4.model.pmode.leg.PModeLeg in project phase4 by phax.
the class TwoWayAsyncPullPushTest method before.
@Before
public void before() {
final PMode aPMode = CEFPMode.createCEFPMode(AS4TestConstants.TEST_INITIATOR, AS4TestConstants.TEST_RESPONDER, MockJettySetup.getServerAddressFromSettings(), (i, r) -> "pmode" + GlobalIDFactory.getNewPersistentLongID(), false);
// Setting second leg to the same as first
final PModeLeg aLeg2 = aPMode.getLeg1();
// ESENS PMode is One Way on default settings need to change to two way
m_aPMode = new PMode(aPMode.getID(), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), aPMode.getAgreement(), EMEP.TWO_WAY, EMEPBinding.PULL_PUSH, aPMode.getLeg1(), aLeg2, aPMode.getPayloadService(), aPMode.getReceptionAwareness());
// Delete old PMode since it is getting created in the ESENS createPMode
MetaAS4Manager.getPModeMgr().deletePMode(aPMode.getID());
MetaAS4Manager.getPModeMgr().createOrUpdatePMode(m_aPMode);
}
use of com.helger.phase4.model.pmode.leg.PModeLeg in project phase4 by phax.
the class TwoWayMEPTest method before.
@Before
public void before() {
final PMode aPMode = CEFPMode.createCEFPMode(AS4TestConstants.TEST_INITIATOR, AS4TestConstants.TEST_RESPONDER, MockJettySetup.getServerAddressFromSettings(), (i, r) -> "pmode" + GlobalIDFactory.getNewPersistentLongID(), false);
// Setting second leg to the same as first
final PModeLeg aLeg2 = aPMode.getLeg1();
// ESENS PMode is One Way on default settings need to change to two way
m_aPMode = new PMode(aPMode.getID(), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), PModeParty.createSimple(DEFAULT_PARTY_ID + "1", CAS4.DEFAULT_ROLE), aPMode.getAgreement(), EMEP.TWO_WAY, EMEPBinding.SYNC, aPMode.getLeg1(), aLeg2, aPMode.getPayloadService(), aPMode.getReceptionAwareness());
// Delete old PMode since it is getting created in the ESENS createPMode
MetaAS4Manager.getPModeMgr().deletePMode(aPMode.getID());
MetaAS4Manager.getPModeMgr().createOrUpdatePMode(m_aPMode);
}
use of com.helger.phase4.model.pmode.leg.PModeLeg in project phase4 by phax.
the class AS4RequestHandler method _createResponseReceiptMessage.
/**
* @param aState
* The processing state of the incoming message. Never
* <code>null</code>.
* @param aSoapDocument
* document which should be used as source for the receipt to convert
* it to non-repudiation information. Can be <code>null</code>.
* @param eSoapVersion
* SOAPVersion which should be used
* @param aEffectiveLeg
* the leg that is used to determined, how the receipt should be build
* @param aUserMessage
* used if no non-repudiation information is needed, prints the
* usermessage in receipt. Can be <code>null</code>.
* @param aResponseAttachments
* that should be sent back if needed. Can be <code>null</code>.
* @throws WSSecurityException
*/
@Nonnull
private IAS4ResponseFactory _createResponseReceiptMessage(@Nonnull final IAS4MessageState aState, @Nullable final Document aSoapDocument, @Nonnull final ESoapVersion eSoapVersion, @Nonnull @Nonempty final String sResponseMessageID, @Nonnull final PModeLeg aEffectiveLeg, @Nullable final Ebms3UserMessage aUserMessage, @Nullable final ICommonsList<WSS4JAttachment> aResponseAttachments) throws WSSecurityException {
final AS4ReceiptMessage aReceiptMessage = AS4ReceiptMessage.create(eSoapVersion, sResponseMessageID, aUserMessage, aSoapDocument, _isSendNonRepudiationInformation(aEffectiveLeg)).setMustUnderstand(true);
// We've got our response
final Document aResponseDoc = aReceiptMessage.getAsSoapDocument();
final AS4SigningParams aSigningParams = new AS4SigningParams().setFromPMode(aEffectiveLeg.getSecurity());
final Document aSignedDoc = _signResponseIfNeeded(aResponseAttachments, aSigningParams, aResponseDoc, aEffectiveLeg.getProtocol().getSoapVersion(), aReceiptMessage.getMessagingID());
return new AS4ResponseFactoryXML(m_aMessageMetadata, aState, sResponseMessageID, aSignedDoc, eSoapVersion.getMimeType());
}
Aggregations