Package javax.xml.crypto.dsig.dom

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


  // create XMLSignature
  XMLSignature sig = fac.newXMLSignature
      (si, ki, Collections.singletonList(obj), null, null);

  DOMSignContext dsc = new DOMSignContext(signingKey, doc);

  sig.sign(dsc);

  DOMValidateContext dvc = new DOMValidateContext
      (ks, doc.getDocumentElement());
View Full Code Here


    ki = kifac.newKeyInfo(Collections.singletonList
        (kifac.newKeyName("testuser")));
      }
      sig = fac.newXMLSignature(si, ki, objs, id, sigValueId);
      Document doc = TestUtils.newDocument();
      signContext = new DOMSignContext(SIGN_KEYS[i], doc);
      sig.sign(signContext);
      validateContext = new DOMValidateContext
    (VALIDATE_KEYS[i], doc.getDocumentElement());
      if (sig.validate(validateContext) == false) {
    status = false;
View Full Code Here

    ki = kifac.newKeyInfo(Collections.singletonList
        (kifac.newKeyName("testuser")));
      }
      sig = fac.newXMLSignature(si, ki, objs, id, sigValueId);
      Document doc = TestUtils.newDocument();
      signContext = new DOMSignContext(SIGN_KEYS[i], doc);
      signContext.setProperty
    ("org.jcp.xml.dsig.internal.dom.SignatureProvider", p);
      try {
          sig.sign(signContext);
          fail("Should have failed because TestProvider does not " +
View Full Code Here

  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

  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

            // DSA PrivateKey for signing
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setValidating(false);
            Document doc = dbf.newDocumentBuilder().newDocument();
          DOMSignContext signContext = new DOMSignContext(kp.getPrivate(), doc);
          signContext.putNamespacePrefix(XMLSignature.XMLNS, "ds");

          // Generate (and sign) the XMLSignature
          signature.sign(signContext);
   
          //
View Full Code Here

  KEYS[1] = TestUtils.getPrivateKey("RSA");
  KEYS[2] = new SecretKeySpec(new byte[16], "HmacSHA1");
  // set up the default XMLSignContext
  SecretKey sk = new SecretKeySpec(new byte[8], "DES");
  doc = TestUtils.newDocument();
  defContext = new DOMSignContext(sk, doc);
    }
View Full Code Here

  KEYS[1] = TestUtils.getPrivateKey("RSA");
  KEYS[2] = new SecretKeySpec(new byte[16], "HmacSHA1");
  // set up the default XMLSignContext
  SecretKey sk = new SecretKeySpec(new byte[8], "DES");
  doc = TestUtils.newDocument();
  defContext = new DOMSignContext(sk, doc);
    }
View Full Code Here

      ("http://example.org/envelope", "Envelope");
  envelope.setAttributeNS
      (Constants.NamespaceSpecNS, "xmlns", "http://example.org/envelope");
  doc.appendChild(envelope);

  DOMSignContext dsc = new DOMSignContext(signingKey, envelope);

  sig.sign(dsc);

  DOMValidateContext dvc = new DOMValidateContext
      (kvks, envelope.getFirstChild());
View Full Code Here

  notaries.appendChild(notary1);
  notaries.appendChild(notary2);
  envelope.appendChild(notaries);
  envelope.appendChild(doc.createComment(" Commentary "));

  DOMSignContext dsc = new DOMSignContext(signingKey, ys);
  dsc.setIdAttributeNS(notaries, null, "Id");

  sig.sign(dsc);

  // DOM L2 does not support the creation of DOCTYPEs, so instead
        // we insert it before the document using a StringWriter
View Full Code Here

TOP

Related Classes of javax.xml.crypto.dsig.dom.DOMSignContext

Copyright © 2018 www.massapicom. 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.