Package org.apache.ws.sandbox.security.conversation.message.token

Examples of org.apache.ws.sandbox.security.conversation.message.token.DerivedKeyToken


                        ref.getURI());
                if (ele == null) {
                    throw new ConversationException("Cannot find  referenced Derived Key");
                }
                String uuid = null;
                DerivedKeyToken dkToken = null;
                try {
                    dkToken = new DerivedKeyToken(ele)//Cover the 'Element' into 'DerivedKeyToken' object
                    if (dkToken.getSecuityTokenReference() == null) {
                        //if dkToken doesn't have a STR find a SecurityContextToken in the SOAP Envelope
                        SecurityContextToken secContextTk =
                            ConversationUtil.getSCT(dkToken);
                        uuid = secContextTk.getIdentifier();
                        log.debug(
                            "ConversationEngine :: The uuid is found " + uuid);
                        DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                        dkcbHandler.addDerivedKey(uuid, dkInfo);
                    } else { ///i.e. dkToken has a STR
                        SecurityTokenReference str2Base =
                            dkToken.getSecuityTokenReference();
                        if (str2Base.containsReference()) {
                            Reference ref2Base = str2Base.getReference();

                            if (ref2Base
                                .getValueType()
                                .equals("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID")) {
                                /* ok now I have a SAML token. What should I do ?
                                 * -Decrypt the secret.
                                 * -create tempUUID
                                 * -add the scTInfo into dkcbHandler
                                 * -add the derived key token to dkcbHandler.
                                 */
                               uuid = ref2Base.getURI();
                            if(dkcbHandler.getSession(uuid)==null){
                        byte[] key = handleSAML(ref2Base.getElement().getOwnerDocument(), uuid);
                   System.out.println("I am here :-)");
                   SecurityContextInfo sctInfo = new SecurityContextInfo(
                                     uuid,
                                     key,
                                     1);
                   dkcbHandler.addSecurtiyContext(
                                     uuid,
                                     sctInfo);
                 }
                  DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                  dkcbHandler.addDerivedKey(uuid, dkInfo);
                            }



                            //TODO :: Add other tokens else if
                        } else if(str2Base.containsKeyIdentifier()){
                          Element elem = str2Base.getFirstElement();
                          //.getKeyIdentifier()System.out.println("KeyIdentifier :: He ehee ........");
              String value = elem.getAttribute("ValueType");
              if("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID".equals(value)){
                uuid = ((Text)elem.getChildNodes().item(0)).getNodeValue();
                if(dkcbHandler.getSession(uuid)==null){
                     byte[] key = handleSAML(elem.getOwnerDocument(), uuid);
                     System.out.println("UUID of SAML is"+uuid);
                     SecurityContextInfo sctInfo = new SecurityContextInfo(
                                                     uuid,
                                                     key,
                                                     1);
                     dkcbHandler.addSecurtiyContext(uuid,sctInfo);
                }
                DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                dkcbHandler.addDerivedKey(uuid, dkInfo);
              }

                        }else{
                            throw new ConversationException("Cannot handle this type of security token reference: " + dkToken.getSecuityTokenReference().getReference().getValueType());
                        }
                    } //////end :if dkToken has a STR
                    //TODO :: Ask ruchith to throw correct exception
                } catch (WSSecurityException e2) {
                    e2.printStackTrace();
                } catch (ConversationException e2) {
                    e2.printStackTrace();
                }

                String identifier =
                    ConversationUtil.generateIdentifier(uuid, dkToken.getID());
                WSPasswordCallback pwCb =
                    new WSPasswordCallback(
                        identifier,
                        WSPasswordCallback.UNKNOWN);
                Callback[] callbacks = new Callback[1];
