List of usage examples for javax.xml.crypto Data getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:be.fedict.eid.applet.service.signer.ooxml.RelationshipTransformService.java
public Data transform(Data data, XMLCryptoContext context) throws TransformException { LOG.debug("transform(data,context)"); LOG.debug("data java type: " + data.getClass().getName()); OctetStreamData octetStreamData = (OctetStreamData) data; LOG.debug("URI: " + octetStreamData.getURI()); InputStream octetStream = octetStreamData.getOctetStream(); Document relationshipsDocument; try {/* ww w. j a v a 2s.c o m*/ relationshipsDocument = loadDocument(octetStream); } catch (Exception e) { throw new TransformException(e.getMessage(), e); } try { LOG.debug("relationships document: " + toString(relationshipsDocument)); } catch (TransformerException e) { throw new TransformException(e.getMessage(), e); } Element nsElement = relationshipsDocument.createElement("ns"); nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:tns", "http://schemas.openxmlformats.org/package/2006/relationships"); Element relationshipsElement = relationshipsDocument.getDocumentElement(); NodeList childNodes = relationshipsElement.getChildNodes(); for (int nodeIdx = 0; nodeIdx < childNodes.getLength(); nodeIdx++) { Node childNode = childNodes.item(nodeIdx); if (Node.ELEMENT_NODE != childNode.getNodeType()) { LOG.debug("removing node"); relationshipsElement.removeChild(childNode); nodeIdx--; continue; } Element childElement = (Element) childNode; String idAttribute = childElement.getAttribute("Id"); String typeAttribute = childElement.getAttribute("Type"); LOG.debug("Relationship id attribute: " + idAttribute); LOG.debug("Relationship type attribute: " + typeAttribute); if (false == this.sourceIds.contains(idAttribute) && false == this.sourceTypes.contains(typeAttribute)) { LOG.debug("removing Relationship element: " + idAttribute); relationshipsElement.removeChild(childNode); nodeIdx--; } /* * See: ISO/IEC 29500-2:2008(E) - 13.2.4.24 Relationships Transform * Algorithm. */ if (null == childElement.getAttributeNode("TargetMode")) { childElement.setAttribute("TargetMode", "Internal"); } } LOG.debug("# Relationship elements: " + relationshipsElement.getElementsByTagName("*").getLength()); sortRelationshipElements(relationshipsElement); try { return toOctetStreamData(relationshipsDocument); } catch (TransformerException e) { throw new TransformException(e.getMessage(), e); } }
From source file:org.apache.jcp.xml.dsig.internal.dom.DOMReference.java
private Data dereference(XMLCryptoContext context) throws XMLSignatureException { Data data = null; // use user-specified URIDereferencer if specified; otherwise use deflt URIDereferencer deref = context.getURIDereferencer(); if (deref == null) { deref = DOMURIDereferencer.INSTANCE; }// ww w . j a v a2s . com try { data = deref.dereference(this, context); if (log.isDebugEnabled()) { log.debug("URIDereferencer class name: " + deref.getClass().getName()); log.debug("Data class name: " + data.getClass().getName()); } } catch (URIReferenceException ure) { throw new XMLSignatureException(ure); } return data; }