Package javax.xml.crypto.dsig.dom

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


  KEYS[1] = TestUtils.getPublicKey("RSA");
  KEYS[2] = new SecretKeySpec(new byte[16], "HmacSHA1");

  // set up the default XMLValidateContext
  SecretKey sk = new SecretKeySpec(new byte[8], "DES");
  defContext = new DOMValidateContext(sk, TestUtils.newDocument());

  // set up the key selectors
  KEY_SELECTORS = new KeySelector[1];
        KEY_SELECTORS[0] = KeySelector.singletonKeySelector(sk);
    }
View Full Code Here

        Document doc = dbf.newDocumentBuilder().parse(new File(dir, fn));
        Element sigElement = getSignatureElement(doc);
  if (sigElement == null) {
      throw new Exception("Couldn't find signature Element");
  }
  DOMValidateContext vc = new DOMValidateContext(ks, sigElement);
  vc.setBaseURI(dir.toURI().toString());
  return vc;
    }
View Full Code Here

    }

    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

      }
      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

          //
          // 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

  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

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.