blautenb    2003/05/01 03:04:36

  Modified:    c/src/dsig DSIGTransformC14n.cpp DSIGTransformC14n.hpp
  Log:
  Added API function to Exclusive Canonicaliser to add enter prefixes list (tx 
Scott Cantor)
  
  Revision  Changes    Path
  1.9       +68 -26    xml-security/c/src/dsig/DSIGTransformC14n.cpp
  
  Index: DSIGTransformC14n.cpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformC14n.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DSIGTransformC14n.cpp     30 Apr 2003 11:41:14 -0000      1.8
  +++ DSIGTransformC14n.cpp     1 May 2003 10:04:36 -0000       1.9
  @@ -299,7 +299,46 @@
   
   }
   
  -void DSIGTransformC14n::addInclusiveNamespace(const char * ns) {
  +void DSIGTransformC14n::createInclusiveNamespaceNode(void) {
  +
  +     // Creates an empty inclusiveNamespace node.  Does _not_ set the 
prefixlist attribute
  +
  +     if (mp_inclNSNode != NULL)
  +             return;         // Already exists
  +
  +     safeBuffer str;
  +     const XMLCh * prefix;
  +     DOMDocument *doc = mp_parentSignature->getParentDocument();
  +
  +     // Use the Exclusive Canonicalisation prefix
  +     prefix = mp_parentSignature->getECNSPrefix();
  +
  +     // Create the transform node
  +     makeQName(str, prefix, "InclusiveNamespaces");
  +     mp_inclNSNode = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
  +
  +     // Add the node to the owner element
  +     
mp_txfmNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +     mp_txfmNode->appendChild(mp_inclNSNode);
  +     
mp_txfmNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  +
  +     // Set the namespace attribute
  +     if (prefix[0] == '\0') {
  +             str.sbTranscodeIn("xmlns");
  +     }
  +     else {
  +             str.sbTranscodeIn("xmlns:");
  +             str.sbXMLChCat(prefix);
  +     }
  +
  +     mp_inclNSNode->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS, 
  +                                                     str.rawXMLChBuffer(), 
  +                                                     
DSIGConstants::s_unicodeStrURIEC);
  +}
  +
  +void DSIGTransformC14n::setInclusiveNamespaces(XMLCh * ns) {
  +
  +     // Set all the namespaces at once
   
        if (m_cMethod != CANON_C14NE_COM && m_cMethod != CANON_C14NE_NOC) {
   
  @@ -310,36 +349,39 @@
   
        if (mp_inclNSNode == NULL) {
   
  -             safeBuffer str;
  -             const XMLCh * prefix;
  -             DOMDocument *doc = mp_parentSignature->getParentDocument();
  +             // Create the transform node
  +             createInclusiveNamespaceNode();
  +
  +
  +     }
   
  -             // Use the Exclusive Canonicalisation prefix
  -             prefix = mp_parentSignature->getECNSPrefix();
  +     // Now create the prefix list
  +
  +     mp_inclNSNode->setAttribute(MAKE_UNICODE_STRING("PrefixList"), ns);
  +     mp_inclNSStr = 
mp_inclNSNode->getAttributes()->getNamedItem(MAKE_UNICODE_STRING("PrefixList"))->getNodeValue();
  +
  +}
  +
  +
  +void DSIGTransformC14n::addInclusiveNamespace(const char * ns) {
  +
  +     if (m_cMethod != CANON_C14NE_COM && m_cMethod != CANON_C14NE_NOC) {
  +
  +             throw XSECException(XSECException::TransformError,
  +                     "Cannot set inclusive namespaces on non Exclusive 
Canonicalisation");
  +
  +     }
  +
  +     if (mp_inclNSNode == NULL) {
   
                // Create the transform node
  -             makeQName(str, prefix, "InclusiveNamespaces");
  -             mp_inclNSNode = 
doc->createElementNS(DSIGConstants::s_unicodeStrURIDSIG, str.rawXMLChBuffer());
  +             createInclusiveNamespaceNode();
  +
  +             // Now create the prefix list
  +
                mp_inclNSNode->setAttribute(MAKE_UNICODE_STRING("PrefixList"), 
MAKE_UNICODE_STRING(ns));
                mp_inclNSStr = 
mp_inclNSNode->getAttributes()->getNamedItem(MAKE_UNICODE_STRING("PrefixList"))->getNodeValue();
   
  -             // Add the node
  -             
mp_txfmNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -             mp_txfmNode->appendChild(mp_inclNSNode);
  -             
mp_txfmNode->appendChild(doc->createTextNode(DSIGConstants::s_unicodeStrNL));
  -
  -             // Set the namespace attribute
  -             if (prefix[0] == '\0') {
  -                     str.sbTranscodeIn("xmlns");
  -             }
  -             else {
  -                     str.sbTranscodeIn("xmlns:");
  -                     str.sbXMLChCat(prefix);
  -             }
  -
  -             
mp_inclNSNode->setAttributeNS(DSIGConstants::s_unicodeStrURIXMLNS, 
  -                                                             
str.rawXMLChBuffer(), 
  -                                                             
DSIGConstants::s_unicodeStrURIEC);
        }
   
        else {
  
  
  
  1.5       +17 -1     xml-security/c/src/dsig/DSIGTransformC14n.hpp
  
  Index: DSIGTransformC14n.hpp
  ===================================================================
  RCS file: /home/cvs/xml-security/c/src/dsig/DSIGTransformC14n.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DSIGTransformC14n.hpp     22 Feb 2003 08:47:23 -0000      1.4
  +++ DSIGTransformC14n.hpp     1 May 2003 10:04:36 -0000       1.5
  @@ -222,6 +222,19 @@
        void addInclusiveNamespace(const char * ns);
   
        /**
  +      * \brief Set the namespace list
  +      *
  +      * Deletes current PrefixList (if any) and sets the list to the space
  +      * separated list of namespace prefixes provided in ns.
  +      *
  +      * @note No checking is done on the string passed in.
  +      *
  +      * @param ns The (space separated) list of prefixes to set.
  +      */
  +
  +     void DSIGTransformC14n::setInclusiveNamespaces(XMLCh * ns);
  +     
  +     /**
         * \brief Get the string containing the inclusive namespaces.
         *
         * Get the string containing a list of (space separated) prefixes that 
will
  @@ -249,6 +262,9 @@
   
        DSIGTransformC14n();
        DSIGTransformC14n(const DSIGTransformC14n & theOther);
  +
  +     void createInclusiveNamespaceNode(void);
  +
   
        canonicalizationMethod                  m_cMethod;                      
// The method
        DOMElement                                              * 
mp_inclNSNode;        // Node holding the inclusive Namespaces
  
  
  

Reply via email to