Examples of DOMValidateContext


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

            key = publicKey;
        } else {
            key = WSSecurityUtil.prepareSecretKey(signatureMethod, secretKey);
        }
       
        XMLValidateContext context = new DOMValidateContext(key, elem);
        context.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
        context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
        context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);
        context.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
       
        try {
            XMLSignature xmlSignature = signatureFactory.unmarshalXMLSignature(context);
            if (data.getWssConfig().isWsiBSPCompliant()) {
                checkBSPCompliance(xmlSignature);
View Full Code Here

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

        Document doc = XMLUtils.createDocumentBuilder(false).parse(new File(dir, file));
        Element sigElement = SignatureValidator.getSignatureElement(doc);
        if (sigElement == null) {
            throw new Exception("Couldn't find signature Element");
        }
        DOMValidateContext vc =
            new DOMValidateContext(new KeySelectors.KeyValueKeySelector(), sigElement);
        vc.setBaseURI(dir.toURI().toString());

        vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.FALSE);
        boolean coreValidity = validator.validate(vc);
        assertTrue("Signature failed core validation", coreValidity);
       
        vc.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
       
        Element manifestElement =
            (Element) doc.getElementsByTagName("Manifest").item(0);
        vc.setIdAttributeNS(manifestElement, null, "Id");
       
        try {
            boolean valid = validator.validate(vc);
            System.out.println("Valid: " + valid);
            fail("Failure expected when secure validation is enabled");
View Full Code Here

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

            "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

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

        throws Exception {
        if (type.equalsIgnoreCase("dom")) {
            DocumentBuilder docBuilder = XMLUtils.createDocumentBuilder(false);
            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

        Document doc = XMLUtils.createDocumentBuilder(false).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

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

                        "cannot get certificate or key");
                }
           
                // Not checking signature here, just marshalling into an XMLSignature
                // structure for testing the transform/digest algorithms etc.
                XMLValidateContext context = new DOMValidateContext(key, sig.getDOM());
                context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
                context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);

                XMLSignature xmlSignature;
                try {
                    xmlSignature = signatureFactory.unmarshalXMLSignature(context);
                } catch (MarshalException ex) {
View Full Code Here

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

            key = publicKey;
        } else {
            key = KeyUtils.prepareSecretKey(signatureMethod, secretKey);
        }
       
        XMLValidateContext context = new DOMValidateContext(key, elem);
        context.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE);
        context.setProperty("org.apache.jcp.xml.dsig.secureValidation", Boolean.TRUE);
        context.setProperty("org.jcp.xml.dsig.secureValidation", Boolean.TRUE);
        context.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
       
        try {
            XMLSignature xmlSignature = signatureFactory.unmarshalXMLSignature(context);
            checkBSPCompliance(xmlSignature, data.getBSPEnforcer());
           
View Full Code Here

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

  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

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

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