/**
  * Set the xArchPath attribute on this object.
  *
  * @param xArchPath attribute value.
  */
 public void setXArchPath(String xArchPath) {
   {
     String oldValue = getXArchPath();
     if (oldValue == null ? xArchPath == null : oldValue.equals(xArchPath)) return;
     DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, X_ARCH_PATH_ATTR_NAME);
     IXArch _x = getXArch();
     if (_x != null) {
       _x.fireXArchEvent(
           new XArchEvent(
               this,
               XArchEvent.CLEAR_EVENT,
               XArchEvent.ATTRIBUTE_CHANGED,
               "xArchPath",
               oldValue,
               XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
               true));
     }
   }
   DOMUtils.setAttribute(elt, ChangesetsConstants.NS_URI, X_ARCH_PATH_ATTR_NAME, xArchPath);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.SET_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "xArchPath",
             xArchPath,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
  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);
  }
  public void addRepositoryLocation(IRepositoryLocation newRepositoryLocation) {
    if (!(newRepositoryLocation instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    Element newChildElt = (Element) (((DOMBased) newRepositoryLocation).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(
            newChildElt, JavasourcecodeConstants.NS_URI, REPOSITORY_LOCATION_ELT_NAME);
    ((DOMBased) newRepositoryLocation).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.ADD_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "repositoryLocation",
              newRepositoryLocation,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void removeRepositoryLocation(IRepositoryLocation repositoryLocationToRemove) {
    if (!(repositoryLocationToRemove instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    NodeList nl =
        DOMUtils.getChildren(elt, JavasourcecodeConstants.NS_URI, REPOSITORY_LOCATION_ELT_NAME);
    for (int i = 0; i < nl.getLength(); i++) {
      Node n = nl.item(i);
      if (n == ((DOMBased) repositoryLocationToRemove).getDOMNode()) {
        synchronized (DOMUtils.getDOMLock(elt)) {
          elt.removeChild(n);
        }

        IXArch context = getXArch();
        if (context != null) {
          context.fireXArchEvent(
              new XArchEvent(
                  this,
                  XArchEvent.REMOVE_EVENT,
                  XArchEvent.ELEMENT_CHANGED,
                  "repositoryLocation",
                  repositoryLocationToRemove,
                  XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
        }

        return;
      }
    }
  }
Esempio n. 5
0
 /**
  * Set the generated attribute on this object.
  *
  * @param generated attribute value.
  */
 public void setGenerated(String generated) {
   {
     String oldValue = getGenerated();
     if (oldValue == null ? generated == null : oldValue.equals(generated)) return;
     DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, GENERATED_ATTR_NAME);
     IXArch _x = getXArch();
     if (_x != null) {
       _x.fireXArchEvent(
           new XArchEvent(
               this,
               XArchEvent.CLEAR_EVENT,
               XArchEvent.ATTRIBUTE_CHANGED,
               "generated",
               oldValue,
               XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
               true));
     }
   }
   DOMUtils.setAttribute(elt, ChangesetsConstants.NS_URI, GENERATED_ATTR_NAME, generated);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.SET_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "generated",
             generated,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
 /** For internal use only. */
 private static Object makeDerivedWrapper(Element elt, String baseTypeName) {
   synchronized (DOMUtils.getDOMLock(elt)) {
     QName typeName = XArchUtils.getXSIType(elt);
     if (typeName == null) {
       return null;
     } else {
       if (!DOMUtils.hasXSIType(
           elt, "http://www.ics.uci.edu/pub/arch/xArch/changesets.xsd", baseTypeName)) {
         try {
           String packageTitle = XArchUtils.getPackageTitle(typeName.getNamespaceURI());
           String packageName = XArchUtils.getPackageName(packageTitle);
           String implName = XArchUtils.getImplName(packageName, typeName.getName());
           Class c = Class.forName(implName);
           java.lang.reflect.Constructor con = c.getConstructor(new Class[] {Element.class});
           Object o = con.newInstance(new Object[] {elt});
           return o;
         } catch (Exception e) {
           // Lots of bad things could happen, but this
           // is OK, because this is best-effort anyway.
         }
       }
       return null;
     }
   }
 }
  public void digest(XMLSignContext signContext) throws XMLSignatureException {
    Data data = null;
    if (appliedTransformData == null) {
      data = dereference(signContext);
    } else {
      data = appliedTransformData;
    }
    digestValue = transform(data, signContext);

    // insert digestValue into DigestValue element
    String encodedDV = Base64.encode(digestValue);
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE, "Reference object uri = " + uri);
    }
    Element digestElem = DOMUtils.getLastChildElement(refElem);
    if (digestElem == null) {
      throw new XMLSignatureException("DigestValue element expected");
    }
    DOMUtils.removeAllChildren(digestElem);
    digestElem.appendChild(refElem.getOwnerDocument().createTextNode(encodedDV));

    digested = true;
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE, "Reference digesting completed");
    }
  }
  public IJavaSourceCodeManager getSourceCodeManager() {
    NodeList nl =
        DOMUtils.getChildren(elt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);
    if (nl.getLength() == 0) {
      return null;
    } else {
      Element el = (Element) nl.item(0);
      IXArch de = getXArch();
      if (de != null) {
        IXArchElement cachedXArchElt = de.getWrapper(el);
        if (cachedXArchElt != null) {
          return (IJavaSourceCodeManager) cachedXArchElt;
        }
      }

      Object o = makeDerivedWrapper(el, "JavaSourceCodeManager");
      if (o != null) {
        try {
          ((edu.uci.isr.xarch.IXArchElement) o).setXArch(getXArch());
          if (de != null) {
            de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) o));
          }
          return (IJavaSourceCodeManager) o;
        } catch (Exception e) {
        }
      }
      JavaSourceCodeManagerImpl eltImpl = new JavaSourceCodeManagerImpl(el);
      eltImpl.setXArch(getXArch());
      if (de != null) {
        de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) eltImpl));
      }
      return eltImpl;
    }
  }
