Examples of XPathContainer


Examples of org.apache.xml.security.transforms.params.XPathContainer

        doc.appendChild(xmlSignature.getElement());
        {
            // ref 0
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            xmlSignature.addDocument("iaikTests.example1.xml", tf);
        }

        {
            // ref 1
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
            xmlSignature.addDocument("iaikTests.example1.xml", tf);
        }

        {
            // ref 2
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            xmlSignature.addDocument("iaikTests.example2.xml", tf);
        }

        {
            // ref 3
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
            xmlSignature.addDocument("iaikTests.example2.xml", tf);
        }

        {
            // ref 4
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:default",
                "http://example.org/default");
                xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
                xc.setXPath(
                "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }

            xmlSignature.addDocument("iaikTests.example3.xml", tf);
        }

        {
            // ref 5
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:default",
                "http://example.org/default");
                xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
                xc.setXPath(
                "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
            xmlSignature.addDocument("iaikTests.example3.xml", tf);
        }

        {
            // ref 6
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            xmlSignature.addDocument("iaikTests.example4.xml", tf);
        }

        {
            // ref 7
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
                xc.setXPath(
                "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            {
                InclusiveNamespaces incNS = new InclusiveNamespaces(doc, "ns2");

                tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS,
                                incNS.getElement());
            }
            xmlSignature.addDocument("iaikTests.example4.xml", tf);
        }

        {
            // ref 8
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object1";

            obj.setId(id);

            String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='uk'>" + "\n"
            + "<included                 >" + "\n" + "</included>"
            + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
            + "\n" + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            // ref apache_8
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 9
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object2";

            obj.setId(id);

            String xmlStr = "" + "<included    xml:lang='uk'>" + "\n"
            + "<notIncluded xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='uk'>" + "\n"
            + "<included                 >" + "\n" + "</included>"
            + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
            + "\n" + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            // ref apache_8
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }
            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 10
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object3";

            obj.setId(id);

            String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='uk'>" + "\n"
            + "<included    xml:lang='de'>" + "\n" + "</included>"
            + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
            + "\n" + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            // ref apache_8
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }

            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 11
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object4";

            obj.setId(id);

            String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
            + "<included    xml:lang='de'>" + "\n"
            + "<notIncluded xml:lang='uk'>" + "\n"
            + "<included                 >" + "\n" + "</included>"
            + "\n" + "</notIncluded>" + "\n" + "</included>"
            + "\n" + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }

            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 12
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object5";

            obj.setId(id);

            String xmlStr = "" + "<included                         xml:lang='de'>"
            + "\n"
            + "<included                         xml:lang='de'>"
            + "\n"
            + "<notIncluded xml:space='preserve' xml:lang='uk'>"
            + "\n" + "<included                 >" + "\n"
            + "</included>" + "\n" + "</notIncluded>" + "\n"
            + "</included>" + "\n" + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }

            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 13
            ObjectContainer obj = new ObjectContainer(doc);
            String id = "object6";

            obj.setId(id);

            String xmlStr = "" + "<included   xml:space='preserve'  xml:lang='de'>"
            + "\n"
            + "<included                         xml:lang='de'>"
            + "\n"
            + "<notIncluded                      xml:lang='uk'>"
            + "\n" + "<included>" + "\n" + "</included>" + "\n"
            + "</notIncluded>" + "\n" + "</included>" + "\n"
            + "</included>";
            Document importDoc =
                db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

            obj.getElement().appendChild(doc.createTextNode("\n"));
            obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
            obj.getElement().appendChild(doc.createTextNode("\n"));
            xmlSignature.appendObject(obj);

            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            }

            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 13b
            String id = "object6";
            Transforms tf = new Transforms(doc);
            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
                tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
            }
            xmlSignature.addDocument("#" + id, tf);
        }

        {
            // ref 13c
            String id = "object6";
            Transforms tf = new Transforms(doc);

            {
                XPathContainer xc = new XPathContainer(doc);

                xc.setXPath("self::node()[local-name()='included']");
                tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
                tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
                tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
            }
            xmlSignature.addDocument("#" + id, tf);
            // xmlSignature.addDocument("#" + id, tf, org.apache.xml.security.algorithms.MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1, "ref13c", null);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

      ed.getCipherData().getCipherReference().setTransforms(xencTransforms);
      org.apache.xml.security.transforms.Transforms dsTransforms =
        xencTransforms.getDSTransforms();

      // An XPath transform
      XPathContainer xpc = new XPathContainer(d);
      xpc.setXPath("self::text()[parent::CipherText[@Id=\"CipherTextId\"]]");
      dsTransforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_XPATH,
                    xpc.getElementPlusReturns());

      // Add a Base64 Transforms
      dsTransforms.addTransform(
                    org.apache.xml.security.transforms.Transforms.TRANSFORM_BASE64_DECODE);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

        object2.setEncoding("http://www.w3.org/2000/09/xmldsig#base64");
        object2.appendChild(doc.createTextNode("SSBhbSB0aGUgdGV4dC4="));
        sig.appendObject(object2);

        Transforms transforms = new Transforms(doc);
        XPathContainer xpathC = new XPathContainer(doc);

        xpathC.setXPath("self::text()");
        transforms.addTransform(Transforms.TRANSFORM_XPATH,
                                xpathC.getElementPlusReturns());
        sig.addDocument("#object-1", transforms,
                        Constants.ALGO_ID_DIGEST_SHA1, null,
                        "http://www.w3.org/2000/09/xmldsig#Object");

        KeyStore ks = KeyStore.getInstance("JKS");
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

         // ref 0
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example1.xml", tf);
      }

      {

         // ref 1
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example1.xml", tf);
      }

      {

         // ref 2
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example2.xml", tf);
      }

      {

         // ref 3
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example2.xml", tf);
      }

      {

         // ref 4
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default",
                                        "http://example.org/default");
            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example3.xml", tf);
      }

      {

         // ref 5
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default",
                                        "http://example.org/default");
            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example3.xml", tf);
      }

      {

         // ref 6
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example4.xml", tf);
      }

      {

         // ref 7
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         {
            InclusiveNamespaces incNS = new InclusiveNamespaces(doc, "ns2");

            tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS,
                            incNS.getElement());
         }

         xmlSignature.addDocument("iaikTests.example4.xml", tf);
      }

      {

         // ref 8
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object1";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 9
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object2";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='uk'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 10
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object3";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included    xml:lang='de'>" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 11
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object4";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</included>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 12
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object5";

         obj.setId(id);

         String xmlStr = "" + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<notIncluded xml:space='preserve' xml:lang='uk'>"
                         + "\n" + "<included                 >" + "\n"
                         + "</included>" + "\n" + "</notIncluded>" + "\n"
                         + "</included>" + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object6";

         obj.setId(id);

         String xmlStr = "" + "<included   xml:space='preserve'  xml:lang='de'>"
                         + "\n"
                         + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<notIncluded                      xml:lang='uk'>"
                         + "\n" + "<included>" + "\n" + "</included>" + "\n"
                         + "</notIncluded>" + "\n" + "</included>" + "\n"
                         + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13b
         String id = "object6";
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13c
         String id = "object6";
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
         }

         xmlSignature.addDocument("#" + id, tf);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

      ed.getCipherData().getCipherReference().setTransforms(xencTransforms);
      org.apache.xml.security.transforms.Transforms dsTransforms =
        xencTransforms.getDSTransforms();

      // An XPath transform
      XPathContainer xpc = new XPathContainer(d);
      xpc.setXPath("self::text()[parent::CipherText[@Id=\"CipherTextId\"]]");
      dsTransforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_XPATH,
                    xpc.getElementPlusReturns());

      // Add a Base64 Transforms
      dsTransforms.addTransform(
                    org.apache.xml.security.transforms.Transforms.TRANSFORM_BASE64_DECODE);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

  Element signatureElement = signature.getElement();
  rootElement.appendChild(signatureElement);

  Transforms transforms = new Transforms(testDocument);
  XPathContainer xpath = new XPathContainer(testDocument);
  xpath.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);
  xpath.setXPath("not(ancestor-or-self::ds:Signature)");
  transforms.addTransform(Transforms.TRANSFORM_XPATH, xpath
        .getElementPlusReturns());
  transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
  signature.addDocument("", transforms,
        MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

      ed.getCipherData().getCipherReference().setTransforms(xencTransforms);
      org.apache.xml.security.transforms.Transforms dsTransforms =
        xencTransforms.getDSTransforms();

      // An XPath transform
      XPathContainer xpc = new XPathContainer(d);
      xpc.setXPath("self::text()[parent::CipherText[@Id=\"CipherTextId\"]]");
      dsTransforms.addTransform(org.apache.xml.security.transforms.Transforms.TRANSFORM_XPATH,
                    xpc.getElementPlusReturns());

      // Add a Base64 Transforms
      dsTransforms.addTransform(
                    org.apache.xml.security.transforms.Transforms.TRANSFORM_BASE64_DECODE);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

         // ref 0
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example1.xml", tf);
      }

      {

         // ref 1
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example1.xml", tf);
      }

      {

         // ref 2
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example2.xml", tf);
      }

      {

         // ref 3
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default", "http://example.org");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::default:Child)) or self::GrandChild or parent::GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example2.xml", tf);
      }

      {

         // ref 4
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default",
                                        "http://example.org/default");
            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example3.xml", tf);
      }

      {

         // ref 5
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:default",
                                        "http://example.org/default");
            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::default:Parent or (parent::default:Parent and not(self::default:Child)) or self::ns1:GrandChild or parent::ns1:GrandChild or self::default:GrandChild or parent::default:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS);
         xmlSignature.addDocument("iaikTests.example3.xml", tf);
      }

      {

         // ref 6
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("iaikTests.example4.xml", tf);
      }

      {

         // ref 7
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPathNamespaceContext("xmlns:ns1", "http://example.org/ns1");
            xc.setXPath(
               "self::Parent or (parent::Parent and not(self::Child)) or self::ns1:GrandChild or parent::ns1:GrandChild");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         {
            InclusiveNamespaces incNS = new InclusiveNamespaces(doc, "ns2");

            tf.addTransform(Transforms.TRANSFORM_C14N_EXCL_OMIT_COMMENTS,
                            incNS.getElement());
         }

         xmlSignature.addDocument("iaikTests.example4.xml", tf);
      }

      {

         // ref 8
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object1";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 9
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object2";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='uk'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 10
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object3";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included    xml:lang='de'>" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</notIncluded>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         // ref apache_8
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 11
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object4";

         obj.setId(id);

         String xmlStr = "" + "<included    xml:lang='de'>" + "\n"
                         + "<included    xml:lang='de'>" + "\n"
                         + "<notIncluded xml:lang='uk'>" + "\n"
                         + "<included                 >" + "\n" + "</included>"
                         + "\n" + "</notIncluded>" + "\n" + "</included>"
                         + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 12
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object5";

         obj.setId(id);

         String xmlStr = "" + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<notIncluded xml:space='preserve' xml:lang='uk'>"
                         + "\n" + "<included                 >" + "\n"
                         + "</included>" + "\n" + "</notIncluded>" + "\n"
                         + "</included>" + "\n" + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13
         ObjectContainer obj = new ObjectContainer(doc);
         String id = "object6";

         obj.setId(id);

         String xmlStr = "" + "<included   xml:space='preserve'  xml:lang='de'>"
                         + "\n"
                         + "<included                         xml:lang='de'>"
                         + "\n"
                         + "<notIncluded                      xml:lang='uk'>"
                         + "\n" + "<included>" + "\n" + "</included>" + "\n"
                         + "</notIncluded>" + "\n" + "</included>" + "\n"
                         + "</included>";
         Document importDoc =
            db.parse(new ByteArrayInputStream(xmlStr.getBytes()));

         obj.getElement().appendChild(doc.createTextNode("\n"));
         obj.getElement()
            .appendChild(doc.importNode(importDoc.getDocumentElement(), true));
         obj.getElement().appendChild(doc.createTextNode("\n"));
         xmlSignature.appendObject(obj);

         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13b
         String id = "object6";
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
         }

         xmlSignature.addDocument("#" + id, tf);
      }

      {

         // ref 13c
         String id = "object6";
         Transforms tf = new Transforms(doc);

         {
            XPathContainer xc = new XPathContainer(doc);

            xc.setXPath("self::node()[local-name()='included']");
            tf.addTransform(Transforms.TRANSFORM_XPATH, xc.getElement());
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
            tf.addTransform(Transforms.TRANSFORM_C14N_OMIT_COMMENTS);
         }

         xmlSignature.addDocument("#" + id, tf);
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

         String rootnamespace = signedResourceElement.getNamespaceURI();
         boolean rootprefixed = (rootnamespace != null)
                                && (rootnamespace.length() > 0);
         String rootlocalname = signedResourceElement.getNodeName();
         Transforms transforms = new Transforms(doc);
         XPathContainer xpath = new XPathContainer(doc);

         xpath.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);

         if (rootprefixed) {
            xpath.setXPathNamespaceContext("root", rootnamespace);
         }

         //J-
         String xpathStr = "\n"
          + "count(                                                                 " + "\n"
          + " ancestor-or-self::" + (rootprefixed ? "root:" : "") + rootlocalname + "" + "\n"
          + " |                                                                     " + "\n"
          + " here()/ancestor::" + (rootprefixed ? "root:" : "") + rootlocalname + "[1] " + "\n"
          + ") <= count(                                                             " + "\n"
          + " ancestor-or-self::" + (rootprefixed ? "root:" : "") + rootlocalname + "" + "\n"
          + ")                                                                      " + "\n"
          + " and                                                                   " + "\n"
          + "count(                                                                 " + "\n"
          + " ancestor-or-self::ds:Signature                                        " + "\n"
          + " |                                                                     " + "\n"
          + " here()/ancestor::ds:Signature[1]                                      " + "\n"
          + ") > count(                                                             " + "\n"
          + " ancestor-or-self::ds:Signature                                        " + "\n"
          + ")                                                                      " + "\n"



          ;
         //J+
         xpath.setXPath(xpathStr);
         transforms.addTransform(Transforms.TRANSFORM_XPATH,
                                 xpath.getElementPlusReturns());
         sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         sig.getKeyInfo()
