Package org.apache.axis

Examples of org.apache.axis.SOAPPart


                            rstr.addChild(tmpEle);
                            shSecElem.addChildElement(rstr);
                        }
                    }
                } else if (el.equals(RequestedProofToken.TOKEN)) {
                    SOAPPart sPart =
                        (org.apache.axis.SOAPPart) sm.getSOAPPart();
                    doc =
                        ((org.apache.axis.message.SOAPEnvelope) sPart
                            .getEnvelope())
                            .getAsDocument();
                    //do decrytion - proof is encrypted with certificate of STS
                    proof = new RequestedProofToken(domEle);
            
            
                    proof.doDecryption(callbackHandler, serverCrypto);

                    byte[] bkArr = proof.getSharedSecret();
                    RequestedProofToken newProof = new RequestedProofToken(doc);
                    newProof.setSharedSecret(bkArr);
                    newProof.doEncryptProof(
                        doc,
                        serverCrypto,
                        this.serverAlias);

                    Element secHeader =
                        WSSecurityUtil.findWsseSecurityHeaderBlock(WSSConfig.getDefaultWSConfig(),
                            doc,
                            doc.getDocumentElement(),
                            true);

                    Element ele =
                        (Element) WSSecurityUtil.findElement(
                            secHeader,
                            RequestSecurityTokenResponse.TOKEN.getLocalPart(),
                            RequestSecurityTokenResponse
                                .TOKEN
                                .getNamespaceURI());

                    ele.appendChild(newProof.getElement());

                    ByteArrayOutputStream os = new ByteArrayOutputStream();
                    XMLUtils.outputDOM(doc, os, true);
                    String osStr = os.toString();
                    sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);

                }

            } //for loop
View Full Code Here


        Document doc = null;
        Message message = msg.getCurrentMessage();

        // Get the soap message as a Docuemnt
        SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
        try {
            doc =
                    ((org.apache.axis.message.SOAPEnvelope) sPart.getEnvelope())
                    .getAsDocument();
        } catch (Exception e) {
            e.printStackTrace();
        }

//    if((this.configurator = (HashMap)msg.getProperty("PolicyObject"))==null){
//      log.debug("ConversationServerHandler :: I am configuring");
//           initSessionInfo(); // load values to this.configurator from wsdd
//    }

        soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
        ConversationEngine eng = new ConversationEngine(this.configurator);

