Exemple #1
0
  /** This will be invoked by the schedular to inject the message in to the SynapseEnvironment */
  public void execute() {
    log.debug("execute");
    if (synapseEnvironment == null) {
      log.error("Synapse Environment not set");
      return;
    }
    if (message == null) {
      log.error("message not set");
      return;
    }
    if (to == null) {
      log.error("to address not set");
      return;
    }

    MessageContext mc = synapseEnvironment.createMessageContext();
    //        AspectHelper.setGlobalAudit(mc);    TODO
    mc.pushFaultHandler(new MediatorFaultHandler(mc.getFaultSequence()));
    mc.setTo(new EndpointReference(to));
    if (format == null) {
      PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
    } else {
      try {
        if (SOAP11_FORMAT.equalsIgnoreCase(format)) {
          mc.setEnvelope(OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope());
        } else if (SOAP12_FORMAT.equalsIgnoreCase(format)) {
          mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope());
        } else if (POX_FORMAT.equalsIgnoreCase(format)) {
          mc.setDoingPOX(true);
        } else if (GET_FORMAT.equalsIgnoreCase(format)) {
          mc.setDoingGET(true);
        }
        PayloadHelper.setXMLPayload(mc, message.cloneOMElement());
      } catch (AxisFault axisFault) {
        String msg = "Error in setting the message payload : " + message;
        log.error(msg, axisFault);
        throw new SynapseException(msg, axisFault);
      }
    }
    if (soapAction != null) {
      mc.setSoapAction(soapAction);
    }
    synapseEnvironment.injectMessage(mc);
  }
Exemple #2
0
  /**
   * Creates the content of a Non-Repudiation Of Receipt (NRR) Receipt as defined in section 5.1.8
   * of the AS4 profile.
   *
   * @param mc The current {@link MessageContext}, used to get copies of the <code>ds:Reference
   *     </code> elements
   * @return The content for the new Receipt represented as an iteration of <code>OMElement</code>s
   */
  protected Iterator<OMElement> createNRRContent(MessageContext mc) {
    ArrayList<OMElement> rcptContent = new ArrayList<OMElement>();
    // Get element factory for creating the elements in the Receipt content
    OMFactory elemFactory = mc.getEnvelope().getOMFactory();
    // Create the ebbp:NonRepudiationInformation container element
    OMElement ebbpNRIElement = elemFactory.createOMElement(QNAME_NRI_ELEM);
    ebbpNRIElement.declareNamespace(EBBP_NS, EBBP_NS_PREFIX);

    // Add a ebbp:MessagePartNRInformation for each reference found in Signature element of the
    // received message
    for (OMElement ref : SecurityUtils.getSignatureReferences(mc)) {
      OMElement ebbpMsgPart = elemFactory.createOMElement(QNAME_MSG_PART_ELEM);
      ebbpMsgPart.addChild(ref.cloneOMElement());
      ebbpNRIElement.addChild(ebbpMsgPart);
    }
    rcptContent.add(ebbpNRIElement);

    return rcptContent.iterator();
  }
 private void setFaultDetail(MessageContext synCtx, SOAPFactory factory, SOAPFault fault) {
   if (faultDetail != null) {
     SOAPFaultDetail soapFaultDetail = factory.createSOAPFaultDetail();
     soapFaultDetail.setText(faultDetail);
     fault.setDetail(soapFaultDetail);
   } else if (faultDetailExpr != null) {
     SOAPFaultDetail soapFaultDetail = factory.createSOAPFaultDetail();
     Object result = null;
     try {
       result = faultDetailExpr.evaluate(synCtx);
     } catch (JaxenException e) {
       handleException(
           "Evaluation of the XPath expression " + this.toString() + " resulted in an error", e);
     }
     if (result instanceof List) {
       List list = (List) result;
       for (Object obj : list) {
         if (obj instanceof OMNode) {
           soapFaultDetail.addChild((OMNode) obj);
         }
       }
     } else {
       soapFaultDetail.setText(faultDetailExpr.stringValueOf(synCtx));
     }
     fault.setDetail(soapFaultDetail);
   } else if (!faultDetailElements.isEmpty()) {
     SOAPFaultDetail soapFaultDetail = factory.createSOAPFaultDetail();
     for (OMElement faultDetailElement : faultDetailElements) {
       soapFaultDetail.addChild(faultDetailElement.cloneOMElement());
     }
     fault.setDetail(soapFaultDetail);
   } else if (fault.getDetail() != null) {
     // work around for a rampart issue in the following thread
     // http://www.nabble.com/Access-to-validation-error-message-tf4498668.html#a13284520
     fault.getDetail().detach();
   }
 }