Package org.apache.axis

Examples of org.apache.axis.SOAPPart


            handShakeDone = true;

        } else { // handshake is done.

            log.debug("Token in memory .");
            SOAPPart sPart = (org.apache.axis.SOAPPart) sm.getSOAPPart();
            try {
                doc =
                    ((org.apache.axis.message.SOAPEnvelope) sPart
                        .getEnvelope())
                        .getAsDocument();
            } catch (Exception e) {
                throw new AxisFault("CoversationClientHandler :: Cannot get the document");
            }

            try {

                //        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
                    DerivedKeyInfo dkInfo =
                        manager.createDerivedKeyToken(doc, uuid, dkcbHandler,null, 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, null,(String)this.configurator.get(ConvHandlerConstants.DK_ENC_ALGO));
                    } else if(actionsInt[i]==ConversationConstants.DK_SIGN){
                      //TODO:
                        manager.performDK_Sign(doc, dkcbHandler, uuid, dkInfo, null);
                    }
                   
                    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);

        }

    }
View Full Code Here


    if(!isSessionInfoConfigured){
      initSessionInfo();
      isSessionInfoConfigured = true;
    }
        Message message = msgContext.getCurrentMessage();
        SOAPPart sPart = (org.apache.axis.SOAPPart) message.getSOAPPart();
//        if (!this.readCrypto) {
//            this.loadCrypto();
//        }
       
        Object obj = null;
        if((obj=msgContext.getProperty(ConvHandlerConstants.DK_CB_HANDLER))!=null){
          this.dkcbHandler = (DerivedKeyCallbackHandler)obj;
        }
        try {
            doc =
                ((org.apache.axis.message.SOAPEnvelope) sPart.getEnvelope())
                    .getAsDocument();

        } catch (Exception e) {
            throw new AxisFault(
                "WSDoAllSender: cannot get SOAP envlope from message" + e);
        }

        /*Get the derved key tokens.
         *Add them to the convSession.
         */

        log.debug("I am in ClientHandler Response");
       
       
        try{
        ConversationEngine convEng = new ConversationEngine(this.configurator);
    Vector results = convEng.processSecConvHeader(doc, "", dkcbHandler, (String)this.configurator.get(WSHandlerConstants.PW_CALLBACK_CLASS));
        } catch (ConversationException e1) {
          e1.printStackTrace();
          throw new AxisFault("CovnersationServerHandler :: "+e1.getMessage());
        }
       
       

//stolen from WSDoallReciever
  ByteArrayOutputStream os = new ByteArrayOutputStream();
      XMLUtils.outputDOM(doc, os, true);
      sPart.setCurrentMessage(os.toByteArray(), SOAPPart.FORM_BYTES);

      ArrayList processedHeaders = new ArrayList();
          Iterator iterator = message.getSOAPEnvelope().getHeaders().iterator();
          while (iterator.hasNext()) {
            org.apache.axis.message.SOAPHeaderElement tempHeader = (org.apache.axis.message.SOAPHeaderElement) iterator.next();
View Full Code Here

     * @param sm
     * @throws AxisFault
     */
    private void doHandshake_Direct_Generated(Message sm) throws AxisFault {
        Document doc = null;
        SOAPPart sPart = (org.apache.axis.SOAPPart) sm.getSOAPPart();
        try {

            log.debug("ConversationClientHandler :: Trust Not required");
            doc =
                ((org.apache.axis.message.SOAPEnvelope) sPart.getEnvelope())
                    .getAsDocument();
            this.initSessionInfo();
            this.stRes = new RequestSecurityTokenResponse(doc, true);

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

        /*
         * SCT is now created.
         * Steps::
         * 1)
         * 2)SCTInfo in dkcbHandler
         */
        uuid = stRes.getRequestedSecurityToken().getSct().getIdentifier();

        stRes.build(doc);
        isSCTavailabe = true;

        //Now encrypting with the base token
        RequestedProofToken reqProof = stRes.getRequestedProofToken();

        try {
            reqProof.doEncryptProof(doc, this.serverCrypto, this.serverAlias);

            SecurityContextInfo info =
                new SecurityContextInfo(
                    stRes.getRequestedSecurityToken().getSct(),
                    reqProof,
                    ((Integer) (configurator
                        .get(ConvHandlerConstants.KEY_FREQ)))
                        .intValue());

            dkcbHandler.addSecurtiyContext(uuid, info);
            /*
             * Add session specific information to the dkcbHandler
             * 1) Key frequency.
             */
            if (usedFixedKeys == true) {
        Long ln = new Long((String)Integer.toString(keyLen));
                dkcbHandler.setDerivedKeyLength(uuid, ln.longValue() );
            }
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            XMLUtils.outputDOM(doc, os, true);
            String osStr = os.toString();
            sPart.setCurrentMessage(osStr, SOAPPart.FORM_STRING);
        } catch (WSSecurityException e2) {
            e2.printStackTrace();
            throw new AxisFault(
                "ConversationClientHandler ::" + e2.getMessage());
        } catch (ConversationException e2) {
View Full Code Here

                            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

                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 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);
                }
            }
            if (tlog.isDebugEnabled()) {
                t1 = System.currentTimeMillis();
            }

            doSenderAction(doAction, doc, reqData, actions, !mc.getPastPivot());
           
            if (tlog.isDebugEnabled()) {
                t2 = System.currentTimeMillis();
            }

            /*
             * 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

            /*
            * 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

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.