//    try {
//            boolean trustEngineResult = false;
//                if(!isInitTrustVerified){
//                String tmpStr = null;
//                  if ((tmpStr = (String) getOption(ConvHandlerConstants.TOKEN_TRUST_VERIFY))
//                        != null) {
//                  if(Boolean.getBoolean(tmpStr)){
//                    String trustPropFile = (String) getOption(ConvHandlerConstants.TRUST_ENGINE_PROP);
//                    TrustEngine trstEngine = new TrustEngine(trustPropFile);
//                    System.out.println("call the engine here ...");
//                    trustEngineResult=true;
//                  }
//                  isInitTrustVerified = true;
//                        }
//                }
//            if(trustEngineResult){
//                 //getUUID and proof of possession
//                 //add it to the derived key token
//            }
//        } catch (WSTrustException e2) {
//            // TODO Auto-generated catch block
//            e2.printStackTrace();
//        }



        try {
            Vector results = eng.processSecConvHeader(doc, "", dkcbHandler, (String)this.configurator.get(WSHandlerConstants.PW_CALLBACK_CLASS));
            ConvEngineResult convResult  = null;
            String uuid = "";

            /*put the actions into a stack to obtain LIFO behavior
            * Rational for using the stack;
            *
            * Consider "Signature Encrypt"
            * Then the ConvEngine Results will be in the order "Encrypt Signature"
            * i.e. ConvEngine reusult containing ConvEngineResult.ENCRYPT_DERIVED_KEY
            * will be before ConvEngineResult.SIGN_DERIVED_KEY
            *
            * Hense I need to read actions in the order of Last in First out - the stack
            *
            * This is same for "Encrypt Signature" visa versa.
            */
            Stack stk = new Stack();
            for(int i=0; i<actionsInt.length ; i++){
                stk.push(new Integer(actionsInt[i]));
            }
            int act = -1;
            boolean rstr = false;
            for(int i=0; i<results.size(); i++){
                convResult=(ConvEngineResult)results.get(i);

                switch(convResult.getAction()){

                    case ConvEngineResult.SECURITY_TOKEN_RESPONSE :
                        log.debug("ConversationServerHandler :: Found RSTR result");
                        uuid = convResult.getUuid();
                        rstr = true;
                        break;

                    case ConvEngineResult.ENCRYPT_DERIVED_KEY :
                        log.debug("ConversationServerHandler :: Found dk_encrypt result");
//            if(stk.isEmpty()){
//              throw new AxisFault("Action mismatch");
//            }
//
//            act =((Integer)stk.pop()).intValue();
//            if(act == ConversationConstants.DK_ENCRYPT){
//              //fine do nothing
//            }else{
//              throw new AxisFault("Mismatch action order");
//            }
                        break;

                    case ConvEngineResult.SIGN_DERIVED_KEY :
                        log.debug("ConversationServerHandler :: Found dk_sign result");
//          if(stk.isEmpty()){
//            throw new AxisFault("Action mismatch");
//          }
//          act =((Integer)stk.pop()).intValue();
//          if(act == ConversationConstants.DK_SIGN){
//              //fine do nothing
//          }else{
//            throw new AxisFault("Mismatch action order");
//          }
                        break;

                    case ConvEngineResult.SCT :
                        log.debug("ConversationServerHandler :: Found SCT result");
                        uuid = convResult.getUuid();
                        break;

                }
            }

            if(uuid.equals("")||(uuid==null)){
                //throw new AxisFault("ConversationServerHandler :: Cannot find Session.");
            }else{
                msg.setProperty(ConversationConstants.IDENTIFIER,uuid);
            }

//
//        if(!rstr){
//        if(!stk.isEmpty()){
//        throw new AxisFault("Action mismatch. Required action missing");
//      }
//            }


        } catch (ConversationException e1) {
            e1.printStackTrace();
            throw new AxisFault("CovnersationServerHandler :: "+e1.getMessage());
        }



        // Replace sPart with the new sPart.
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        XMLUtils.outputDOM(doc, os, true);
        String osStr = os.toString();
        sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);

        //Following sets the headers as processed.
        SOAPHeader sHeader = null;
        try {
            sHeader = message.getSOAPEnvelope().getHeader();
View Full Code Here

        //System.out.println("Doing response .... ");
        Document doc = null;
        Message message = msg.getCurrentMessage();
        String uuid, identifier;
        //  Code to get the soap message as a Docuemnt
        SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();

        try {
            if ((doc = (Document) msg.getProperty(WSHandlerConstants.SND_SECURITY))
                    == null) {
                doc =
                        ((org.apache.axis.message.SOAPEnvelope) sPart.getEnvelope())
                        .getAsDocument();
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new AxisFault("CovnersationServerHandler :: "+e.getMessage());
        }

        //get the uuid
        uuid = (String) msg.getProperty(ConversationConstants.IDENTIFIER);

        if (uuid == null) {
            //TODO :: throw exception
            System.out.println("UUID NULl line :: 346");
        }


        try {
            ConversationSession session = dkcbHandler.getSession(uuid);

            if(session.isAddBase2Message()){
                //add the relavent SCT
                Element securityHeader =
                        WSSecurityUtil.findWsseSecurityHeaderBlock(WSSConfig.getDefaultWSConfig(),
                                doc,
                                doc.getDocumentElement(),
                                true);
                WSSecurityUtil.appendChildElement(
                        doc,
                        securityHeader,
                        (new SecurityContextToken(doc, uuid)).getElement());
            }

            ConversationManager manager = new ConversationManager();

            for (int i = 0; i < this.actionsInt.length; i++) {

                // Derrive the token
                SecurityTokenReference stRef2Base = null;
                if(session.getRef2Base()==null){
                    //do nothing
                }else{
                    stRef2Base = new SecurityTokenReference(WSSConfig.getDefaultWSConfig(),doc);
                    Reference ref = new Reference(WSSConfig.getDefaultWSConfig(),doc);
                    Reference oldRef = session.getRef2Base();

                    ref.setURI(oldRef.getURI());
                    ref.setValueType(oldRef.getValueType());
                    stRef2Base.setReference(ref);
                }
                DerivedKeyInfo dkInfo =
                        manager.createDerivedKeyToken(doc, uuid, dkcbHandler,stRef2Base, keyLen);

                String genID = dkInfo.getId();
                SecurityTokenReference stRef =
                        dkInfo.getSecTokRef2DkToken();

                if (actionsInt[i] == ConversationConstants.DK_ENCRYPT) {
                    manager.performDK_ENCR(
                            ConversationUtil.generateIdentifier(uuid, genID),
                            "",
                            true,
                            doc,
                            stRef,
                            dkcbHandler, this.encParts, (String)this.configurator.get(ConvHandlerConstants.DK_ENC_ALGO));

                } else if(actionsInt[i]==ConversationConstants.DK_SIGN){
                    //TODO
                    manager.performDK_Sign(doc, dkcbHandler, uuid, dkInfo,this.sigParts);
                }

                manager.addDkToken(doc,dkInfo);

            }
        } catch (ConversationException e1) {
            e1.printStackTrace();
            throw new AxisFault(
                    "ConversationClientHandler ::" + e1.getMessage());
        }

        //set it as current message
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        XMLUtils.outputDOM(doc, os, true);
        String osStr = os.toString();
        sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);


    } //doResponse
