Package org.apache.sandesha2

Examples of org.apache.sandesha2.FaultData


        log.debug("Sequence not valid " + sequenceID);

      // Return an UnknownSequence error
      int SOAPVersion = SandeshaUtil.getSOAPVersion(messageContext.getEnvelope());

      FaultData data = new FaultData();
      if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
        data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
      else
        data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

      data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.UNKNOWN_SEQUENCE);

      SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SOAPVersion);

      OMElement identifierElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.IDENTIFIER,
          rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
      identifierElement.setText(sequenceID);
     
      data.setDetail(identifierElement);

      data.setReason(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noSequenceEstablished, sequenceID));

      if (log.isDebugEnabled())
        log.debug("Exit: FaultManager::checkForUnknownSequence");

      return getFault(rmMessageContext, data, rmMessageContext.getAddressingNamespaceValue(), storageManager);
View Full Code Here


              .toString(upper));
        }
      }

      if (invalidAck) {
        FaultData data = new FaultData();
        int SOAPVersion = SandeshaUtil.getSOAPVersion(ackMessageContext.getEnvelope());
        if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
          data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
        else
          data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

        data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.INVALID_ACKNOWLEDGEMENT);
        data.setReason(reason);

        SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SOAPVersion);
        OMElement dummyElement = factory.createOMElement("dummyElem", null);
        sequenceAcknowledgement.toOMElement(dummyElement);

        OMElement sequenceAckElement = dummyElement.getFirstChildWithName(new QName(
            Sandesha2Constants.WSRM_COMMON.SEQUENCE_ACK));
        data.setDetail(sequenceAckElement);

        if (log.isDebugEnabled())
          log.debug("Exit: FaultManager::checkForInvalidAcknowledgement, invalid ACK");
        return getFault(ackRMMessageContext, data, ackRMMessageContext.getAddressingNamespaceValue(),
            storageManager);
View Full Code Here

      sequenceClosed = true;
      reason = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotAcceptMsgAsSequenceClosed, sequenceID);
    }

    if (sequenceClosed) {
      FaultData data = new FaultData();
      int SOAPVersion = SandeshaUtil.getSOAPVersion(referenceMessage.getEnvelope());
      if (SOAPVersion == Sandesha2Constants.SOAPVersion.v1_1)
        data.setCode(SOAP11Constants.FAULT_CODE_SENDER);
      else
        data.setCode(SOAP12Constants.FAULT_CODE_SENDER);

      data.setSubcode(Sandesha2Constants.SOAPFaults.Subcodes.SEQUENCE_CLOSED);
      data.setReason(reason);
     
      SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SOAPVersion);
      String rmNamespaceValue = referenceRMMessage.getRMNamespaceValue();
      OMElement identifierElement = factory.createOMElement(Sandesha2Constants.WSRM_COMMON.IDENTIFIER,
          rmNamespaceValue, Sandesha2Constants.WSRM_COMMON.NS_PREFIX_RM);
      identifierElement.setText(sequenceID);
     
      data.setDetail(identifierElement);

      if (log.isDebugEnabled())
        log.debug("Exit: FaultManager::checkForSequenceClosed, sequence closed");
      return getFault(referenceRMMessage, data, referenceRMMessage.getAddressingNamespaceValue(), storageManager);
    }
View Full Code Here

    MessageContext messageContext = new MessageContext();
    messageContext.setConfigurationContext(serverConfigContext);
    messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));   
    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Create an RMSBean so the create sequence message can be created
    RMSBean rmsBean = new RMSBean();
    rmsBean.setRMVersion(Sandesha2Constants.SPEC_VERSIONS.v1_1);
    rmsBean.setToEPR(to);
    rmsBean.setAcksToEPR(AddressingConstants.Final.WSA_NONE_URI);
       
    // Create a Create Sequence message
    // 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
    createSeqRMMessage.addSOAPEnvelope();

    SOAPEnvelope envelope = createSeqRMMessage.getMessageContext().getEnvelope();
   
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   
    envelope.serialize(outputStream);
   
View Full Code Here

    MessageContext messageContext = new MessageContext();
    messageContext.setConfigurationContext(serverConfigContext);
    messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));   
    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
    msgNumber.setMessageNumber(1);
    sequence.setMessageNumber(msgNumber);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
   
    // Create an RMSBean so the create sequence message can be created
    messageContext.setWSAAction(pingAction);

    // Set the AxisOperation to be InOut
    AxisOperation operation = messageContext.getAxisService().getOperation(Sandesha2Constants.RM_IN_OUT_OPERATION);
    operation.setMessageReceiver(new RMMessageReceiver());
    messageContext.setAxisOperation(operation);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   
    // Serialize the application message
    applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
   
    return outputStream.toByteArray();
  }
