Package org.apache.xml.security.signature

Examples of org.apache.xml.security.signature.XMLSignature.sign()


            oTrans.addTransform(oTransforms[i]);
        }
        oSig.addDocument("#" + sID, oTrans);

        // now finally sign the thing
        oSig.sign(oKey);

        // now sub in this element
        Element oSigElem = oSig.getElement();

        // insert the signature in the right place
View Full Code Here


            (X509Certificate) ks.getCertificate(certificateAlias);

         sig.addKeyInfo(cert);
         sig.addKeyInfo(cert.getPublicKey());
         System.out.println("Start signing");
         sig.sign(privateKey);
         System.out.println("Finished signing");
      }

      FileOutputStream f = new FileOutputStream(signatureFile);
View Full Code Here

         X509Certificate cert =
            (X509Certificate) ks.getCertificate(certificateAlias);

         sig.addKeyInfo(cert);
         sig.addKeyInfo(cert.getPublicKey());
         sig.sign(privateKey);
      }

      FileOutputStream f = new FileOutputStream(signatureFile);

      XMLUtils.outputDOMc14nWithComments(doc, f);
View Full Code Here

         x509data.add(new XMLX509Certificate(doc, cert));
         sig.getKeyInfo().add(x509data);
         */

         System.out.println("Start signing");
         sig.sign(privateKey);
         System.out.println("Finished signing");
      }

      FileOutputStream f = new FileOutputStream(signatureFile);

View Full Code Here

         x509data.add(new XMLX509Certificate(doc, cert));
         sig.getKeyInfo().add(x509data);
         */

         System.out.println("Start signing");
         sig.sign(privateKey);
         System.out.println("Finished signing");
      }

      FileOutputStream f = new FileOutputStream(signatureFile);

View Full Code Here

  }
        ks.load(fis, "xmlsecurity".toCharArray());
        PrivateKey privateKey = (PrivateKey) ks.getKey("test",
                                 "xmlsecurity".toCharArray());

  sig.sign(privateKey);
    }
   
    KeyPair kp = null;   
    javax.xml.parsers.DocumentBuilder db;
   
View Full Code Here

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

        sig.addKeyInfo(kp.getPublic());
        sig.sign(privateKey);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        XMLUtils.outputDOMc14nWithComments(doc, bos);
        return new String(bos.toByteArray());
View Full Code Here

           // Add these three lines
           org.apache.xml.security.keys.KeyInfo ki = sig.getKeyInfo();
           ki.itemX509Data(0).addSubjectName(cert.getSubjectDN().toString());
           ki.itemX509Data(0).addIssuerSerial(cert.getIssuerDN().toString(),
               cert.getSerialNumber());          
           sig.sign(getPrivateKey());
           ByteArrayOutputStream os = new ByteArrayOutputStream();
           XMLUtils.outputDOM(doc, os);
           XMLSignature newSig=getSignature(os.toByteArray());
           assertNotNull(newSig.getKeyInfo().itemX509Data(0));
           assertEquals(RFC2253Parser.normalize(cert.getSubjectDN().toString()),
View Full Code Here

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

        sig.addKeyInfo(signingCert);
        sig.sign(privateKey);
  X509Certificate cert = sig.getKeyInfo().getX509Certificate();
  sig.checkSignatureValue(cert.getPublicKey());
        ByteArrayOutputStream bos = new ByteArrayOutputStream();

        XMLUtils.outputDOMc14nWithComments(doc, bos);
View Full Code Here

           // Add these three lines
           org.apache.xml.security.keys.KeyInfo ki = sig.getKeyInfo();
           ki.itemX509Data(0).addSubjectName(cert.getSubjectDN().toString());
           ki.itemX509Data(0).addIssuerSerial(cert.getIssuerDN().toString(),
               cert.getSerialNumber());          
           sig.sign(getPrivateKey());
           ByteArrayOutputStream os = new ByteArrayOutputStream();
           XMLUtils.outputDOM(doc, os);
           XMLSignature newSig=getSignature(os.toByteArray());
           assertNotNull(newSig.getKeyInfo().itemX509Data(0));
           assertEquals(RFC2253Parser.normalize(cert.getSubjectDN().toString()),
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.