Esempio n. 9
0
  private boolean equalsContent(List otherContent) {
    if (content.size() != otherContent.size()) {
      return false;
    }
    for (int i = 0, osize = otherContent.size(); i < osize; i++) {
      XMLStructure oxs = (XMLStructure) otherContent.get(i);
      XMLStructure xs = (XMLStructure) content.get(i);
      if (oxs instanceof javax.xml.crypto.dom.DOMStructure) {
        if (!(xs instanceof javax.xml.crypto.dom.DOMStructure)) {
          return false;
        }
        Node onode = ((javax.xml.crypto.dom.DOMStructure) oxs).getNode();
        Node node = ((javax.xml.crypto.dom.DOMStructure) xs).getNode();
        if (!DOMUtils.nodesEqual(node, onode)) {
          return false;
        }
      } else {
        if (!(xs.equals(oxs))) {
          return false;
        }
      }
    }

    return true;
  }
  public edu.uci.isr.xarch.instance.IXMLLink getChangeSet() {
    NodeList nl = DOMUtils.getChildren(elt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);
    if (nl.getLength() == 0) {
      return null;
    } else {
      Element el = (Element) nl.item(0);
      IXArch de = getXArch();
      if (de != null) {
        IXArchElement cachedXArchElt = de.getWrapper(el);
        if (cachedXArchElt != null) {
          return (edu.uci.isr.xarch.instance.IXMLLink) cachedXArchElt;
        }
      }

      Object o = makeDerivedWrapper(el, "XMLLink");
      if (o != null) {
        try {
          ((edu.uci.isr.xarch.IXArchElement) o).setXArch(getXArch());
          if (de != null) {
            de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) o));
          }
          return (edu.uci.isr.xarch.instance.IXMLLink) o;
        } catch (Exception e) {
        }
      }
      edu.uci.isr.xarch.instance.XMLLinkImpl eltImpl =
          new edu.uci.isr.xarch.instance.XMLLinkImpl(el);
      eltImpl.setXArch(getXArch());
      if (de != null) {
        de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) eltImpl));
      }
      return eltImpl;
    }
  }
  public IXArchElement cloneElement(int depth) {
    synchronized (DOMUtils.getDOMLock(elt)) {
      Document doc = elt.getOwnerDocument();
      if (depth == 0) {
        Element cloneElt = (Element) elt.cloneNode(false);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());
        return cloneImpl;
      } else if (depth == 1) {
        Element cloneElt = (Element) elt.cloneNode(false);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());

        NodeList nl = elt.getChildNodes();
        int size = nl.getLength();
        for (int i = 0; i < size; i++) {
          Node n = nl.item(i);
          Node cloneNode = (Node) n.cloneNode(false);
          cloneNode = doc.importNode(cloneNode, true);
          cloneElt.appendChild(cloneNode);
        }
        return cloneImpl;
      } else /* depth = infinity */ {
        Element cloneElt = (Element) elt.cloneNode(true);
        cloneElt = (Element) doc.importNode(cloneElt, true);
        AbstractChangeSetImpl cloneImpl = new AbstractChangeSetImpl(cloneElt);
        cloneImpl.setXArch(getXArch());
        return cloneImpl;
      }
    }
  }
  public void setSourceCodeManager(IJavaSourceCodeManager value) {
    if (!(value instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    {
      IJavaSourceCodeManager oldElt = getSourceCodeManager();
      DOMUtils.removeChildren(elt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);

      IXArch context = getXArch();
      if (context != null) {
        context.fireXArchEvent(
            new XArchEvent(
                this,
                XArchEvent.CLEAR_EVENT,
                XArchEvent.ELEMENT_CHANGED,
                "sourceCodeManager",
                oldElt,
                XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
                true));
      }
    }
    Element newChildElt = (Element) (((DOMBased) value).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(
            newChildElt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);
    ((DOMBased) value).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.SET_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "sourceCodeManager",
              value,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void setChangeSet(edu.uci.isr.xarch.instance.IXMLLink value) {
    if (!(value instanceof DOMBased)) {
      throw new IllegalArgumentException("Cannot handle non-DOM-based xArch entities.");
    }
    {
      edu.uci.isr.xarch.instance.IXMLLink oldElt = getChangeSet();
      DOMUtils.removeChildren(elt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);

      IXArch context = getXArch();
      if (context != null) {
        context.fireXArchEvent(
            new XArchEvent(
                this,
                XArchEvent.CLEAR_EVENT,
                XArchEvent.ELEMENT_CHANGED,
                "changeSet",
                oldElt,
                XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this),
                true));
      }
    }
    Element newChildElt = (Element) (((DOMBased) value).getDOMNode());
    newChildElt =
        DOMUtils.cloneAndRename(newChildElt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);
    ((DOMBased) value).setDOMNode(newChildElt);

    synchronized (DOMUtils.getDOMLock(elt)) {
      elt.appendChild(newChildElt);
      DOMUtils.order(elt, getSequenceOrder());
    }

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.SET_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "changeSet",
              value,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
Esempio n. 14
0
  /**
   * Creates an <code>XMLObject</code> from an element.
   *
   * @param objElem an Object element
   * @throws MarshalException if there is an error when unmarshalling
   */
  public DOMXMLObject(Element objElem, XMLCryptoContext context, Provider provider)
      throws MarshalException {
    // unmarshal attributes
    this.encoding = DOMUtils.getAttributeValue(objElem, "Encoding");

    Attr attr = objElem.getAttributeNodeNS(null, "Id");
    if (attr != null) {
      this.id = attr.getValue();
      objElem.setIdAttributeNode(attr, true);
    } else {
      this.id = null;
    }
    this.mimeType = DOMUtils.getAttributeValue(objElem, "MimeType");

    NodeList nodes = objElem.getChildNodes();
    int length = nodes.getLength();
    List content = new ArrayList(length);
    for (int i = 0; i < length; i++) {
      Node child = nodes.item(i);
      if (child.getNodeType() == Node.ELEMENT_NODE) {
        Element childElem = (Element) child;
        String tag = childElem.getLocalName();
        if (tag.equals("Manifest")) {
          content.add(new DOMManifest(childElem, context, provider));
          continue;
        } else if (tag.equals("SignatureProperties")) {
          content.add(new DOMSignatureProperties(childElem));
          continue;
        } else if (tag.equals("X509Data")) {
          content.add(new DOMX509Data(childElem));
          continue;
        }
        // @@@FIXME: check for other dsig structures
      }
      content.add(new javax.xml.crypto.dom.DOMStructure(child));
    }
    if (content.isEmpty()) {
      this.content = Collections.EMPTY_LIST;
    } else {
      this.content = Collections.unmodifiableList(content);
    }
  }
  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);
  }
  /**
   * Creates a <code>DOMSignatureProperty</code> from an element.
   *
   * @param propElem a SignatureProperty element
   */
  public DOMSignatureProperty(Element propElem) throws MarshalException {
    // unmarshal attributes
    target = DOMUtils.getAttributeValue(propElem, "Target");
    if (target == null) {
      throw new MarshalException("target cannot be null");
    }
    id = DOMUtils.getAttributeValue(propElem, "Id");

    NodeList nodes = propElem.getChildNodes();
    int length = nodes.getLength();
    List content = new ArrayList(length);
    for (int i = 0; i < length; i++) {
      content.add(new javax.xml.crypto.dom.DOMStructure(nodes.item(i)));
    }
    if (content.isEmpty()) {
      throw new MarshalException("content cannot be empty");
    } else {
      this.content = Collections.unmodifiableList(content);
    }
  }
Esempio n. 17
0
 /** Removes the id attribute from this object. */
 public void clearId() {
   String oldValue = getId();
   if (oldValue == null) return;
   DOMUtils.removeAttribute(elt, ChangesetsConstants.NS_URI, ID_ATTR_NAME);
   IXArch _x = getXArch();
   if (_x != null) {
     _x.fireXArchEvent(
         new XArchEvent(
             this,
             XArchEvent.CLEAR_EVENT,
             XArchEvent.ATTRIBUTE_CHANGED,
             "id",
             oldValue,
             XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
   }
 }
  public void clearSourceCodeManager() {
    IJavaSourceCodeManager oldElt = getSourceCodeManager();
    DOMUtils.removeChildren(elt, JavasourcecodeConstants.NS_URI, SOURCE_CODE_MANAGER_ELT_NAME);

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.CLEAR_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "sourceCodeManager",
              oldElt,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
  public void clearChangeSet() {
    edu.uci.isr.xarch.instance.IXMLLink oldElt = getChangeSet();
    DOMUtils.removeChildren(elt, ChangesetsConstants.NS_URI, CHANGE_SET_ELT_NAME);

    IXArch context = getXArch();
    if (context != null) {
      context.fireXArchEvent(
          new XArchEvent(
              this,
              XArchEvent.CLEAR_EVENT,
              XArchEvent.ELEMENT_CHANGED,
              "changeSet",
              oldElt,
              XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, this)));
    }
  }
 public Collection getAllRepositoryLocations() {
   NodeList nl =
       DOMUtils.getChildren(elt, JavasourcecodeConstants.NS_URI, REPOSITORY_LOCATION_ELT_NAME);
   int nlLength = nl.getLength();
   ArrayList v = new ArrayList(nlLength);
   IXArch de = getXArch();
   for (int i = 0; i < nlLength; i++) {
     Element el = (Element) nl.item(i);
     boolean found = false;
     if (de != null) {
       IXArchElement cachedXArchElt = de.getWrapper(el);
       if (cachedXArchElt != null) {
         v.add((IRepositoryLocation) cachedXArchElt);
         found = true;
       }
     }
     if (!found) {
       Object o = makeDerivedWrapper(el, "RepositoryLocation");
       if (o != null) {
         try {
           ((edu.uci.isr.xarch.IXArchElement) o).setXArch(getXArch());
           if (de != null) {
             de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) o));
           }
           v.add((IRepositoryLocation) o);
         } catch (Exception e) {
           RepositoryLocationImpl eltImpl = new RepositoryLocationImpl((Element) nl.item(i));
           eltImpl.setXArch(getXArch());
           if (de != null) {
             de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) eltImpl));
           }
           v.add(eltImpl);
         }
       } else {
         RepositoryLocationImpl eltImpl = new RepositoryLocationImpl((Element) nl.item(i));
         eltImpl.setXArch(getXArch());
         if (de != null) {
           de.cacheWrapper(el, ((edu.uci.isr.xarch.IXArchElement) eltImpl));
         }
         v.add(eltImpl);
       }
     }
   }
   return v;
 }
