Package org.apache.xml.security.signature

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


                 XMLSignature.ALGO_ID_SIGNATURE_DSA);
       doc.appendChild(sig.getElement());
       sig.addDocument("");
           //Add in the KeyInfo for the certificate that we used the private key of          
       X509Certificate cert =getCertificate();
           sig.addKeyInfo(cert);
           sig.addKeyInfo(cert.getPublicKey());
           // 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(),
View Full Code Here


       doc.appendChild(sig.getElement());
       sig.addDocument("");
           //Add in the KeyInfo for the certificate that we used the private key of          
       X509Certificate cert =getCertificate();
           sig.addKeyInfo(cert);
           sig.addKeyInfo(cert.getPublicKey());
           // 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());          
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);

        X509Certificate x509 = (X509Certificate)keyStore.getCertificate("ECDSA");
        sig.addKeyInfo(x509);
        sig.sign(privateKey);

        ByteArrayOutputStream bos = new ByteArrayOutputStream();

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

  transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
  signature.addDocument("", transforms,
        MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);

  if (cert) {
      signature.addKeyInfo(signingCert);
  } else {
      signature.addKeyInfo(publicKey);
  }

  Element nsElement = testDocument.createElementNS(null, "nsElement");
View Full Code Here

        MessageDigestAlgorithm.ALGO_ID_DIGEST_SHA1);

  if (cert) {
      signature.addKeyInfo(signingCert);
  } else {
      signature.addKeyInfo(publicKey);
  }

  Element nsElement = testDocument.createElementNS(null, "nsElement");
  nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:ds",
        Constants.SignatureSpecNS);
View Full Code Here

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


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

            Canonicalizer c14n = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
            byte[] canonicalMessage = c14n.canonicalizeDocument(doc);
View Full Code Here

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


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

            Canonicalizer c14n = Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
            byte[] canonicalMessage = c14n.canonicalizeDocument(doc);
View Full Code Here

      signature.addDocument("",transforms,org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);
     
      for (EbMSDataSource dataSource : dataSources)
        signature.addDocument("cid:" + dataSource.getContentId());
     
      signature.addKeyInfo(keyPair.getPublic());
     
      Certificate[] certificates = keyStore.getCertificateChain(alias);
        //for (Certificate certificate : certificates)
        //  signature.addKeyInfo((X509Certificate)certificate);
      signature.addKeyInfo((X509Certificate)certificates[0]);
View Full Code Here

      signature.addKeyInfo(keyPair.getPublic());
     
      Certificate[] certificates = keyStore.getCertificateChain(alias);
        //for (Certificate certificate : certificates)
        //  signature.addKeyInfo((X509Certificate)certificate);
      signature.addKeyInfo((X509Certificate)certificates[0]);
 
      signature.sign(keyPair.getPrivate());
    }
   
    private Element getFirstChildElement(Node node)
View Full Code Here

      signature.addDocument("",transforms,org.apache.xml.security.utils.Constants.ALGO_ID_DIGEST_SHA1);
     
      for (EbMSDataSource dataSource : dataSources)
        signature.addDocument("cid:" + dataSource.getContentId());
     
      signature.addKeyInfo(keyPair.getPublic());
     
      Certificate[] certificates = keyStore.getCertificateChain(alias);
        //for (Certificate certificate : certificates)
        //  signature.addKeyInfo((X509Certificate)certificate);
      signature.addKeyInfo((X509Certificate)certificates[0]);
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.