View Full Code Here

            /*
            * If the message context property conatins a document then this is
            * a chained handler.
            */
            SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
            if ((doc = (Document) ((MessageContext)reqData.getMsgContext())
                    .getProperty(WSHandlerConstants.SND_SECURITY)) == null) {
                try {
                    doc = ((org.apache.axis.message.SOAPEnvelope) sPart
                            .getEnvelope()).getAsDocument();
                } catch (Exception e) {
                    throw new AxisFault(
                            "WSDoAllSender: cannot get SOAP envlope from message"
                                    + e);
                }
            }
            doSenderAction(doAction, doc, reqData, actions);

            /*
                * If required convert the resulting document into a message first.
                * The outputDOM() method performs the necessary c14n call. After
                * that we extract it as a string for further processing.
                *
                * Set the resulting byte array as the new SOAP message.
                *
                * If noSerialization is false, this handler shall be the last (or
                * only) one in a handler chain. If noSerialization is true, just
                * set the processed Document in the transfer property. The next
                * Axis WSS4J handler takes it and performs additional security
                * processing steps.
                *
                */
            if (reqData.isNoSerialization()) {
                ((MessageContext)reqData.getMsgContext()).setProperty(WSHandlerConstants.SND_SECURITY,
                        doc);
            } else {
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                XMLUtils.outputDOM(doc, os, true);
                sPart.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);
                if (doDebug) {
                    String osStr = null;
                    try {
                        osStr = os.toString("UTF-8");
                    } catch (UnsupportedEncodingException e) {
View Full Code Here

                fault.removeFaultDetail(Constants.QNAME_FAULTDETAIL_RUNTIMEEXCEPTION);
            }
            responseMsg = new Message(fault);
        }
        responseMessage = responseMsg;
        SOAPPart soapPart = (SOAPPart) responseMessage.getSOAPPart();
        soapPart.getMessage().setMessageContext(context);
        return responseMessage;
    }
View Full Code Here

        }
        res.setStatusCode(status);
        responseMessage = context.getResponseMessage();
        if (responseMessage == null) {
            responseMessage = new Message(fault);
            SOAPPart soapPart = (SOAPPart) responseMessage.getSOAPPart();
            soapPart.getMessage().setMessageContext(context);
        }
        return responseMessage;
    }