View Full Code Here

    }

    rmdBean.setClosed(true);
    storageManager.getRMDBeanMgr().update(rmdBean);

    RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx, rmdBean, sequenceId, storageManager, true);
    // adding the ack part(s) to the envelope.
    Iterator sequenceAckIter = ackRMMsgCtx
        .getMessageParts(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);

    RMMsgContext closeSeqResponseRMMsg = RMMsgCreator.createCloseSeqResponseMsg(rmMsgCtx, rmdBean);
    MessageContext closeSequenceResponseMsg = closeSeqResponseRMMsg.getMessageContext();

    while (sequenceAckIter.hasNext()) {
      SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) sequenceAckIter.next();
      closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,
          sequenceAcknowledgement);
    }
   
    closeSeqResponseRMMsg.setFlow(MessageContext.OUT_FLOW);
    closeSeqResponseRMMsg.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");

    closeSequenceResponseMsg.setResponseWritten(true);

    closeSeqResponseRMMsg.addSOAPEnvelope();
   
    //
    // Now that we have generated the message we can commit the transaction
    //
    if(transaction != null && transaction.isActive()) {
View Full Code Here

   *
   * @return
   * @throws SandeshaException
   */
  public static RMMsgContext initializeMessage(MessageContext ctx) throws AxisFault {
    RMMsgContext rmMsgCtx = new RMMsgContext(ctx);

    populateRMMsgContext(ctx, rmMsgCtx);
    validateMessage(rmMsgCtx);
    return rmMsgCtx;
  }
View Full Code Here

  public void checkProofOfPossession(SecurityToken token, OMElement messagePart,
      MessageContext message) throws SandeshaException {
    log.debug("Enter: UnitTestSecurityManager::checkProofOfPossession");
    if(token == null) {
      throw new SandeshaException("Security manager was passed a null token");
    }
   
    // Look for the header that we should have introduced in the 'apply' method
    String key = ((UnitTestSecurityToken)token).getURI();
    boolean foundToken = false;
    SOAPEnvelope env = message.getEnvelope();
    SOAPHeader headers = env.getHeader();
    if(headers != null) {
      Iterator tokens = headers.getChildrenWithName(unitTestHeader);
      while(tokens.hasNext()) {
        OMElement myHeader = (OMElement) tokens.next();
        String text = myHeader.getText();
        if(key.equals(text)) {
          foundToken = true;
          break;
        }
      }
    }
    if(!foundToken) {
      SandeshaException e = new SandeshaException("Message was not secured with the correct token(s)");
      e.printStackTrace(System.err);
      throw e;
    }

    log.debug("Exit: UnitTestSecurityManager::checkProofOfPossession");
  }
View Full Code Here

  }

  public void applySecurityToken(SecurityToken token, MessageContext outboundMessage) throws SandeshaException {
    log.debug("Enter: UnitTestSecurityManager::applySecurityToken");
    if(token == null) {
      throw new SandeshaException("Security manager was passed a null token");
    }
   
    // Add the header that pretends to secure the message
    String key = ((UnitTestSecurityToken)token).getURI();
    SOAPEnvelope env = outboundMessage.getEnvelope();
View Full Code Here

    if (rmsBean == null)
    {
      if (log.isDebugEnabled())
        log.debug("Exit: WSRMParentProcessor::setupOutMessage Sequence doesn't exist");
     
      throw new SandeshaException(SandeshaMessageHelper.getMessage(
          SandeshaMessageKeys.couldNotSendTerminateSeqNotFound, internalSequenceID));     
    }
   
    if (rmsBean.getSequenceID() != null)
    {
      sequenceExists = true;   
      outSequenceID = rmsBean.getSequenceID();
    }
    else
      outSequenceID = Sandesha2Constants.TEMP_SEQUENCE_ID;     

    rmVersion = rmsBean.getRMVersion();
    if (rmVersion == null)
      throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));

    if (log.isDebugEnabled())
      log.debug("Exit: WSRMParentProcessor::setupOutMessage");
  }
View Full Code Here

TOP

Related Classes of org.apache.sandesha2.FaultData

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.