Examples of XMLSignatureInput


Examples of org.apache.xml.security.signature.XMLSignatureInput

      // Need to wrap the uri in an Attribute node so that we can
      // Pass to the resource resolvers

      Attr uriAttr = cr.getURIAsAttr();
      XMLSignatureInput input = null;

      try {
        ResourceResolver resolver =
          ResourceResolver.getInstance(uriAttr, null);
        input = resolver.resolve(uriAttr, null);
      } catch (ResourceResolverException ex) {
        throw new XMLEncryptionException("empty", ex);
      }

      if (input != null) {
        logger.debug("Managed to resolve URI \"" + cr.getURI() + "\"");
      }
      else {
        logger.debug("Failed to resolve URI \"" + cr.getURI() + "\"");
      }
   
      // Lets see if there are any transforms
      Transforms transforms = cr.getTransforms();
      if (transforms != null) {
        logger.debug ("Have transforms in cipher reference");
        try {
             org.apache.xml.security.transforms.Transforms dsTransforms =
            transforms.getDSTransforms();
            input =  dsTransforms.performTransforms(input);
        } catch (TransformationException ex) {
          throw new XMLEncryptionException("empty", ex);
        }
      }

      try {
        return input.getBytes();
      }
      catch (IOException ex) {
        throw new XMLEncryptionException("empty", ex);
      } catch (CanonicalizationException ex) {
        throw new XMLEncryptionException("empty", ex);
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

         String type = rm.getType();
         Transforms transforms = rm.getTransforms();
         ResourceResolver resRes = ResourceResolver.getInstance(uri, BaseURI);

         if (resRes != null) {
            XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
            if (log.isDebugEnabled())
              log.debug("Before applying Transforms, resource has "
                      + resource.getBytes().length + "bytes");

            if (transforms != null) {
               log.debug("We have Transforms");

               resource = transforms.performTransforms(resource);
            }
            if (log.isDebugEnabled()) {
              log.debug("After applying Transforms, resource has "
                      + resource.getBytes().length + "bytes");
              log.debug("Resolved to resource " + resource.getSourceURI());
            }

            byte inputBytes[] = resource.getBytes();

            if ((type != null) && type.equals(RetrievalMethod.TYPE_RAWX509)) {

               // if the resource stores a raw certificate, we have to handle it
               CertificateFactory certFact =
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

           log.debug("Asked to resolve URI " + uri);

         ResourceResolver resRes = ResourceResolver.getInstance(uri, BaseURI);

         if (resRes != null) {
            XMLSignatureInput resource = resRes.resolve(uri, BaseURI);
            if (log.isDebugEnabled())
              log.debug("Before applying Transforms, resource has "
                      + resource.getBytes().length + "bytes");

            if (transforms != null) {
               log.debug("We have Transforms");

               resource = transforms.performTransforms(resource);
            }
           
            if (log.isDebugEnabled()) {
              log.debug("After applying Transforms, resource has "
                      + resource.getBytes().length + "bytes");
              log.debug("Resolved to resource " + resource.getSourceURI());
            }

            byte inputBytes[] = resource.getBytes();

            if ((rm.getType() != null)
                    && rm.getType().equals(RetrievalMethod.TYPE_RAWX509)) {

               // if the resource stores a raw certificate, we have to handle it
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

      sig.sign(sig.createSecretKey("secret".getBytes()));

      log.info("Signing finished");

      XMLSignatureInput s = sig.getSignedInfo().getReferencedContentAfterTransformsItem(0);
      Set nodes = s.getNodeSet();
      Iterator it = nodes.iterator();
      while (it.hasNext()) {
         Node n = (Node) it.next();
         if (n.getNodeType() == Node.ATTRIBUTE_NODE) {
            Element e = ((Attr)n).getOwnerElement();
            System.out.println("<" + e.getTagName() + " " + n + " />");
         } else if (n.getNodeType() == Node.ELEMENT_NODE) {
            System.out.println("<" + ((Element)n).getTagName() + " />");
         }
      }
      log.info("finished");

      System.out.println("###########################");
      System.out.println(new String(s.getBytes()));
   }
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

           throws IOException, CanonicalizationException,
                  InvalidCanonicalizerException {

      InputStream inputStream =
         new ByteArrayInputStream(_octetStreamTextInput.getBytes("UTF-8"));
      XMLSignatureInput input = new XMLSignatureInput(inputStream);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      InputStream res = input.getOctetStream();
      int off = 0;

      while (res.available() > 0) {
         byte array[] = new byte[1024];
         int len = res.read(array);
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

           throws IOException, UnsupportedEncodingException,
                  ParserConfigurationException, SAXException,
                  CanonicalizationException, InvalidCanonicalizerException,
                  TransformerException {

      XMLSignatureInput input = new XMLSignatureInput(getNodeSet1(), null);
      String definedWithoutComments =
         "<RootElement><Element1></Element1><Element2></Element2><Element3>Text in Element3</Element3></RootElement>";

      {

         // input.setCanonicalizerURI(Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS);
         String resultWithoutComments = new String(input.getBytes(), "UTF-8");

         /* FileOutputStream fos = new FileOutputStream ("xResult.xml");
            fos.write(resultWithoutComments.getBytes()); */
         assertTrue("testSetNodeSetGetOctetStream(false)",
                    resultWithoutComments.equals(definedWithoutComments));
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

    */
   public static void testIsInitializedWithOctetStream() throws IOException {

      InputStream inputStream =
         new ByteArrayInputStream(_octetStreamTextInput.getBytes());
      XMLSignatureInput input = new XMLSignatureInput(inputStream);

      assertTrue("Input is initialized", input.isInitialized());
   }
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

    */
   public static void testOctetStreamIsOctetStream() throws IOException {

      InputStream inputStream =
         new ByteArrayInputStream(_octetStreamTextInput.getBytes());
      XMLSignatureInput input = new XMLSignatureInput(inputStream);

      assertTrue("Input is octet stream", input.isOctetStream());
   }
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

    */
   public static void testOctetStreamIsNotNodeSet() throws IOException {

      InputStream inputStream =
         new ByteArrayInputStream(_octetStreamTextInput.getBytes());
      XMLSignatureInput input = new XMLSignatureInput(inputStream);

      assertTrue("Input is not node set", !input.isNodeSet());
   }
View Full Code Here

Examples of org.apache.xml.security.signature.XMLSignatureInput

   public static void testIsInitializedWithNodeSet()
           throws IOException, UnsupportedEncodingException,
                  ParserConfigurationException, SAXException,
                  CanonicalizationException, TransformerException {

      XMLSignatureInput input = new XMLSignatureInput(getNodeSet1(), null);

      assertTrue("Input is initialized", input.isInitialized());
   }
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.