Examples of DOMValidateContext


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

    }

    public boolean validate(String fn, KeySelector ks, URIDereferencer ud)
  throws Exception {

  DOMValidateContext vc = getValidateContext(fn, ks);
  if (ud != null) {
      vc.setURIDereferencer(ud);
  }

  return validate(vc);
    }
View Full Code Here

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

                } else {
                    assertNotNull(ref.getDereferencedData());
                    assertNotNull(ref.getDigestInputStream());
                    assertTrue(digestInputEqual(ref));
                }
          validateContext = new DOMValidateContext
        (TestUtils.getPublicKey(CRYPTO_ALGS[i]),
        doc.getDocumentElement());
          validateContext.setURIDereferencer(dereferrer);

                if (cache) {
View Full Code Here

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

    public void tearDown() {}

    public void testConstructor() throws Exception {
  assertNotNull(domVC);
  try {
      new DOMValidateContext(TestUtils.getPublicKey("RSA"), null);
      fail("Should throw a NPE for null node");
  } catch (NullPointerException npe) {
  } catch (Exception ex) {
      fail("Should throw a NPE instead of " + ex + " for null node");
  }
View Full Code Here

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

  DOMSignContext dsc = new DOMSignContext(signingKey, envelope);

  sig.sign(dsc);

  DOMValidateContext dvc = new DOMValidateContext
      (kvks, envelope.getFirstChild());
  XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);

  assertTrue(sig.equals(sig2));
View Full Code Here

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

  Element sigElement = SignatureValidator.getSignatureElement(doc);
  if (sigElement == null) {
            throw new Exception("Couldn't find signature Element");
  }

  DOMValidateContext dvc = new DOMValidateContext
      (new X509KeySelector(ks), sigElement);
  File f = new File(
      System.getProperty("dir.test.vector.baltimore") +
            System.getProperty("file.separator") +
      "merlin-xmldsig-twenty-three" +
            System.getProperty("file.separator"));
  dvc.setBaseURI(f.toURI().toString());

  // register Notaries ID
//  Element notariesElem =
//      (Element) doc.getElementsByTagName("Notaries").item(0);
//  dvc.setIdAttributeNS(notariesElem, "", "Id");
View Full Code Here

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

  StringWriter sw = new StringWriter();
        dumpDocument(doc, sw);
  System.out.println(sw.toString());
**/

  DOMValidateContext dvc = new DOMValidateContext
      (ks, doc.getDocumentElement());
  String base = System.getProperty("basedir") == null ? "./": System.getProperty("basedir");
  String fs = System.getProperty("file.separator");
  File f = new File(
      base + fs + "data" + fs + "ie" + fs +
      "baltimore" + fs + "merlin-examples" + fs +
      "merlin-xmldsig-twenty-three" + fs);
  dvc.setBaseURI(f.toURI().toString());
     
  XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);

  assertTrue(sig.equals(sig2));
  assertTrue(sig2.validate(dvc));
View Full Code Here

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

  DOMSignContext dsc = new DOMSignContext(signingKey, doc);

  sig.sign(dsc);

  DOMValidateContext dvc = new DOMValidateContext
      (ks, doc.getDocumentElement());
  XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);

  assertTrue(sig.equals(sig2));
  assertTrue(sig2.validate(dvc));
View Full Code Here

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

      DocumentBuilderFactory docFactory =
    DocumentBuilderFactory.newInstance();
      DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
      Document doc = docBuilder.parse(input);
      if (tag == null) {
    return new DOMValidateContext
        (TestUtils.getPublicKey("RSA"), doc.getDocumentElement());
      } else {
    NodeList list = doc.getElementsByTagName(tag);
    return new DOMValidateContext
        (TestUtils.getPublicKey("RSA"), list.item(0));
      }
  } else {
      throw new Exception("Unsupported XMLValidateContext type: " +
        type);
View Full Code Here

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

     * The element's ID needs to be registered so that it can be found.
     */
    public void test_signature_with_ID() throws Exception {
        String file = "envelopingSignature.xml";

  DOMValidateContext vc = validator.getValidateContext
      (file, new KeySelectors.KeyValueKeySelector());
  Document doc = vc.getNode().getOwnerDocument();
  NodeList nl = doc.getElementsByTagName("Assertion");
  vc.setIdAttributeNS((Element) nl.item(0), null, "AssertionID");
  boolean coreValidity = validator.validate(vc);
  assertTrue("Signature failed core validation", coreValidity);
    }
View Full Code Here

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

      }
      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;
    TestUtils.dumpDocument(doc, "signatureTest_out"+i+".xml");
      }
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.