javax.xml.crypto.dom.DOMStructure Java Examples
The following examples show how to use
javax.xml.crypto.dom.DOMStructure.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Signer.java From IDES-Data-Preparation-Java with Creative Commons Zero v1.0 Universal | 6 votes |
protected List<XMLStructure> getSignaturePropertyList(Document doc, SigDocType sigDocType) throws Exception { List<XMLStructure> list = new ArrayList<XMLStructure>(); if (isAddSignaturePropTimestamp && sigDocType != SigDocType.BINARY) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy'T'HH:mm:ss.SSS'Z'"); sdf.setTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC)); Element tselem; if (signaturePrefix == null || "".equals(signaturePrefix)) tselem = doc.createElementNS(XMLSignature.XMLNS, "Timestamp"); else tselem = doc.createElementNS(XMLSignature.XMLNS, signaturePrefix + ":Timestamp"); tselem.appendChild(doc.createTextNode(sdf.format(new Date()))); list.add(new DOMStructure(tselem)); //may add additional properties in future } return list; }
Example #2
Source File: Marshal.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #3
Source File: Marshal.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #4
Source File: Marshal.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #5
Source File: Marshal.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #6
Source File: Marshal.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #7
Source File: Marshal.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #8
Source File: Marshal.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #9
Source File: Marshal.java From hottub with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #10
Source File: Marshal.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #11
Source File: Marshal.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #12
Source File: Marshal.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #13
Source File: SignatureVerifier.java From IDES-Data-Preparation-Java with Creative Commons Zero v1.0 Universal | 5 votes |
protected void setSigPublicKeyFromXml(String xml, DocumentBuilder docBuilderNSTrue) throws Exception { xml = sigStartElemToWrapXml + xml + sigEndElemToWrapXml; Document doc = docBuilderNSTrue.parse(new InputSource(new StringReader(xml))); DOMStructure ds = new DOMStructure(doc.getDocumentElement().getFirstChild()); KeyInfo keyInfo = KeyInfoFactory.getInstance().unmarshalKeyInfo(ds); List<?> list = keyInfo.getContent(); for (int i = 0; i < list.size(); i++) { XMLStructure xmlStructure = (XMLStructure) list.get(i); if (xmlStructure instanceof KeyValue) { try { sigPublicKey = ((KeyValue)xmlStructure).getPublicKey(); } catch(KeyException ke) { throw new KeySelectorException(ke.getMessage()); } break; } else if (xmlStructure instanceof X509Data) { X509Data x509data = (X509Data)xmlStructure; List<?> x509datalist = x509data.getContent(); for (int j = 0; j < x509datalist.size(); j++) { if (x509datalist.get(j) instanceof X509Certificate) { X509Certificate cert = (X509Certificate)x509datalist.get(j); sigPublicKey = cert.getPublicKey(); break; } } } } }
Example #14
Source File: Marshal.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #15
Source File: Marshal.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { KeyInfoFactory fac = KeyInfoFactory.getInstance(); KeyInfo ki = fac.newKeyInfo (Collections.singletonList(fac.newKeyName("foo")), "keyid"); try { ki.marshal(null, null); throw new Exception("Should raise a NullPointerException"); } catch (NullPointerException npe) {} DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setNamespaceAware(true); Document doc = dbf.newDocumentBuilder().newDocument(); Element elem = doc.createElementNS("http://acme.org", "parent"); doc.appendChild(elem); DOMStructure parent = new DOMStructure(elem); ki.marshal(parent, null); Element kiElem = DOMUtils.getFirstChildElement(elem); if (!kiElem.getLocalName().equals("KeyInfo")) { throw new Exception ("Should be KeyInfo element: " + kiElem.getLocalName()); } Element knElem = DOMUtils.getFirstChildElement(kiElem); if (!knElem.getLocalName().equals("KeyName")) { throw new Exception ("Should be KeyName element: " + knElem.getLocalName()); } }
Example #16
Source File: SamlDescriptorIDPKeysExtractor.java From keycloak with Apache License 2.0 | 5 votes |
private KeyInfo processKeyDescriptor(Element keyDescriptor) throws MarshalException { NodeList childNodes = keyDescriptor.getElementsByTagNameNS(JBossSAMLURIConstants.XMLDSIG_NSURI.get(), XmlDSigQNames.KEY_INFO.getQName().getLocalPart()); if (childNodes.getLength() == 0) { return null; } Node keyInfoNode = childNodes.item(0); return (keyInfoNode == null) ? null : kif.unmarshalKeyInfo(new DOMStructure(keyInfoNode)); }