Java Code Examples for org.apache.xml.security.signature.XMLSignatureInput#getSubNode()

The following examples show how to use org.apache.xml.security.signature.XMLSignatureInput#getSubNode() . 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: NippinOptionalDeflateTransformer.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private XMLSignatureInput processElement(XMLSignatureInput input, OutputStream os) throws TechnicalConnectorException, IOException {
   Node el = input.getSubNode();
   if (input.getSubNode().getNodeType() == 3) {
      el = el.getParentNode();
   }

   StringBuilder sb = new StringBuilder();
   this.traverseElement((Element)el, sb);
   if (os == null) {
      byte[] decodedBytes = ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8));
      return new XMLSignatureInput(decodedBytes);
   } else {
      os.write(ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8)));
      XMLSignatureInput output = new XMLSignatureInput((byte[])null);
      output.setOutputStream(os);
      return output;
   }
}
 
Example 2
Source File: NippinOptionalDeflateTransformer.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private XMLSignatureInput processElement(XMLSignatureInput input, OutputStream os) throws TechnicalConnectorException, IOException {
   Node el = input.getSubNode();
   if (input.getSubNode().getNodeType() == 3) {
      el = el.getParentNode();
   }

   StringBuilder sb = new StringBuilder();
   this.traverseElement((Element)el, sb);
   if (os == null) {
      byte[] decodedBytes = ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8));
      return new XMLSignatureInput(decodedBytes);
   } else {
      os.write(ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8)));
      XMLSignatureInput output = new XMLSignatureInput((byte[])null);
      output.setOutputStream(os);
      return output;
   }
}
 
Example 3
Source File: NippinOptionalDeflateTransformer.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private XMLSignatureInput processElement(XMLSignatureInput input, OutputStream os) throws TechnicalConnectorException, IOException {
   Node el = input.getSubNode();
   if (input.getSubNode().getNodeType() == 3) {
      el = el.getParentNode();
   }

   StringBuilder sb = new StringBuilder();
   this.traverseElement((Element)el, sb);
   if (os == null) {
      byte[] decodedBytes = ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8));
      return new XMLSignatureInput(decodedBytes);
   } else {
      os.write(ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8)));
      XMLSignatureInput output = new XMLSignatureInput((byte[])null);
      output.setOutputStream(os);
      return output;
   }
}
 
Example 4
Source File: NippinOptionalDeflateTransformer.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private XMLSignatureInput processElement(XMLSignatureInput input, OutputStream os) throws TechnicalConnectorException, IOException {
   Node el = input.getSubNode();
   if (input.getSubNode().getNodeType() == 3) {
      el = el.getParentNode();
   }

   StringBuilder sb = new StringBuilder();
   this.traverseElement((Element)el, sb);
   if (os == null) {
      byte[] decodedBytes = ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8));
      return new XMLSignatureInput(decodedBytes);
   } else {
      os.write(ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8)));
      XMLSignatureInput output = new XMLSignatureInput((byte[])null);
      output.setOutputStream(os);
      return output;
   }
}
 
Example 5
Source File: NippinOptionalDeflateTransformer.java    From freehealth-connector with GNU Affero General Public License v3.0 6 votes vote down vote up
private XMLSignatureInput processElement(XMLSignatureInput input, OutputStream os) throws TechnicalConnectorException, IOException {
   Node el = input.getSubNode();
   if (input.getSubNode().getNodeType() == 3) {
      el = el.getParentNode();
   }

   StringBuilder sb = new StringBuilder();
   this.traverseElement((Element)el, sb);
   if (os == null) {
      byte[] decodedBytes = ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8));
      return new XMLSignatureInput(decodedBytes);
   } else {
      os.write(ConnectorIOUtils.decompress(ConnectorIOUtils.toBytes(sb.toString(), Charset.UTF_8)));
      XMLSignatureInput output = new XMLSignatureInput((byte[])null);
      output.setOutputStream(os);
      return output;
   }
}
 
Example 6
Source File: QualifyingPropertyVerificationContext.java    From xades4j with GNU Lesser General Public License v3.0 5 votes vote down vote up
private <TObj> TObj getReferencedElement(
        String objReference,
        Map<Element, TObj> mapper)
{
    if (!objReference.startsWith("#"))
        throw new IllegalArgumentException();

    if (mapper.isEmpty())
        return null;

    // A little workaround to be able to use the ResourceResolver.
    Attr refAttr = this.signatureDoc.createAttributeNS(null, "ref");
    refAttr.setNodeValue(objReference);
    this.signatureDoc.createElementNS(null, "dummy").setAttributeNodeNS(refAttr);

    try
    {
        XMLSignatureInput refData = ResourceResolver.getInstance(refAttr, "", true).resolve(refAttr, "", true);
        // This has to be a NodeSet data because it is a same-document reference.
        Node refNode = refData.getSubNode();
        if (refNode.getNodeType() != Node.ELEMENT_NODE)
            return null;
        // May return null.
        return mapper.get((Element)refNode);
    } catch (ResourceResolverException ex)
    {
        // Maybe an exception should be thrown...
        return null;
    }
}