View Full Code Here

            /*
            * If we had some security processing, get the original SOAP part of
            * Axis' message and replace it with new SOAP part. This new part
            * may contain decrypted elements.
            */
            SOAPPart sPart = (org.apache.axis.SOAPPart) sm.getSOAPPart();

            ByteArrayOutputStream os = new ByteArrayOutputStream();
            XMLUtils.outputDOM(doc, os, true);
            sPart.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);
            if (doDebug) {
                log.debug("Processed received SOAP request");
                log.debug(org.apache.axis.utils.XMLUtils
                        .PrettyDocumentToString(doc));
            }
View Full Code Here

        //get the request msg   
        Message smReq = msgCntxt.getRequestMessage();
        //get the response msg
        Message smCurr = msgCntxt.getCurrentMessage();
        //get the request msg as a SOAP part
        SOAPPart sPartReq = (org.apache.axis.SOAPPart) smReq.getSOAPPart();
        //get the response msg as a SOAP part
        SOAPPart sPartRes = (org.apache.axis.SOAPPart) smCurr.getSOAPPart();

        Document docReq, docRes = null;

        try {
            //initialize xml security
            org.apache.xml.security.Init.init();
            docReq = ((SOAPEnvelope) sPartReq.getEnvelope()).getAsDocument();
            docRes = ((SOAPEnvelope) sPartRes.getEnvelope()).getAsDocument();

            ByteArrayOutputStream osReq = new ByteArrayOutputStream();
            XMLUtils.outputDOM(docReq, osReq, true);

            ByteArrayOutputStream osRes = new ByteArrayOutputStream();
            XMLUtils.outputDOM(docRes, osRes, true);
           
            //creates an STSManager and handover server-config.wsdd parameters in a hash table
            log.debug("STSServerHandler: calling STSManager");
            STSManager stsMgr =
                    new STSManager(this.getOptions());
            docRes = stsMgr.handleRequest(docReq, docRes);
            log.debug("STSServerHandler: STSManager has done the job");
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            XMLUtils.outputDOM(docRes, os, true);
            //modify the current message
            sPartRes.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);           
            //set current message to the context
            msgCntxt.setCurrentMessage(sPartRes.getMessage());

        } catch (Exception ex) {
            throw new AxisFault("STSServerHandler-dorequest:Response failed due to a problem in issuence process",
                    ex);
        }
