Package nl.clockwork.mule.ebms.model.ebxml

Examples of nl.clockwork.mule.ebms.model.ebxml.MessageHeader


    if (message.getPayload() instanceof EbMSMessage)
    {
      try
      {
        EbMSMessage msg = (EbMSMessage)message.getPayload();
        MessageHeader messageHeader = msg.getMessageHeader();
        CollaborationProtocolAgreement cpa = ebMSDAO.getCPA(messageHeader.getCPAId());
        Signature signature = (Signature)message.getProperty(Constants.EBMS_SIGNATURE);
        PartyInfo partyInfo = CPAUtils.getPartyInfo(cpa,messageHeader.getFrom().getPartyId());
        List<DeliveryChannel> deliveryChannels = CPAUtils.getDeliveryChannels(partyInfo,messageHeader.getFrom().getRole(),messageHeader.getService(),messageHeader.getAction());
        if (CPAUtils.isSigned(deliveryChannels.get(0)))
        {
          if (signature == null)
          {
            message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/Signature",Constants.EbMSErrorCode.SECURITY_FAILURE.errorCode(),"No signature found."));
View Full Code Here


    if (message.getPayload() instanceof EbMSBaseMessage)
    {
      try
      {
        EbMSBaseMessage msg = (EbMSBaseMessage)message.getPayload();
        MessageHeader messageHeader = msg.getMessageHeader();

        String refToMessageId = messageHeader.getMessageData().getRefToMessageId();
        if (!StringUtils.isEmpty(refToMessageId))
          //FIXME refToMessageId does not have to refer to another message or to an Acknowledgment or ErrorMessage
          if (!ebMSDAO.existsMessage(refToMessageId))
          {
            message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/MessageData/RefToMessageId",Constants.EbMSErrorCode.VALUE_NOT_RECOGNIZED.errorCode(),"Value not found."));
View Full Code Here

    }

    private boolean isSigned(Document document) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException, JAXBException, DAOException
    {
      Node n = (Node)XMLUtils.executeXPathQuery(new EbXMLNamespaceContext(),document,"/soap:Envelope/soap:Header/ebxml:MessageHeader",XPathConstants.NODE);
      MessageHeader messageHeader = XMLMessageBuilder.getInstance(MessageHeader.class).handle(n);
      CollaborationProtocolAgreement cpa = ebMSDAO.getCPA(messageHeader.getCPAId());
      PartyInfo partyInfo = CPAUtils.getPartyInfo(cpa,messageHeader.getFrom().getPartyId());
      List<DeliveryChannel> channels = CPAUtils.getDeliveryChannels(partyInfo,messageHeader.getFrom().getRole(),messageHeader.getService(),messageHeader.getAction());
      return CPAUtils.isSigned(channels.get(0));
    }
View Full Code Here

    String uuid = UUID.getUUID();
    PartyInfo sendingPartyInfo = CPAUtils.getSendingPartyInfo(cpa,context.getFromRole(),context.getServiceType(),context.getService(),context.getAction());
    PartyInfo receivingPartyInfo = CPAUtils.getReceivingPartyInfo(cpa,context.getToRole(),context.getServiceType(),context.getService(),context.getAction());
    //PartyInfo receivingPartyInfo = CPAUtils.getOtherReceivingPartyInfo(cpa,context.getFromRole(),context.getServiceType(),context.getService(),context.getAction());

    MessageHeader messageHeader = new MessageHeader();

    messageHeader.setVersion(Constants.EBMS_VERSION);
    messageHeader.setMustUnderstand(true);

    messageHeader.setCPAId(cpa.getCpaid());
    messageHeader.setConversationId(context.getConversationId() != null ? context.getConversationId() : uuid);
   
    messageHeader.setFrom(new From());
    PartyId from = new PartyId();
    from.setType(sendingPartyInfo.getPartyId().get(0).getType());
    from.setValue(sendingPartyInfo.getPartyId().get(0).getValue());
    messageHeader.getFrom().getPartyId().add(from);
    messageHeader.getFrom().setRole(sendingPartyInfo.getCollaborationRole().get(0).getRole().getName());

    messageHeader.setTo(new To());
    PartyId to = new PartyId();
    to.setType(receivingPartyInfo.getPartyId().get(0).getType());
    to.setValue(receivingPartyInfo.getPartyId().get(0).getValue());
    messageHeader.getTo().getPartyId().add(to);
    messageHeader.getTo().setRole(receivingPartyInfo.getCollaborationRole().get(0).getRole().getName());
   
    messageHeader.setService(new Service());
    messageHeader.getService().setType(sendingPartyInfo.getCollaborationRole().get(0).getServiceBinding().getService().getType());
    messageHeader.getService().setValue(sendingPartyInfo.getCollaborationRole().get(0).getServiceBinding().getService().getValue());
    messageHeader.setAction(sendingPartyInfo.getCollaborationRole().get(0).getServiceBinding().getCanSend().get(0).getThisPartyActionBinding().getAction());

    messageHeader.setMessageData(new MessageData());
    messageHeader.getMessageData().setMessageId(uuid + "@" + hostname);
    messageHeader.getMessageData().setRefToMessageId(context.getRefToMessageId());
    messageHeader.getMessageData().setTimestamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar()));

    ReliableMessaging rm = CPAUtils.getReliableMessaging(cpa,messageHeader);
    if (rm != null)
    {
      GregorianCalendar timestamp = messageHeader.getMessageData().getTimestamp().toGregorianCalendar();
      Duration d = rm.getRetryInterval().multiply(rm.getRetries().add(new BigInteger("1")).intValue());
      d.addTo(timestamp);
      timestamp.add(Calendar.SECOND,1);
      messageHeader.getMessageData().setTimeToLive(DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp));
    }

    DeliveryChannel channel = CPAUtils.getDeliveryChannel(sendingPartyInfo.getCollaborationRole().get(0).getServiceBinding().getCanSend().get(0).getThisPartyActionBinding());

    messageHeader.setDuplicateElimination(PerMessageCharacteristicsType.ALWAYS.equals(channel.getMessagingCharacteristics().getDuplicateElimination()) ? "" : null);
   
    return messageHeader;
  }
View Full Code Here

    return pong;
  }

  public static EbMSStatusResponse ebMSStatusRequestToEbMSStatusResponse(EbMSStatusRequest request, String hostname, EbMSMessageStatus status, GregorianCalendar timestamp) throws DatatypeConfigurationException
  {
    MessageHeader messageHeader = createMessageHeader(request.getMessageHeader(),hostname,new GregorianCalendar(),EbMSMessageType.STATUS_RESPONSE.action());
    StatusResponse statusResponse = createStatusResponse(request.getStatusRequest(),status,timestamp);
    EbMSStatusResponse response = new EbMSStatusResponse(messageHeader,statusResponse);
    return response;
  }
View Full Code Here

    return response;
  }

  public static EbMSMessage ebMSMessageContentToEbMSMessage(CollaborationProtocolAgreement cpa, EbMSMessageContent content, String hostname) throws DatatypeConfigurationException
  {
    MessageHeader messageHeader = createMessageHeader(cpa,content.getContext(),hostname);

    AckRequested ackRequested = createAckRequested(cpa,content.getContext());
   
    Manifest manifest = createManifest();
    for (int i = 0; i < content.getAttachments().size(); i++)
View Full Code Here

    if (message.getPayload() instanceof EbMSMessage)
    {
      try
      {
        EbMSMessage msg = (EbMSMessage)message.getPayload();
        MessageHeader messageHeader = ebMSDAO.getMessageHeader(msg.getMessageHeader().getMessageData().getMessageId());
        return compare(msg.getMessageHeader(),messageHeader);
      }
      catch (DAOException e)
      {
        throw new RuntimeException(e);
View Full Code Here

    if (message.getPayload() instanceof EbMSBaseMessage)
    {
      try
      {
        EbMSBaseMessage msg = (EbMSBaseMessage)message.getPayload();
        MessageHeader messageHeader = msg.getMessageHeader();
        CollaborationProtocolAgreement cpa = ebMSDAO.getCPA(messageHeader.getCPAId());
        PartyInfo from = null;
        PartyInfo to = null;

        if (!Constants.EBMS_VERSION.equals(messageHeader.getVersion()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader[@version]",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value invalid."));
          return false;
        }

        if (!isValid(messageHeader.getFrom().getPartyId()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/From/PartyId",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value invalid."));
          return false;
        }
        if (!isValid(messageHeader.getTo().getPartyId()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/To/PartyId",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value invalid."));
          return false;
        }
        if (!isValid(messageHeader.getService()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/Service",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value invalid."));
          return false;
        }
       
        if ((from = CPAUtils.getPartyInfo(cpa, messageHeader.getFrom().getPartyId())) == null)
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/From/PartyId",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value not found."));
          return false;
        }
        if ((to = CPAUtils.getPartyInfo(cpa, messageHeader.getTo().getPartyId())) == null)
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/To/PartyId",Constants.EbMSErrorCode.INCONSISTENT.errorCode(),"Value not found."));
          return false;
        }

        if (!CPAUtils.canSend(from,messageHeader.getFrom().getRole(),messageHeader.getService(),messageHeader.getAction()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/Action",Constants.EbMSErrorCode.VALUE_NOT_RECOGNIZED.errorCode(),"Value not found."));
          return false;
        }
        if (!CPAUtils.canReceive(to,messageHeader.getTo().getRole(),messageHeader.getService(),messageHeader.getAction()))
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError("//Header/MessageHeader/Action",Constants.EbMSErrorCode.VALUE_NOT_RECOGNIZED.errorCode(),"Value not found."));
          return false;
        }

        List<DeliveryChannel> deliveryChannels = CPAUtils.getDeliveryChannels(from,messageHeader.getFrom().getRole(),messageHeader.getService(),messageHeader.getAction());
        if (deliveryChannels.size() == 0)
        {
          message.setProperty(Constants.EBMS_ERROR,EbMSMessageUtils.createError(Constants.EbMSErrorCode.UNKNOWN.errorCode(),Constants.EbMSErrorCode.UNKNOWN.errorCode(),"No DeliveryChannel found."));
          return false;
        }