View Full Code Here


            /* check token type: We support Derivedkey tokens now.
             * We will support security context tokens.
             */
            QName el = new QName(token.getNamespaceURI(), token.getLocalName());
            if (el.equals(DERIVEDKEY_TOKEN)) {
                DerivedKeyToken dkToken = new DerivedKeyToken(token);
                DerivedKeyInfo dkInfo = null;

        String uuid = null;

                try {
          if (dkToken.getSecuityTokenReference() == null) {
            //if dkToken doesn't have a STR
            SecurityContextToken secContextTk =
              ConversationUtil.getSCT(dkToken);
            uuid = secContextTk.getIdentifier();
            log.debug(
              "ConversationEngine :: The uuid is found " + uuid);
            dkInfo = new DerivedKeyInfo(dkToken);
            dkcbHandler.addDerivedKey(uuid, dkInfo);
          } else { ///i.e. dkToken has a STR
            SecurityTokenReference str2Base =
              dkToken.getSecuityTokenReference();
            if (str2Base.containsReference()) {
              Reference ref2Base = str2Base.getReference();
                          //TODO:: Find where can I find the constants.
              if (ref2Base
                .getValueType()
                .equals("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID")) {
                /* ok now I have a SAML token. What should I do ?
                 * -Decrypt the secret.
                 * -create tempUUID
                 * -add the scTInfo into dkcbHandler
                 * -add the derived key token to dkcbHandler.
                 */
                uuid = ref2Base.getURI();
                if(dkcbHandler.getSession(uuid)==null){
                  byte[] key = handleSAML(docSig, uuid);
                  System.out.println("I am here :-)");
                  SecurityContextInfo sctInfo =
                  new SecurityContextInfo(
                    uuid,
                    key,
                    1);
                  dkcbHandler.addSecurtiyContext(
                    uuid,
                  sctInfo);
                }
                  dkInfo = new DerivedKeyInfo(dkToken);
                  dkcbHandler.addDerivedKey(uuid, dkInfo);
                }
            } else if(str2Base.containsKeyIdentifier()){
                          Element elem = str2Base.getFirstElement();
                          //.getKeyIdentifier()System.out.println("KeyIdentifier :: He ehee ........");
                          String value = elem.getAttribute("ValueType");
                if("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID".equals(value)){
                  uuid = ((Text)elem.getChildNodes().item(0)).getNodeValue();
                  if(dkcbHandler.getSession(uuid)==null){
                     byte[] key = handleSAML(elem.getOwnerDocument(), uuid);
                     System.out.println("UUID of SAML is"+uuid);
                     SecurityContextInfo sctInfo = new SecurityContextInfo(uuid,key,1);
                     dkcbHandler.addSecurtiyContext(uuid,sctInfo);
                  }
                dkInfo = new DerivedKeyInfo(dkToken);
                dkcbHandler.addDerivedKey(uuid, dkInfo);
                }

            } else {
              throw new ConversationException("Don't know how to process here");
            }

          }
                //String uuid = "aNewUuid";
                String dkId = dkToken.getID();
                userName = ConversationUtil.generateIdentifier(uuid, dkId);
                convResult =
                    new ConvEngineResult(ConvEngineResult.SIGN_DERIVED_KEY);
                    dkcbHandler.addDerivedKey(uuid, dkInfo);
                    log.debug(
View Full Code Here

        WSSecurityUtil.setNamespace(stRef.getElement(),
                WSConstants.WSSE_NS,
                WSConstants.WSSE_PREFIX);

        // step 2 :Create the DerriveToken
        DerivedKeyToken dtoken = new DerivedKeyToken(doc);
    if(stRef2Base != null){
      dtoken.setSecuityTokenReference(doc, stRef2Base);
    }
        dtoken.setLabel(doc, "WS-SecureConversationWS-SecureConversation");
        dtoken.setNonce(doc, ConversationUtil.generateNonce(128));
        dtoken.setID(genID);
    //System.out.println("Fix me here ....");
   
    if(keyLen!=-1){
       dtoken.setLength(doc,keyLen);
    }
       
        //step 3 :add the derived key token infomation into the dkcbHandler
        DerivedKeyInfo dkInfo = null;
        try {
View Full Code Here

        WSSecurityUtil.setNamespace(stRef.getElement(),
                WSConstants.WSSE_NS,
                WSConstants.WSSE_PREFIX);

        // step 2 :Create the DerriveToken
        DerivedKeyToken dtoken = new DerivedKeyToken(doc);
    if(stRef2Base != null){
      dtoken.setSecuityTokenReference(doc, stRef2Base);
    }
        dtoken.setLabel(doc, "WS-SecureConversationWS-SecureConversation");
        dtoken.setNonce(doc, ConversationUtil.generateNonce(128));
        dtoken.setID(genID);
    //System.out.println("Fix me here ....");
   
    if(keyLen!=-1){
       dtoken.setLength(doc,keyLen);
    }
       
        //step 3 :add the derived key token infomation into the dkcbHandler
        DerivedKeyInfo dkInfo = null;
        try {
View Full Code Here

                        ref.getURI());
                if (ele == null) {
                    throw new ConversationException("Cannot find  referenced Derived Key");
                }
                String uuid = null;
                DerivedKeyToken dkToken = null;
                try {
                    dkToken = new DerivedKeyToken(ele)//Cover the 'Element' into 'DerivedKeyToken' object
                    if (dkToken.getSecuityTokenReference() == null) {
                        //if dkToken doesn't have a STR find a SecurityContextToken in the SOAP Envelope
                        SecurityContextToken secContextTk =
                            ConversationUtil.getSCT(dkToken);
                        uuid = secContextTk.getIdentifier();
                        log.debug(
                            "ConversationEngine :: The uuid is found " + uuid);
                        DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                        dkcbHandler.addDerivedKey(uuid, dkInfo);
                    } else { ///i.e. dkToken has a STR
                        SecurityTokenReference str2Base =
                            dkToken.getSecuityTokenReference();
                        if (str2Base.containsReference()) {
                            Reference ref2Base = str2Base.getReference();

                            if (ref2Base
                                .getValueType()
                                .equals("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID")) {
                                /* ok now I have a SAML token. What should I do ?
                                 * -Decrypt the secret.
                                 * -create tempUUID
                                 * -add the scTInfo into dkcbHandler
                                 * -add the derived key token to dkcbHandler.
                                 */
                               uuid = ref2Base.getURI();
                            if(dkcbHandler.getSession(uuid)==null){
                        byte[] key = handleSAML(ref2Base.getElement().getOwnerDocument(), uuid);
                   System.out.println("I am here :-)");
                   SecurityContextInfo sctInfo = new SecurityContextInfo(
                                     uuid,
                                     key,
                                     1);
                   dkcbHandler.addSecurtiyContext(
                                     uuid,
                                     sctInfo);
                 }
                  DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                  dkcbHandler.addDerivedKey(uuid, dkInfo);
                            }



                            //TODO :: Add other tokens else if
                        } else if(str2Base.containsKeyIdentifier()){
                          Element elem = str2Base.getFirstElement();
                          //.getKeyIdentifier()System.out.println("KeyIdentifier :: He ehee ........");
              String value = elem.getAttribute("ValueType");
              if("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID".equals(value)){
                uuid = ((Text)elem.getChildNodes().item(0)).getNodeValue();
                if(dkcbHandler.getSession(uuid)==null){
                     byte[] key = handleSAML(elem.getOwnerDocument(), uuid);
                     System.out.println("UUID of SAML is"+uuid);
                     SecurityContextInfo sctInfo = new SecurityContextInfo(
                                                     uuid,
                                                     key,
                                                     1);
                     dkcbHandler.addSecurtiyContext(uuid,sctInfo);
                }
                DerivedKeyInfo dkInfo = new DerivedKeyInfo(dkToken);
                dkcbHandler.addDerivedKey(uuid, dkInfo);
              }

                        }else{
                            throw new ConversationException("Cannot handle this type of security token reference: " + dkToken.getSecuityTokenReference().getReference().getValueType());
                        }
                    } //////end :if dkToken has a STR
                    //TODO :: Ask ruchith to throw correct exception
                } catch (WSSecurityException e2) {
                    e2.printStackTrace();
                } catch (ConversationException e2) {
                    e2.printStackTrace();
                }

                String identifier =
                    ConversationUtil.generateIdentifier(uuid, dkToken.getID());
                WSPasswordCallback pwCb =
                    new WSPasswordCallback(
                        identifier,
                        WSPasswordCallback.UNKNOWN);
                Callback[] callbacks = new Callback[1];
View Full Code Here

            /* check token type: We support Derivedkey tokens now.
             * We will support security context tokens.
             */
            QName el = new QName(token.getNamespaceURI(), token.getLocalName());
            if (el.equals(DERIVEDKEY_TOKEN)) {
                DerivedKeyToken dkToken = new DerivedKeyToken(token);
                DerivedKeyInfo dkInfo = null;

        String uuid = null;

                try {
          if (dkToken.getSecuityTokenReference() == null) {
            //if dkToken doesn't have a STR
            SecurityContextToken secContextTk =
              ConversationUtil.getSCT(dkToken);
            uuid = secContextTk.getIdentifier();
            log.debug(
              "ConversationEngine :: The uuid is found " + uuid);
            dkInfo = new DerivedKeyInfo(dkToken);
            dkcbHandler.addDerivedKey(uuid, dkInfo);
          } else { ///i.e. dkToken has a STR
            SecurityTokenReference str2Base =
              dkToken.getSecuityTokenReference();
            if (str2Base.containsReference()) {
              Reference ref2Base = str2Base.getReference();
                          //TODO:: Find where can I find the constants.
              if (ref2Base
                .getValueType()
                .equals("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID")) {
                /* ok now I have a SAML token. What should I do ?
                 * -Decrypt the secret.
                 * -create tempUUID
                 * -add the scTInfo into dkcbHandler
                 * -add the derived key token to dkcbHandler.
                 */
                uuid = ref2Base.getURI();
                if(dkcbHandler.getSession(uuid)==null){
                  byte[] key = handleSAML(docSig, uuid);
                  System.out.println("I am here :-)");
                  SecurityContextInfo sctInfo =
                  new SecurityContextInfo(
                    uuid,
                    key,
                    1);
                  dkcbHandler.addSecurtiyContext(
                    uuid,
                  sctInfo);
                }
                  dkInfo = new DerivedKeyInfo(dkToken);
                  dkcbHandler.addDerivedKey(uuid, dkInfo);
                }
            } else if(str2Base.containsKeyIdentifier()){
                          Element elem = str2Base.getFirstElement();
                          //.getKeyIdentifier()System.out.println("KeyIdentifier :: He ehee ........");
                          String value = elem.getAttribute("ValueType");
                if("http://docs.oasis-open.org/wss/2004/XX/oasis-2004XX-wss-saml-token-profile-1.0#SAMLAssertionID".equals(value)){
                  uuid = ((Text)elem.getChildNodes().item(0)).getNodeValue();
                  if(dkcbHandler.getSession(uuid)==null){
                     byte[] key = handleSAML(elem.getOwnerDocument(), uuid);
                     System.out.println("UUID of SAML is"+uuid);
                     SecurityContextInfo sctInfo = new SecurityContextInfo(uuid,key,1);
                     dkcbHandler.addSecurtiyContext(uuid,sctInfo);
                  }
                dkInfo = new DerivedKeyInfo(dkToken);
                dkcbHandler.addDerivedKey(uuid, dkInfo);
                }

            } else {
              throw new ConversationException("Don't know how to process here");
            }

          }
                //String uuid = "aNewUuid";
                String dkId = dkToken.getID();
                userName = ConversationUtil.generateIdentifier(uuid, dkId);
                convResult =
                    new ConvEngineResult(ConvEngineResult.SIGN_DERIVED_KEY);
                    dkcbHandler.addDerivedKey(uuid, dkInfo);
                    log.debug(
View Full Code Here

TOP

Related Classes of org.apache.ws.sandbox.security.conversation.message.token.DerivedKeyToken

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.