Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

XSECC14n20010315.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2002-2005 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * XSEC
00019  *
00020  * XSECC14n20010315 := Canonicaliser object to process XML document in line with
00021  *                       RFC 3076
00022  *
00023  * Author(s): Berin Lautenbach
00024  *
00025  * $Id: XSECC14n20010315.hpp,v 1.9 2005/02/03 13:09:31 milan Exp $
00026  *
00027  */
00028 
00029 #ifndef XSECC14n20010315_INCLUDE
00030 #define XSECC14n20010315_INCLUDE
00031 
00032 //XSEC includes
00033 #include <xsec/framework/XSECDefs.hpp>
00034 #include <xsec/utils/XSECSafeBuffer.hpp>
00035 #include <xsec/utils/XSECXPathNodeList.hpp>
00036 #include <xsec/canon/XSECCanon.hpp>
00037 
00038 #include <xercesc/framework/XMLFormatter.hpp>
00039 
00040 // General includes
00041 #include <memory.h>
00042 #include <vector>
00043 
00044 XSEC_USING_XERCES(XMLFormatter);
00045 XSEC_USING_XERCES(XMLFormatTarget);
00046 
00047 class XSECSafeBufferFormatter;
00048 
00049 // --------------------------------------------------------------------------------
00050 //           Simple structure for holding a list of nodes
00051 // --------------------------------------------------------------------------------
00052 
00053 // NOTE: We don't use NamedNodeMap or DOMNodeList as we are unsure what might happen
00054 // to them in the future.  Also, to add items we would have to delve into the inards
00055 // of Xerces (and use the "...impl" classes).  Such an approach might not be supported
00056 // in the future.
00057 
00058 struct XSECNodeListElt {
00059 
00060     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode  *element;   // Element referred to
00061     safeBuffer                      sortString; // The string that is used to sort the nodes
00062 
00063     XSECNodeListElt                 *next,
00064                                     *last;      // For the list
00065 
00066 };
00067 
00068 // Used for the sorting function
00069 
00070 #define XMLNS_PREFIX        "a"
00071 #define ATTRIBUTE_PREFIX    "b"
00072 
00073 #define NOURI_PREFIX         "a"
00074 #define HAVEURI_PREFIX       "b"
00075 
00076 // --------------------------------------------------------------------------------
00077 //           XSECC14n20010315 Object definition
00078 // --------------------------------------------------------------------------------
00079 
00080 class CANON_EXPORT XSECC14n20010315 : public XSECCanon {
00081 
00082 #if defined(XALAN_NO_NAMESPACES)
00083     typedef vector<char *>              CharListVectorType;
00084 #else
00085     typedef std::vector<char *>         CharListVectorType;
00086 #endif
00087 
00088 #if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
00089     typedef std::size_t     size_type;
00090 #else
00091     typedef size_t          size_type;
00092 #endif
00093 
00094 
00095 public:
00096 
00097     // Constructors
00098     XSECC14n20010315();
00099     XSECC14n20010315(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc);
00100     XSECC14n20010315(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *newDoc, 
00101                      XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newStartNode);
00102     virtual ~XSECC14n20010315();
00103 
00104     // XPath processor
00105 
00106     int XPathSelectNodes(const char * XPathExpr);
00107     void setXPathMap(const XSECXPathNodeList & map);
00108 
00109     // Comments processing
00110     void setCommentsProcessing(bool onoff);
00111     bool getCommentsProcessing(void);
00112 
00113     // Exclusive processing
00114     void setExclusive(void);
00115     void setExclusive(char * xmlnsList);
00116 
00117 protected:
00118 
00119     // Implementation of virtual function
00120     int processNextNode();
00121 
00122     // Test whether a name space is in the non-exclusive list
00123     bool inNonExclNSList(safeBuffer &ns);
00124 
00125 private:
00126 
00127     void XSECC14n20010315::init();
00128     bool checkRenderNameSpaceNode(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *e, 
00129                                   XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *a);
00130 
00131     // For formatting the buffers
00132     XSECSafeBufferFormatter     * mp_formatter;
00133     safeBuffer                  m_formatBuffer;
00134 
00135     // For holding state whilst walking the DOM tree
00136     XSECNodeListElt * mp_attributes,                // Start of list
00137                     * mp_currentAttribute,          // Where we currently are in list
00138                     * mp_firstNonNsAttribute;       // First NON XMLNS element in list
00139     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_attributeParent;            // To return up the tree
00140     bool m_returnedFromChild;                       // Did we get to this node from below?
00141     XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_firstElementNode;           // The root element of the document
00142     bool            m_firstElementProcessed;        // Has the first node been handled?
00143     unsigned char   * mp_charBuffer;
00144 
00145     // For XPath evaluation
00146     bool              m_XPathSelection;             // Are we doing an XPath?
00147     XSECXPathNodeList m_XPathMap;                   // The elements in the XPath
00148 
00149     // For comment processing
00150     bool            m_processComments;              // Whether comments are in or out (in by default)
00151 
00152     // For exclusive canonicalisation
00153     CharListVectorType      m_exclNSList;
00154     bool                    m_exclusive;
00155     bool                    m_exclusiveDefault;
00156 
00157 
00158 
00159 };
00160 
00161 
00162 #endif /* XSECC14n20010315_INCLUDE */
00163 
00164 

Generated on Sun Jul 3 17:37:28 2005 for XML-Security-C by  doxygen 1.4.2