Package javax.xml.crypto.dsig.dom

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


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

        DOMValidateContext dvc = new DOMValidateContext
      (VALIDATE_KEYS[1], doc.getDocumentElement());
        XMLSignature sig2 = fac.unmarshalXMLSignature(dvc);

        if (sig.equals(sig2) == false) {
            throw new Exception
View Full Code Here


          //
          // PART 2 : Validating the detached signature
          //
   
          // Create a XMLValidateContext & set the DSAPublicKey for validating
      XMLValidateContext vc = new DOMValidateContext(kp.getPublic(),
    doc.getDocumentElement());
   
          // Validate the Signature (generated above)
          boolean coreValidity = signature.validate(vc);
   
View Full Code Here

      "merlin-xmldsig-twenty-three");
  Document doc = docBuilder.parse(new File(dir, "signature.xml"));
  NodeList nl = doc.getElementsByTagName("KeyInfo");
  try {
      stuff = factory.unmarshalXMLSignature
      (new DOMValidateContext(TestUtils.getPublicKey("RSA"), nl.item(0)));
      fail("Should throw a MarshalException for non-XMLSignature inputs");
  } catch (MarshalException ex) {}
 
  nl = doc.getElementsByTagName("Signature");
  try {
      stuff = factory.unmarshalXMLSignature
      (new DOMValidateContext(TestUtils.getPublicKey("DSA"), nl.item(0)));
      assertNotNull(stuff);
  } catch (MarshalException ex) {
      fail("Unmarshal failed: " + ex.getMessage());
      ex.printStackTrace();
  }
View Full Code Here

//        assertTrue("Signature failed core validation", coreValidity);
//    }
    public void test_signature_dsa_detached() throws Exception {
  String file = "signature-dsa-detached.xml";

        DOMValidateContext vc = validator.getValidateContext
            (file, new KeySelectors.RawX509KeySelector());
        vc.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);

  boolean coreValidity = validator.validate(vc);
  assertTrue("Signature failed core validation", coreValidity);
    }
View Full Code Here

  assertTrue("Signature failed core validation", coreValidity);
    }
    public void test_signature_rsa_detached() throws Exception {
  String file = "signature-rsa-detached.xml";

        DOMValidateContext vc = validator.getValidateContext
      (file, new KeySelectors.RawX509KeySelector());
        vc.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
  boolean coreValidity = validator.validate(vc);
  assertTrue("Signature failed core validation", coreValidity);
    }
View Full Code Here

  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

  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

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

  DOMValidateContext dvc = new DOMValidateContext
      (ks, doc.getDocumentElement());
  String fs = System.getProperty("file.separator");
  File f = new File(
      System.getProperty("basedir") + 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

  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

      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

TOP

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

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.