Esempio n. 21
0
  /**
   * Creates a <code>DOMReference</code> from an element.
   *
   * @param refElem a Reference element
   */
  public DOMReference(Element refElem, XMLCryptoContext context) throws MarshalException {
    // unmarshal Transforms, if specified
    Element nextSibling = DOMUtils.getFirstChildElement(refElem);
    List transforms = new ArrayList(5);
    if (nextSibling.getLocalName().equals("Transforms")) {
      Element transformElem = DOMUtils.getFirstChildElement(nextSibling);
      while (transformElem != null) {
        transforms.add(new DOMTransform(transformElem, context));
        transformElem = DOMUtils.getNextSiblingElement(transformElem);
      }
      nextSibling = DOMUtils.getNextSiblingElement(nextSibling);
    }

    // unmarshal DigestMethod
    Element dmElem = nextSibling;
    this.digestMethod = DOMDigestMethod.unmarshal(dmElem);

    // unmarshal DigestValue
    try {
      Element dvElem = DOMUtils.getNextSiblingElement(dmElem);
      this.digestValue = Base64.decode(dvElem);
    } catch (Base64DecodingException bde) {
      throw new MarshalException(bde);
    }

    // unmarshal attributes
    this.uri = DOMUtils.getAttributeValue(refElem, "URI");
    this.id = DOMUtils.getAttributeValue(refElem, "Id");

    this.type = DOMUtils.getAttributeValue(refElem, "Type");
    this.here = refElem.getAttributeNodeNS(null, "URI");
    this.refElem = refElem;

    if (transforms.isEmpty()) {
      this.transforms = Collections.EMPTY_LIST;
    } else {
      this.transforms = Collections.unmodifiableList(transforms);
    }
    this.appliedTransforms = Collections.EMPTY_LIST;
    this.allTransforms = transforms;
    this.appliedTransformData = null;
  }