View Full Code Here

Examples of org.apache.xml.security.transforms.params.XPathContainer

                         transforms, Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         Transforms transforms = new Transforms(doc);
         XPathContainer xpathC = new XPathContainer(doc);

         xpathC.setXPath("self::text()");
         transforms.addTransform(Transforms.TRANSFORM_XPATH,
                                 xpathC.getElementPlusReturns());
         sig.addDocument("#object-1", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }
      /*
      {
         Transforms transforms = new Transforms(doc);
         XPathContainer xpathC = new XPathContainer(doc);

         //J-
         xpathC.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);
         xpathC.setXPath("\n"
          + " ancestor-or-self::ds:SignedInfo                    " + "\n"
          + "  and                                               " + "\n"
          + " count(ancestor-or-self::ds:Reference |             " + "\n"
          + "      here()/ancestor::ds:Reference[1]) >           " + "\n"
          + " count(ancestor-or-self::ds:Reference)              " + "\n"
          + "  or                                                " + "\n"
          + " count(ancestor-or-self::node() |                   " + "\n"
          + "      id('notaries')) =                             " + "\n"
          + " count(ancestor-or-self::node())                    " + "\n");
         //J+
         transforms.addTransform(Transforms.TRANSFORM_XPATH,
                                 xpathC.getElementPlusReturns());
         sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }
      */

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_BASE64_DECODE);
         sig.addDocument("#object-2", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }

      sig.addDocument("#manifest-1", null, Constants.ALGO_ID_DIGEST_SHA1, null,
                      "http://www.w3.org/2000/09/xmldsig#Manifest");
      sig.addDocument("#signature-properties-1", null,
                      Constants.ALGO_ID_DIGEST_SHA1, null,
                      "http://www.w3.org/2000/09/xmldsig#SignatureProperties");

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
         sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
         transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
         sig.addDocument("", transforms, Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
         sig.addDocument("#xpointer(/)", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
         transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
         sig.addDocument("#xpointer(/)", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1);
      }

      {
         sig.addDocument("#object-3", null, Constants.ALGO_ID_DIGEST_SHA1,
                         null, "http://www.w3.org/2000/09/xmldsig#Object");
      }

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
         sig.addDocument("#object-3", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }

      {
         sig.addDocument("#xpointer(id('object-3'))", null,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }

      {
         Transforms transforms = new Transforms(doc);

         transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
         sig.addDocument("#xpointer(id('object-3'))", transforms,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Object");
      }

      {
         sig.addDocument("#manifest-reference-1", null,
                         Constants.ALGO_ID_DIGEST_SHA1, "reference-1",
                         "http://www.w3.org/2000/09/xmldsig#Reference");
      }

      {
         sig.addDocument("#reference-1", null,
                         Constants.ALGO_ID_DIGEST_SHA1, "reference-2",
                         "http://www.w3.org/2000/09/xmldsig#Reference");
      }

      {
         sig.addDocument("#reference-2", null,
                         Constants.ALGO_ID_DIGEST_SHA1, null,
                         "http://www.w3.org/2000/09/xmldsig#Reference");
      }

      /*
       * Add KeyInfo and sign()
       */
      {
         Transforms retrievalTransforms = new Transforms(doc);
         XPathContainer xpathC = new XPathContainer(doc);

         xpathC.setXPathNamespaceContext("ds", Constants.SignatureSpecNS);
         xpathC.setXPath("ancestor-or-self::ds:X509Data");
         retrievalTransforms.addTransform(Transforms.TRANSFORM_XPATH,
                                          xpathC.getElement());
         sig.getKeyInfo().add(
            new RetrievalMethod(
               doc, "#object-4", retrievalTransforms,
               "http://www.w3.org/2000/09/xmldsig#X509Data"));

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.