View Full Code Here

  private X509Certificate getCertificate(Document document)
  {
    try
    {
      Node n = (Node)XMLUtils.executeXPathQuery(new EbXMLNamespaceContext(),document,"/soap:Envelope/soap:Header/ebxml:MessageHeader",XPathConstants.NODE);
      MessageHeader messageHeader = XMLMessageBuilder.getInstance(MessageHeader.class).handle(n);
      CollaborationProtocolAgreement cpa = ebMSDAO.getCPA(messageHeader.getCPAId());
      if (cpa != null)
      {
        PartyInfo partyInfo = CPAUtils.getPartyInfo(cpa,messageHeader.getFrom().getPartyId());
        if (partyInfo != null)
        {
          List<DeliveryChannel> channels = CPAUtils.getDeliveryChannels(partyInfo,messageHeader.getFrom().getRole(),messageHeader.getService(),messageHeader.getAction());
          if (channels.size() == 1)
          {
            nl.clockwork.mule.ebms.model.cpp.cpa.Certificate c = CPAUtils.getCertificate(channels.get(0));
            if (c == null)
              return null;
View Full Code Here

    try
    {
      GregorianCalendar timestamp = new GregorianCalendar();

      EbMSMessage msg = (EbMSMessage)message.getPayload();
      MessageHeader messageHeader = EbMSMessageUtils.createMessageHeader(msg.getMessageHeader(),hostname,timestamp,EbMSMessageType.ACKNOWLEDGMENT.action());
     
      Acknowledgment acknowledgment = new Acknowledgment();

      acknowledgment.setVersion(Constants.EBMS_VERSION);
      acknowledgment.setMustUnderstand(true);

      acknowledgment.setTimestamp(DatatypeFactory.newInstance().newXMLGregorianCalendar(timestamp));
      acknowledgment.setRefToMessageId(messageHeader.getMessageData().getRefToMessageId());
      acknowledgment.setFrom(new From()); //optioneel
      acknowledgment.getFrom().getPartyId().addAll(messageHeader.getFrom().getPartyId());
      // ebMS specs 1701
      //acknowledgment.getFrom().setRole(messageHeader.getFrom().getRole());
      acknowledgment.getFrom().setRole(null);
     
      //TODO resolve actor from CPA
View Full Code Here

TOP

Related Classes of nl.clockwork.mule.ebms.model.ebxml.MessageHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.