Examples of DOMSignContext


Examples of javax.xml.crypto.dsig.dom.DOMSignContext

  SignedInfo si = createSignedInfo(SIG_METHODS[1]);
  KeyInfo  ki = kifac.newKeyInfo(Collections.singletonList
        (kifac.newKeyValue((PublicKey) VALIDATE_KEYS[1])));
  XMLSignature sig = fac.newXMLSignature(si, ki, objs, id, sigValueId);
  Document doc = TestUtils.newDocument();
  XMLSignContext signContext = new DOMSignContext(SIGN_KEYS[1], doc);
  signContext.putNamespacePrefix(XMLSignature.XMLNS, "");
        sig.sign(signContext);
/*
  StringWriter sw = new StringWriter();
  dumpDocument(doc, sw);
  System.out.println(sw);
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

  KeyInfo  ki = kifac.newKeyInfo(Collections.singletonList
        (kifac.newKeyValue((PublicKey) VALIDATE_KEYS[1])));

        // create XMLSignature
        XMLSignature sig = fac.newXMLSignature(si, ki, objs, "signature", null);
        DOMSignContext dsc = new DOMSignContext(SIGN_KEYS[1], doc);

        sig.sign(dsc);

/*
  StringWriter sw = new StringWriter();
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

            (signature.getSignedInfo(), null, signature.getObjects(),
             signature.getId(), signature.getSignatureValue().getId());

        // Sign the template
        Node parent = domSignature.getNode().getParentNode();
        DOMSignContext signContext = new DOMSignContext(SIGN_KEYS[0], parent);
        // remove the signature node (since it will get recreated)
        parent.removeChild(domSignature.getNode());
        newSignature.sign(signContext);

        // check that Object element retained namespace definitions
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

    public void sign(XMLSignContext signContext)
  throws MarshalException, XMLSignatureException {
  if (signContext == null) {
      throw new NullPointerException("signContext cannot be null");
  }
        DOMSignContext context = (DOMSignContext) signContext;
        if (context != null) {
            marshal(context.getParent(), context.getNextSibling(),
                DOMUtils.getSignaturePrefix(context), context);
        }

  // generate references and signature value
  List allReferences = new ArrayList();
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

    public void sign(XMLSignContext signContext)
  throws MarshalException, XMLSignatureException {
  if (signContext == null) {
      throw new NullPointerException("signContext cannot be null");
  }
        DOMSignContext context = (DOMSignContext) signContext;
        if (context != null) {
            marshal(context.getParent(), context.getNextSibling(),
                DOMUtils.getSignaturePrefix(context), context);
        }

  // generate references and signature value
  List allReferences = new ArrayList(si.getReferences());
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

      }

      PrivateKey signingKey = keyPair.getPrivate();
      PublicKey publicKey = keyPair.getPublic();

      DOMSignContext dsc = new DOMSignContext(signingKey, doc.getDocumentElement());
      dsc.setDefaultNamespacePrefix("dsig");

      try
      {
         DigestMethod digestMethodObj = fac.newDigestMethod(DigestMethod.SHA1, null);
         Transform transform = fac.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null);
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

            // Prepend the signature element to the security header (after the assertion)
            //
            XMLSignContext signContext = null;
            if (siblingElement != null && siblingElement.getNextSibling() != null) {
                signContext =
                    new DOMSignContext(key, securityHeaderElement, siblingElement.getNextSibling());
            } else {
                signContext = new DOMSignContext(key, securityHeaderElement);
            }
            signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
            if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                signContext.putNamespacePrefix(
                    WSConstants.C14N_EXCL_OMIT_COMMENTS,
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

            if (prepend) {
                if (siblingElement == null) {
                    siblingElement = (Element)securityHeader.getFirstChild();
                }
                if (siblingElement == null) {
                    signContext = new DOMSignContext(key, securityHeader);
                } else {
                    signContext = new DOMSignContext(key, securityHeader, siblingElement);
                }
            } else {
                signContext = new DOMSignContext(key, securityHeader);
            }
           
            signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
            if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                signContext.putNamespacePrefix(
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

                        child = child.getNextSibling();
                    }
                    siblingElement = (Element)child;
                }
                if (siblingElement == null) {
                    signContext = new DOMSignContext(key, securityHeader);
                } else {
                    signContext = new DOMSignContext(key, securityHeader, siblingElement);
                }
            } else {
                signContext = new DOMSignContext(key, securityHeader);
            }
           
            signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
            if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
                signContext.putNamespacePrefix(
View Full Code Here

Examples of javax.xml.crypto.dsig.dom.DOMSignContext

        X509Data xd = kif.newX509Data(x509Content);
        ki = kif.newKeyInfo(Collections.singletonList(xd));    

       
       
        DOMSignContext dsc = new DOMSignContext
            (keyEntry.getPrivateKey(), document.getDocumentElement());

        // Create the XMLSignature, but don't sign it yet.
        XMLSignature signature = fac.newXMLSignature(si, ki);
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.