Examples of CreateSequence


Examples of org.apache.sandesha.ws.rm.CreateSequence

        String seqId = getNextUUID();
        storageManager.addRequestedSequence(seqId);


        CreateSequence createSeq = rmMessageContext.getRMHeaders().getCreateSequence();
        //Support AcksTo
        if (createSeq.getAcksTo() != null) {
            storageManager.setAcksTo(seqId, createSeq.getAcksTo().getAddress().toString());
        }

        //Support offer
        SequenceOffer offer = createSeq.getOffer();
        boolean offerAccepted = false;
        boolean hasOffer = false;
        if (offer != null) {
            hasOffer = true;
            offerAccepted = acceptOrRejectOffer(offer);
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

    // generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);
    messageContext = createSeqRMMessage.getMessageContext();
    messageContext.setWSAAction(SpecSpecificConstants.getCreateSequenceAction(Sandesha2Constants.SPEC_VERSIONS.v1_1));

    CreateSequence createSeqResPart = (CreateSequence) createSeqRMMessage
    .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    createSeqResPart.setAcksTo(
        new AcksTo(new EndpointReference(AddressingConstants.Final.WSA_NONE_URI),
                   SpecSpecificConstants.getRMNamespaceValue(rmsBean.getRMVersion()),
                   AddressingConstants.Final.WSA_NAMESPACE));
   
    // Update the SOAP Envelope of the message
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

   */
  private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    String sequenceID = null;

    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ);
    CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
    TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.TERMINATE_SEQ);
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

    // generating a new create sequeuce message.
    RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(rmsBean, applicationRMMsg);

    createSeqRMMessage.setFlow(MessageContext.OUT_FLOW);
    CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);

    SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();

    SequenceOffer offer = createSequencePart.getSequenceOffer();
    if (offer != null) {
      String offeredSequenceId = offer.getIdentifer().getIdentifier();

      rmsBean.setOfferedSequence(offeredSequenceId);
    }
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

          log.debug("Exit: CreateSeqMsgProcessor::processInMessage, Service has disabled RM " + false);
          return false;
        }
      }
     
      CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg
          .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
      if (createSeqPart == null) {
        if (log.isDebugEnabled())
          log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqParts));
        FaultManager.makeCreateSequenceRefusedFault(createSeqRMMsg,
                                                    SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqParts),
                                                    new Exception());
        // Return false if an Exception hasn't been thrown.
        if (log.isDebugEnabled())
          log.debug("Exit: CreateSeqMsgProcessor::processInMessage " + Boolean.FALSE);       
        return false;

      }
 
      MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
      ConfigurationContext context = createSeqMsg.getConfigurationContext();
      StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
     
      // If the inbound CreateSequence includes a SecurityTokenReference then
      // ask the security manager to resolve that to a token for us. We also
      // check that the Create was secured using the token.
      SecurityManager secManager = SandeshaUtil.getSecurityManager(context);
      OMElement theSTR = createSeqPart.getSecurityTokenReference();
      SecurityToken token = null;
      if(theSTR != null) {
        MessageContext msgcontext = createSeqRMMsg.getMessageContext();
        token = secManager.getSecurityToken(theSTR, msgcontext);
       
        // The create must be the body part of this message, so we check the
        // security of that element.
        OMElement body = msgcontext.getEnvelope().getBody();
        secManager.checkProofOfPossession(token, body, msgcontext);
      }
 
      //if toAddress is RMAnon we may need to terminate the request side sequence here.
      EndpointReference toEPR = createSeqMsg.getTo();
      if (toEPR.hasAnonymousAddress()) {
 
        RMSBean findBean = new RMSBean ();
        findBean.setReplyToEPR(toEPR.getAddress());
        findBean.setTerminationPauserForCS(true);
       
        //TODO recheck
        RMSBean rmsBean = storageManager.getRMSBeanMgr().findUnique(findBean);
        if (rmsBean!=null) {         
          //AckManager hs not done the termination. Do the termination here.
          MessageContext requestSideRefMessage = storageManager.retrieveMessageContext(rmsBean.getReferenceMessageStoreKey(),context);
          if (requestSideRefMessage==null) {
            FaultManager.makeCreateSequenceRefusedFault(createSeqRMMsg,
                SandeshaMessageHelper.getMessage(SandeshaMessageKeys.referencedMessageNotFound, rmsBean.getInternalSequenceID()),
                new Exception());           
            // Return false if an Exception hasn't been thrown.
            if (log.isDebugEnabled())
              log.debug("Exit: CreateSeqMsgProcessor::processInMessage " + Boolean.FALSE);       
            return false;
          }
         
          RMMsgContext requestSideRefRMMessage = MsgInitializer.initializeMessage(requestSideRefMessage);
          TerminateManager.addTerminateSequenceMessage(requestSideRefRMMessage, rmsBean.getInternalSequenceID(), rmsBean.getSequenceID(), storageManager);
        }
      }
       

      MessageContext outMessage = null;
 
      // Create the new sequence id, as well as establishing the beans that handle the
      // sequence state.
      RMDBean rmdBean = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager, secManager, token);
       
      RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, rmdBean);
      outMessage = createSeqResponse.getMessageContext();
      // Set a message ID for this Create Sequence Response message
      outMessage.setMessageID(SandeshaUtil.getUUID());
       
      createSeqResponse.setFlow(MessageContext.OUT_FLOW);
 
      // for making sure that this won't be processed again
      createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
     
      CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
          .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
 
        // OFFER PROCESSING
      SequenceOffer offer = createSeqPart.getSequenceOffer();
      if (offer != null) {
        Accept accept = createSeqResPart.getAccept();
        if (accept == null) {
          if (log.isDebugEnabled())
            log.debug(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart));
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

   */
  private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {

    String sequenceID = null;

    CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ);
    CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
    TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(
        Sandesha2Constants.MessageParts.TERMINATE_SEQ);
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

      acksToEPR = new EndpointReference(acksToAddress);
    } else {
      acksToEPR = new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
    }
   
    CreateSequence createSequencePart = new CreateSequence(rmNamespaceValue);

    // Check if this service includes 2-way operations
    boolean twoWayService = false;
    AxisService service = applicationMsgContext.getAxisService();
    if(service != null) {
      Parameter p = service.getParameter(Sandesha2Constants.SERVICE_CONTAINS_OUT_IN_MEPS);
      if(p != null && p.getValue() != null) {
        twoWayService = ((Boolean) p.getValue()).booleanValue();
      }
    }
   
    // Adding sequence offer - if present. We send an offer if the client has assigned an
    // id, or if we are using WS-RM 1.0 and the service contains out-in MEPs
    boolean autoOffer = false;
    if(Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmNamespaceValue)) {
      autoOffer = twoWayService;
    } else {
      // We also do some checking at this point to see if MakeConection is required to
      // enable WS-RM 1.1, and write a warning to the log if it has been disabled.
      SandeshaPolicyBean policy = SandeshaUtil.getPropertyBean(context.getAxisConfiguration());
      if(twoWayService && !policy.isEnableMakeConnection()) {
        String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.makeConnectionWarning);
        log.warn(message);
      }
    }

    String offeredSequenceId = (String) applicationMsgContext.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
    if(autoOffer ||
       (offeredSequenceId != null && offeredSequenceId.length() > 0))  {
     
      if (offeredSequenceId == null || offeredSequenceId.length() == 0) {
        offeredSequenceId = SandeshaUtil.getUUID();
      }

      SequenceOffer offerPart = new SequenceOffer(rmNamespaceValue);
      Identifier identifier = new Identifier(rmNamespaceValue);
      identifier.setIndentifer(offeredSequenceId);
      offerPart.setIdentifier(identifier);
      createSequencePart.setSequenceOffer(offerPart);
     
      if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(rmNamespaceValue)) {
        // We are going to send an offer, so decide which endpoint to include
        EndpointReference offeredEndpoint = (EndpointReference) applicationMsgContext.getProperty(SandeshaClientConstants.OFFERED_ENDPOINT);
        if (offeredEndpoint==null) {
          EndpointReference replyTo = applicationMsgContext.getReplyTo()//using replyTo as the Endpoint if it is not specified
       
          if (replyTo!=null) {
            offeredEndpoint = SandeshaUtil.cloneEPR(replyTo);
          }
        }
        // Finally fall back to using an anonymous endpoint
        if (offeredEndpoint==null) {
          offeredEndpoint = new EndpointReference(SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace));
        }
        Endpoint endpoint = new Endpoint (offeredEndpoint, rmNamespaceValue, addressingNamespace);
        offerPart.setEndpoint(endpoint);
      }
    }
   
    String to = rmsBean.getToEPR();
    String replyTo = rmsBean.getReplyToEPR();

    if (to == null) {
      String message = SandeshaMessageHelper
          .getMessage(SandeshaMessageKeys.toBeanNotSet);
      throw new SandeshaException(message);
    }

    // TODO store and retrieve a full EPR instead of just the address.
    EndpointReference toEPR = new EndpointReference(to);
    createSeqRMMsg.setTo(toEPR);

    if(replyTo != null) {
      EndpointReference replyToEPR = new EndpointReference(replyTo);
      createSeqRMMsg.setReplyTo(replyToEPR);
    }

    AcksTo acksTo = new AcksTo(acksToEPR, rmNamespaceValue, addressingNamespace);
    createSequencePart.setAcksTo(acksTo);
   
    createSeqRMMsg.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ, createSequencePart);

    // Find the token that should be used to secure this new sequence. If there is a token, then we
    // save it in the properties so that the caller can store the token within the create sequence
    // bean.
    SecurityManager secMgr = SandeshaUtil.getSecurityManager(context);
    SecurityToken token = secMgr.getSecurityToken(applicationMsgContext);
    if(token != null) {
      OMElement str = secMgr.createSecurityTokenReference(token, createSeqmsgContext);
      createSequencePart.setSecurityTokenReference(str);
      createSeqRMMsg.setProperty(Sandesha2Constants.MessageContextProperties.SECURITY_TOKEN, token);
     
      // If we are using token based security, and the 1.1 spec level, then we
      // should introduce a UsesSequenceSTR header into the message.
      if(createSequencePart.getNamespaceValue().equals(Sandesha2Constants.SPEC_2007_02.NS_URI)) {
        UsesSequenceSTR header = new UsesSequenceSTR(null, Sandesha2Constants.SPEC_2007_02.NS_URI);
        header.toSOAPEnvelope(createSeqmsgContext.getEnvelope());
      }

      // Ensure that the correct token will be used to secure the outbound create sequence message.
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

   * @return
   * @throws AxisFault
   */
  public static RMMsgContext createCreateSeqResponseMsg(RMMsgContext createSeqMessage, RMSequenceBean rmSequenceBean) throws AxisFault {

    CreateSequence cs = (CreateSequence) createSeqMessage.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    String namespace = createSeqMessage.getRMNamespaceValue();

    CreateSequenceResponse response = new CreateSequenceResponse(namespace);
    Identifier identifier = new Identifier(namespace);
    identifier.setIndentifer(rmSequenceBean.getSequenceID());
    response.setIdentifier(identifier);

    SequenceOffer offer = cs.getSequenceOffer();
    if (offer != null) {
      String outSequenceId = offer.getIdentifer().getIdentifier();

      if (outSequenceId != null && !"".equals(outSequenceId)) {

        Accept accept = new Accept(namespace);

        // Putting the To EPR as the AcksTo for the response sequence. We echo back the
        // addressing version that the create used.
        String addressingNamespace = cs.getAddressingNamespaceValue();
        EndpointReference acksToEPR = createSeqMessage.getTo();
        if(acksToEPR != null) {
          acksToEPR = SandeshaUtil.cloneEPR(acksToEPR);
        } else {
          String anon = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
          acksToEPR = new EndpointReference(anon);
        }
       
        AcksTo acksTo = new AcksTo(acksToEPR, namespace, cs.getAddressingNamespaceValue());
        accept.setAcksTo(acksTo);
        response.setAccept(accept);
      }
    }

View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

      throw new AxisFault(message);
    }

    EndpointReference replyTo = createSequenceMsg.getReplyTo();

    CreateSequence createSequence = (CreateSequence) createSequenceMsg
        .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
    if (createSequence == null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
      log.debug(message);
      throw new AxisFault(message);
    }

    EndpointReference acksTo = createSequence.getAcksTo().getEPR();

    if (acksTo == null) {
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence), new Exception());
    } else if (acksTo.getAddress().equals(AddressingConstants.Final.WSA_NONE_URI)){
      FaultManager.makeCreateSequenceRefusedFault(createSequenceMsg, "AcksTo can not be " + AddressingConstants.Final.WSA_NONE_URI, new Exception());
    }

    MessageContext createSeqContext = createSequenceMsg.getMessageContext();
   
    // If this create is the result of a MakeConnection, then we must have a related
    // outbound sequence.
    SequenceEntry entry = (SequenceEntry) createSeqContext.getProperty(Sandesha2Constants.MessageContextProperties.MAKECONNECTION_ENTRY);
    if(log.isDebugEnabled()) log.debug("This message is associated with sequence entry: " + entry);
    if(entry != null && entry.isRmSource()) {
      rmdBean.setOutboundInternalSequence(entry.getSequenceId());
    }

    rmdBean.setServerCompletedMessages(new RangeString());
   
    rmdBean.setReplyToEPR(to.getAddress());
    rmdBean.setAcksToEPR(acksTo.getAddress());

    // If no replyTo value. Send responses as sync.
    if (replyTo != null)
      rmdBean.setToEPR(replyTo.getAddress());

    // Store the security token alongside the sequence
    if(token != null) {
      String tokenData = securityManager.getTokenRecoveryData(token);
      rmdBean.setSecurityTokenData(tokenData);
    }   
   
    rmdBean.setSequenceID(sequenceId);
    rmdBean.setNextMsgNoToProcess(1);
   
    rmdBean.setToAddress(to.getAddress());
   
    // If this sequence has a 'To' address that is anonymous then we must have got the
    // message as a response to a poll. We need to make sure that we keep polling until
    // the sequence is closed.
    if(to.hasAnonymousAddress()) {
      String newKey = SandeshaUtil.getUUID();
      rmdBean.setPollingMode(true);
      rmdBean.setReferenceMessageKey(newKey);
      storageManager.storeMessageContext(newKey, createSeqContext);
    }

    String messageRMNamespace = createSequence.getNamespaceValue();

    String specVersion = null;
    if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(messageRMNamespace)) {
      specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
    } else if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(messageRMNamespace)) {
View Full Code Here

Examples of org.apache.sandesha2.wsrm.CreateSequence

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);

    String addressingNamespaceValue = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
        Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);

    CreateSequence createSequencePart = new CreateSequence(rmNamespaceValue, addressingNamespaceValue);

    // Adding sequence offer - if present
    OperationContext operationcontext = applicationMsgContext.getOperationContext();
    if (operationcontext != null) {
      String offeredSequence = (String) applicationMsgContext
          .getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
      EndpointReference offeredEndpoint = (EndpointReference) applicationMsgContext
          .getProperty(SandeshaClientConstants.OFFERED_ENDPOINT);
     
      if (offeredEndpoint==null) {
        EndpointReference replyTo = applicationMsgContext.getReplyTo()//using replyTo as the Endpoint if it is not specified
       
        if (replyTo!=null)
          offeredEndpoint = SandeshaUtil.cloneEPR(replyTo);
      }
     
      if (offeredSequence != null && !"".equals(offeredSequence)) {
        SequenceOffer offerPart = new SequenceOffer(rmNamespaceValue);
        Identifier identifier = new Identifier(rmNamespaceValue);
        identifier.setIndentifer(offeredSequence);
        offerPart.setIdentifier(identifier);
        createSequencePart.setSequenceOffer(offerPart);
       
        if (Sandesha2Constants.SPEC_2006_08.NS_URI.equals(rmNamespaceValue)) {
          if (offeredEndpoint!=null) {
            Endpoint endpoint = new Endpoint (rmNamespaceValue,addressingNamespaceValue);
            endpoint.setEPR (offeredEndpoint);
            offerPart.setEndpoint(endpoint);
          } else {
            String message = SandeshaMessageHelper.getMessage(
                SandeshaMessageKeys.invalidOfferNoResponseEndpoint);
            throw new SandeshaException (message);
          }
        }
      }
    }

    String to = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
                    Sandesha2Constants.SequenceProperties.TO_EPR,storageManager);
    String replyTo = SandeshaUtil.getSequenceProperty(sequencePropertyKey,
         Sandesha2Constants.SequenceProperties.REPLY_TO_EPR,storageManager);
   
    if (replyTo==null) {
      //using wsa:Anonymous as ReplyTo
     
      String addressingNamespace = applicationRMMsg.getAddressingNamespaceValue();
      if (AddressingConstants.Submission.WSA_NAMESPACE.equals(addressingNamespace))
        replyTo = AddressingConstants.Submission.WSA_ANONYMOUS_URL;
      else
        replyTo = AddressingConstants.Final.WSA_ANONYMOUS_URL;
    }
   
    if (to==null) {
      String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toBeanNotSet);
      throw new SandeshaException (message);
    }
   
    //TODO store and retrieve a full EPR instead of just the address.
    EndpointReference toEPR = new EndpointReference (to);
    EndpointReference replyToEPR = new EndpointReference (replyTo);
   
    createSeqRMMsg.setTo(toEPR);
    createSeqRMMsg.setReplyTo(replyToEPR);
   
    String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceValue);

    if (acksToEPR==null || acksToEPR.getAddress() == null || "".equals(acksToEPR.getAddress()))
      acksToEPR = new EndpointReference(anonymousURI);

    AcksTo acksTo = new AcksTo(acksToEPR,rmNamespaceValue,addressingNamespaceValue);
    createSequencePart.setAcksTo(acksTo);
   
    // Find the token that should be used to secure this new sequence. If there is a token, then we
    // save it in the properties so that the caller can store the token within the create sequence
    // bean.
    SecurityManager secMgr = SandeshaUtil.getSecurityManager(context);
    SecurityToken token = secMgr.getSecurityToken(createSeqmsgContext);
    if(token != null) {
      OMElement str = secMgr.createSecurityTokenReference(token, createSeqmsgContext);
      createSequencePart.setSecurityTokenReference(str);
      createSeqRMMsg.setProperty(Sandesha2Constants.SequenceProperties.SECURITY_TOKEN, token);
     
      //adding the UseSequenceSTR header
      SOAPFactory createSeqFactory = (SOAPFactory) createSeqRMMsg.getSOAPEnvelope().getOMFactory();
      OMNamespace namespace = createSeqFactory.createOMNamespace(Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM, createSeqRMMsg.getRMNamespaceValue());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.