Package org.apache.xml.security.signature

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


      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


      }
      if (content != null && content.getResolvedSrc() != null)
        sig.addDocument(content.getResolvedSrc().toASCIIString());
    }
   
    if (cert != null) sig.addKeyInfo(cert);
    if (pkey != null) sig.addKeyInfo(pkey);
    sig.sign(signingKey);   
    return (T)domToFom(dom, options);
  }
 
View Full Code Here

      if (content != null && content.getResolvedSrc() != null)
        sig.addDocument(content.getResolvedSrc().toASCIIString());
    }
   
    if (cert != null) sig.addKeyInfo(cert);
    if (pkey != null) sig.addKeyInfo(pkey);
    sig.sign(signingKey);   
    return (T)domToFom(dom, options);
  }
 
  public <T extends Element>T sign(
View Full Code Here

            if (content != null && content.getResolvedSrc() != null)
                sig.addDocument(content.getResolvedSrc().toASCIIString());
        }

        if (cert != null)
            sig.addKeyInfo(cert);
        if (pkey != null)
            sig.addKeyInfo(pkey);
        sig.sign(signingKey);
        return (T)domToFom(dom, options);
    }
View Full Code Here

        }

        if (cert != null)
            sig.addKeyInfo(cert);
        if (pkey != null)
            sig.addKeyInfo(pkey);
        sig.sign(signingKey);
        return (T)domToFom(dom, options);
    }

    public <T extends Element> T sign(T entry, SignatureOptions options) throws SecurityException {
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.canonicalizeSubtree(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.canonicalizeSubtree(doc);
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

        }

        XMLSignature sig = null;
        try {
            sig = new XMLSignature(docTobeSigned, null, sigAlgo, canonAlgo);
            sig.addKeyInfo(certs[0]);
            sig.sign(crypto.getPrivateKey(alias, password));
        } catch (XMLSecurityException e) {
            throw new WSSecurityException(WSSecurityException.FAILED_SIGNATURE,
                    "UserNAmeTokenIssuer:signature over token failed");
View Full Code Here

                "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
                document, localNames, "http://www.w3.org/2000/09/xmldsig#base64", key
        );

        // Add KeyInfo
        sig.addKeyInfo(cert);

        //XMLUtils.outputDOM(document, System.out);

        // Convert Document to a Stream Reader
        javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
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.