Esempio n. 22
0
  public void marshal(Node parent, String dsPrefix, DOMCryptoContext context)
      throws MarshalException {
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE, "Marshalling Reference");
    }
    Document ownerDoc = DOMUtils.getOwnerDocument(parent);

    refElem = DOMUtils.createElement(ownerDoc, "Reference", XMLSignature.XMLNS, dsPrefix);

    // set attributes
    DOMUtils.setAttributeID(refElem, "Id", id);
    DOMUtils.setAttribute(refElem, "URI", uri);
    DOMUtils.setAttribute(refElem, "Type", type);

    // create and append Transforms element
    if (!transforms.isEmpty() || !appliedTransforms.isEmpty()) {
      Element transformsElem =
          DOMUtils.createElement(ownerDoc, "Transforms", XMLSignature.XMLNS, dsPrefix);
      refElem.appendChild(transformsElem);
      for (int i = 0, size = appliedTransforms.size(); i < size; i++) {
        DOMStructure transform = (DOMStructure) appliedTransforms.get(i);
        transform.marshal(transformsElem, dsPrefix, context);
      }
      for (int i = 0, size = transforms.size(); i < size; i++) {
        DOMStructure transform = (DOMStructure) transforms.get(i);
        transform.marshal(transformsElem, dsPrefix, context);
      }
    }

    // create and append DigestMethod element
    ((DOMDigestMethod) digestMethod).marshal(refElem, dsPrefix, context);

    // create and append DigestValue element
    if (log.isLoggable(Level.FINE)) {
      log.log(Level.FINE, "Adding digestValueElem");
    }
    Element digestValueElem =
        DOMUtils.createElement(ownerDoc, "DigestValue", XMLSignature.XMLNS, dsPrefix);
    if (digestValue != null) {
      digestValueElem.appendChild(ownerDoc.createTextNode(Base64.encode(digestValue)));
    }
    refElem.appendChild(digestValueElem);

    parent.appendChild(refElem);
    here = refElem.getAttributeNodeNS(null, "URI");
  }
