コード例 #1
0
  public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
      throws MarshalException {
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element pdElem = DOMUtils.createElement(ownerDoc, "PGPData", XMLSignature.XMLNS, dsPrefix);

    // create and append PGPKeyID element
    if (keyId != null) {
      Element keyIdElem =
          DOMUtils.createElement(ownerDoc, "PGPKeyID", XMLSignature.XMLNS, dsPrefix);
      keyIdElem.appendChild(ownerDoc.createTextNode(Base64.encode(keyId)));
      pdElem.appendChild(keyIdElem);
    }

    // create and append PGPKeyPacket element
    if (keyPacket != null) {
      Element keyPktElem =
          DOMUtils.createElement(ownerDoc, "PGPKeyPacket", XMLSignature.XMLNS, dsPrefix);
      keyPktElem.appendChild(ownerDoc.createTextNode(Base64.encode(keyPacket)));
      pdElem.appendChild(keyPktElem);
    }

    // create and append any elements
    for (int i = 0, size = externalElements.size(); i < size; i++) {
      DOMUtils.appendChild(
          pdElem, ((javax.xml.crypto.dom.DOMStructure) externalElements.get(i)).getNode());
    }

    parent.appendChild(pdElem);
  }
コード例 #2
0
  public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
      throws MarshalException {
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element propElem =
        DOMUtils.createElement(ownerDoc, "SignatureProperty", XMLSignature.XMLNS, dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(propElem, "Id", id);
    DOMUtils.setAttribute(propElem, "Target", target);

    // create and append any elements and mixed content
    for (int i = 0, size = content.size(); i < size; i++) {
      javax.xml.crypto.dom.DOMStructure property =
          (javax.xml.crypto.dom.DOMStructure) content.get(i);
      DOMUtils.appendChild(propElem, property.getNode());
    }

    parent.appendChild(propElem);
  }
コード例 #3
0
  public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
      throws MarshalException {
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    Element objElem = DOMUtils.createElement(ownerDoc, "Object", XMLSignature.XMLNS, dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(objElem, "Id", id);
    DOMUtils.setAttribute(objElem, "MimeType", mimeType);
    DOMUtils.setAttribute(objElem, "Encoding", encoding);

    // create and append any elements and mixed content, if necessary
    for (int i = 0, size = content.size(); i < size; i++) {
      XMLStructure object = (XMLStructure) content.get(i);
      if (object instanceof DOMStructure) {
        ((DOMStructure) object).marshal(objElem, dsPrefix, context);
      } else {
        javax.xml.crypto.dom.DOMStructure domObject = (javax.xml.crypto.dom.DOMStructure) object;
        DOMUtils.appendChild(objElem, domObject.getNode());
      }
    }

    parent.appendChild(objElem);
  }