View Full Code Here

          Message smReq = msgCntxt.getRequestMessage();
          //get the response msg
         // Message smCurr = msgCntxt.getCurrentMessage();
       Message smCurr = msgCntxt.getResponseMessage();//.getRequestMessage();
          //get the request msg as a SOAP part
          SOAPPart sPartReq = (org.apache.axis.SOAPPart) smReq.getSOAPPart();
          //get the response msg as a SOAP part
          SOAPPart sPartRes = (org.apache.axis.SOAPPart) smCurr.getSOAPPart();

          Document docReq, docRes = null;

          try {
              //initialize xml security
              org.apache.xml.security.Init.init();
              docReq = ((SOAPEnvelope) sPartReq.getEnvelope()).getAsDocument();
              docRes = ((SOAPEnvelope) sPartRes.getEnvelope()).getAsDocument();

              STSManager stsMgr =
                      new STSManager(this.options);
              docRes = stsMgr.handleRequest(docReq, docRes);
//              log.debug("STSServerHandler: STSManager has done the job");
              ByteArrayOutputStream os = new ByteArrayOutputStream();
              XMLUtils.outputDOM(docRes, os, true);
              //modify the current message
              sPartRes.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);  
              //set current message to the context
        //msgCntxt.setCurrentMessage(sPartRes.getMessage());
        //msgCntxt.setPastPivot(true);
        //msgCntxt.setPastPivot(true);
        msgCntxt.setCurrentMessage(sPartRes.getMessage());
            // msgCntxt.setResponseMessage(sPartRes.getMessage());
      

          } catch (Exception ex) {
              throw new AxisFault("STSServerHandler-dorequest:Response failed due to a problem in issuence process",
View Full Code Here

      /*
       * If the message context property conatins a document then this is
       * a chained handler.
       */
      SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
      if ((doc = (Document) reqData.msgContext
          .getProperty(WSHandlerConstants.SND_SECURITY)) == null) {
        try {
          doc = ((org.apache.axis.message.SOAPEnvelope) sPart
              .getEnvelope()).getAsDocument();
        } catch (Exception e) {
          throw new AxisFault(
              "WSDoAllSender: cannot get SOAP envlope from message"
                  + e);
        }
      }
      reqData.soapConstants = WSSecurityUtil.getSOAPConstants(doc
          .getDocumentElement());
      /*
       * Here we have action, username, password, and actor,
       * mustUnderstand. Now get the action specific parameters.
       */
      if ((doAction & WSConstants.UT) == WSConstants.UT) {
        decodeUTParameter(reqData);
      }
      /*
       * Here we have action, username, password, and actor,
       * mustUnderstand. Now get the action specific parameters.
       */
      if ((doAction & WSConstants.UT_SIGN) == WSConstants.UT_SIGN) {
        decodeUTParameter(reqData);
        decodeSignatureParameter(reqData);
      }
      /*
       * Get and check the Signature specific parameters first because
       * they may be used for encryption too.
       */
      if ((doAction & WSConstants.SIGN) == WSConstants.SIGN) {
        reqData.sigCrypto = loadSignatureCrypto(reqData);
        decodeSignatureParameter(reqData);
      }
      /*
       * If we need to handle signed SAML token then we need may of the
       * Signature parameters. The handle procedure loads the signature
       * crypto file on demand, thus don't do it here.
       */
      if ((doAction & WSConstants.ST_SIGNED) == WSConstants.ST_SIGNED) {
        decodeSignatureParameter(reqData);
      }
      /*
       * Set and check the encryption specific parameters, if necessary
       * take over signature parameters username and crypto instance.
       */
      if ((doAction & WSConstants.ENCR) == WSConstants.ENCR) {
        reqData.encCrypto = loadEncryptionCrypto(reqData);
        decodeEncryptionParameter(reqData);
      }
      /*
       * Here we have all necessary information to perform the requested
       * action(s).
       */
      for (int i = 0; i < actions.size(); i++) {

        int actionToDo = ((Integer) actions.get(i)).intValue();
        if (doDebug) {
          log.debug("Performing Action: " + actionToDo);
        }

        String password = null;
        switch (actionToDo) {
        case WSConstants.UT:
          performUTAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.ENCR:
          performENCRAction(mu, actionToDo, doc, reqData);
          break;

        case WSConstants.SIGN:
          performSIGNAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.ST_SIGNED:
          performST_SIGNAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.ST_UNSIGNED:
          performSTAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.TS:
          performTSAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.UT_SIGN:
          performUT_SIGNAction(actionToDo, mu, doc, reqData);
          break;

        case WSConstants.NO_SERIALIZE:
          reqData.noSerialization = true;
          break;
        }
      }

      /*
       * If required convert the resulting document into a message first.
       * The outputDOM() method performs the necessary c14n call. After
       * that we extract it as a string for further processing.
       *
       * Set the resulting byte array as the new SOAP message.
       *
       * If noSerialization is false, this handler shall be the last (or
       * only) one in a handler chain. If noSerialization is true, just
       * set the processed Document in the transfer property. The next
       * Axis WSS4J handler takes it and performs additional security
       * processing steps.
       * 
       */
      if (reqData.noSerialization) {
        reqData.msgContext.setProperty(WSHandlerConstants.SND_SECURITY,
            doc);
      } else {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        XMLUtils.outputDOM(doc, os, true);
        sPart.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);
        if (doDebug) {
          String osStr = null;
          try {
            osStr = os.toString("UTF-8");
          } catch (UnsupportedEncodingException e) {
View Full Code Here

TOP

Related Classes of org.apache.axis.SOAPPart

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.