Package org.apache.xml.security.signature

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


        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);
        return bos.toByteArray();
View Full Code Here


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

  signature.sign(privateKey);

  // TransformerFactory tf = TransformerFactory.newInstance();
  // Transformer t = tf.newTransformer();
  // t.transform(new DOMSource(testDocument), new StreamResult(System.out));
View Full Code Here

                    (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);

            InputSource is = new InputSource(new java.io.ByteArrayInputStream(canonicalMessage));
View Full Code Here

      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)
    {
      Node child = node.getFirstChild();
View Full Code Here

      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)
    {
      Node child = node.getFirstChild();
View Full Code Here

                log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature "
                        + "created during marshalling.");
                throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature");
            }
            log.debug("Computing signature over XMLSignature object");
            xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential()));
        } catch (XMLSecurityException e) {
            log.error("An error occured computing the digital signature", e);
            throw new SignatureException("Signature computation error", e);
        }
    }
View Full Code Here

        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(
    T entry,
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 {
        try {
View Full Code Here

                    (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);

            InputSource is = new InputSource(new java.io.ByteArrayInputStream(canonicalMessage));
View Full Code Here

                log.error("Unable to compute signature, Signature XMLObject does not have the XMLSignature "
                        + "created during marshalling.");
                throw new SignatureException("XMLObject does not have an XMLSignature instance, unable to compute signature");
            }
            log.debug("Computing signature over XMLSignature object");
            xmlSignature.sign(SecurityHelper.extractSigningKey(signature.getSigningCredential()));
        } catch (XMLSecurityException e) {
            log.error("An error occured computing the digital signature", e);
            throw new SignatureException("Signature computation error", e);
        }
    }
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.