Esempio n. 23
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);
  }
Esempio n. 24
0
 /**
  * Determines if this object's generated attribute has the given value.
  *
  * @param generated value to test.
  * @return <code>true</code> if the values match, <code>false</code> otherwise. Matching is done
  *     by string-matching.
  */
 public boolean hasGenerated(String generated) {
   return DOMUtils.objNullEq(getGenerated(), generated);
 }
Esempio n. 25
0
 /**
  * Gets the value of the generated attribute on this object.
  *
  * @return generated attribute's value or <code>null</code> if that attribute is not set.
  */
 public String getGenerated() {
   return DOMUtils.getAttributeValue(elt, ChangesetsConstants.NS_URI, GENERATED_ATTR_NAME);
 }
Esempio n. 26
0
 /**
  * Determines if this object's id attribute has the given value.
  *
  * @param id value to test.
  * @return <code>true</code> if the values match, <code>false</code> otherwise. Matching is done
  *     by string-matching.
  */
 public boolean hasId(String id) {
   return DOMUtils.objNullEq(getId(), id);
 }
Esempio n. 27
0
 /**
  * Gets the value of the id attribute on this object.
  *
  * @return id attribute's value or <code>null</code> if that attribute is not set.
  */
 public String getId() {
   return DOMUtils.getAttributeValue(elt, ChangesetsConstants.NS_URI, ID_ATTR_NAME);
 }
 /**
  * Gets the value of the xArchPath attribute on this object.
  *
  * @return xArchPath attribute's value or <code>null</code> if that attribute is not set.
  */
 public String getXArchPath() {
   return DOMUtils.getAttributeValue(elt, ChangesetsConstants.NS_URI, X_ARCH_PATH_ATTR_NAME);
 }
 /**
  * Determines if this object's xArchPath attribute has the given value.
  *
  * @param xArchPath value to test.
  * @return <code>true</code> if the values match, <code>false</code> otherwise. Matching is done
  *     by string-matching.
  */
 public boolean hasXArchPath(String xArchPath) {
   return DOMUtils.objNullEq(getXArchPath(), xArchPath);
 }