Moved signature classes into own namespace.
authorScott Cantor <cantor.2@osu.edu>
Sun, 2 Apr 2006 22:04:40 +0000 (22:04 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sun, 2 Apr 2006 22:04:40 +0000 (22:04 +0000)
xmltooling/XMLObject.h
xmltooling/XMLToolingConfig.cpp
xmltooling/base.h
xmltooling/io/AbstractXMLObjectMarshaller.cpp
xmltooling/signature/KeyInfo.h
xmltooling/signature/Signature.h
xmltooling/signature/SigningContext.h
xmltooling/signature/VerifyingContext.h
xmltooling/signature/impl/KeyInfoImpl.cpp
xmltooling/signature/impl/XMLSecSignatureImpl.cpp
xmltoolingtest/XMLObjectBaseTestCase.h

index 46157b8..89466a5 100644 (file)
 \r
 using namespace xercesc;\r
 \r
+#ifndef XMLTOOLING_NO_XMLSEC\r
+namespace xmlsignature {\r
+    class XMLTOOL_API Signature;\r
+    class XMLTOOL_API SigningContext;\r
+};\r
+#endif\r
+\r
 #if defined (_MSC_VER)\r
     #pragma warning( push )\r
     #pragma warning( disable : 4250 4251 )\r
@@ -39,11 +46,6 @@ using namespace xercesc;
 \r
 namespace xmltooling {\r
 \r
-#ifndef XMLTOOLING_NO_XMLSEC\r
-    class XMLTOOL_API Signature;\r
-    class XMLTOOL_API SigningContext;\r
-#endif\r
-\r
     /**\r
      * Supplies additional information to the marshalling process.\r
      * Currently this only consists of signature related information.\r
@@ -65,12 +67,12 @@ namespace xmltooling {
          * @param sig   a signature object\r
          * @param ctx   the signing context to associate with the signature \r
          */\r
-        MarshallingContext(Signature* sig, const SigningContext* ctx) {\r
+        MarshallingContext(xmlsignature::Signature* sig, const xmlsignature::SigningContext* ctx) {\r
             m_signingContexts.push_back(std::make_pair(sig,ctx));\r
         }\r
         \r
         /** Array of signing contexts, keyed off of the associated Signature */\r
-        std::vector< std::pair<Signature*,const SigningContext*> > m_signingContexts;\r
+        std::vector< std::pair<xmlsignature::Signature*,const xmlsignature::SigningContext*> > m_signingContexts;\r
 #endif\r
     };\r
 \r
index 5eb291b..6cd8826 100644 (file)
@@ -46,8 +46,9 @@
 
 #include <stdexcept>
 
-using namespace log4cpp;
+using namespace xmlsignature;
 using namespace xmltooling;
+using namespace log4cpp;
 using namespace std;
 
 #define REGISTER_ELEMENT(namespaceURI,cname) \
@@ -183,10 +184,15 @@ bool XMLToolingInternalConfig::init()
         REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,J);
         REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,Seed);
         REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,PgenCounter);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,XPath);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,Transform);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,Transforms);
         REGISTER_TYPE(XMLConstants::XMLSIG_NS,KeyInfo);
         REGISTER_TYPE(XMLConstants::XMLSIG_NS,KeyValue);
         REGISTER_TYPE(XMLConstants::XMLSIG_NS,DSAKeyValue);
         REGISTER_TYPE(XMLConstants::XMLSIG_NS,RSAKeyValue);
+        REGISTER_TYPE(XMLConstants::XMLSIG_NS,Transform);
+        REGISTER_TYPE(XMLConstants::XMLSIG_NS,Transforms);
 
 #ifndef XMLTOOLING_NO_XMLSEC
         XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new SignatureBuilder());
index 9809d52..43903d8 100644 (file)
   #include <xmltooling/config_pub.h>
 #endif
 
-/**
- * @namespace xmltooling
- * Public namespace of XML Tooling library
- */
-
 // Windows and GCC4 Symbol Visibility Macros
 #ifdef WIN32
   #define XMLTOOL_IMPORT __declspec(dllimport)
  * @param linkage   linkage specifier for the class
  * @param cname     the name of the class to declare
  * @param base      the base class to derive from using public virtual inheritance
+ * @param desc      documentation comment for class
  */
-#define BEGIN_XMLOBJECT(linkage,cname,base) \
-    class linkage cname : public virtual base, public virtual ValidatingXMLObject { \
+#define BEGIN_XMLOBJECT(linkage,cname,base,desc) \
+    XMLTOOLING_DOXYGEN(desc) \
+    class linkage cname : public virtual base, public virtual xmltooling::ValidatingXMLObject { \
     protected: \
         cname() {} \
     public: \
         } 
 
 /**
+ * Implements marshalling for an attribute
+ * 
+ * @param proper        the proper name of the attribute
+ * @param ucase         the upcased name of the attribute
+ * @param namespaceURI  the XML namespace of the attribute
+ */
+#define MARSHALL_XMLOBJECT_ATTRIB(proper,ucase,namespaceURI) \
+    if(get##proper()) { \
+        domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, get##proper()); \
+    }
+
+/**
+ * Implements marshalling for an ID attribute
+ * 
+ * @param proper        the proper name of the attribute
+ * @param ucase         the upcased name of the attribute
+ * @param namespaceURI  the XML namespace of the attribute
+ */
+#define MARSHALL_XMLOBJECT_ID_ATTRIB(proper,ucase,namespaceURI) \
+    if(get##proper()) { \
+        domElement->setAttributeNS(namespaceURI, ucase##_ATTRIB_NAME, get##proper()); \
+        domElement->setIdAttributeNS(namespaceURI, ucase##_ATTRIB_NAME); \
+    }
+
+/**
+ * Implements unmarshalling process branch for an attribute
+ * 
+ * @param proper        the proper name of the attribute
+ * @param ucase         the upcased name of the attribute
+ * @param namespaceURI  the XML namespace of the attribute
+ */
+#define PROC_XMLOBJECT_ATTRIB(proper,ucase,namespaceURI) \
+    if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
+        set##proper(attribute->getValue()); \
+        return; \
+    }
+
+/**
+ * Implements unmarshalling process branch for an ID attribute
+ * 
+ * @param proper        the proper name of the attribute
+ * @param ucase         the upcased name of the attribute
+ * @param namespaceURI  the XML namespace of the attribute
+ */
+#define PROC_XMLOBJECT_ID_ATTRIB(proper,ucase,namespaceURI) \
+    if (xmltooling::XMLHelper::isNodeNamed(attribute, namespaceURI, ucase##_ATTRIB_NAME)) { \
+        set##proper(attribute->getValue()); \
+        static_cast<DOMElement*>(attribute->getParentNode())->setIdAttributeNode(attribute); \
+        return; \
+    }
+
+/**
  * Implements unmarshalling process branch for typed child collection element
  * 
  * @param proper        the proper name of the child type
  * @param namespaceURI  the XML namespace of the child element
  */
 #define PROC_XMLOBJECT_CHILDREN(proper,namespaceURI) \
-    if (XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
+    if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
         if (typesafe) { \
             get##proper##s().push_back(typesafe); \
  * @param namespaceURI  the XML namespace of the child element
  */
 #define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
-    if (XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
+    if (xmltooling::XMLHelper::isNodeNamed(root,namespaceURI,proper::LOCAL_NAME)) { \
         proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
         if (typesafe) { \
             set##proper(typesafe); \
         return clone(); \
     } \
     cname* clone() const { \
-        auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone()); \
+        std::auto_ptr<xmltooling::XMLObject> domClone(xmltooling::AbstractDOMCachingXMLObject::clone()); \
         cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
         if (ret) { \
             domClone.release(); \
  * @param linkage   linkage specifier for the class
  * @param cname     the name of the XMLObject specialization
  * @param proper    the proper name to label the element's content
+ * @param desc      documentation for class
  */
 #define DECL_XMLOBJECT_SIMPLE(linkage,cname,proper,desc) \
-    XMLTOOLING_DOXYGEN(desc) \
-    BEGIN_XMLOBJECT(linkage,cname,XMLObject); \
+    BEGIN_XMLOBJECT(linkage,cname,xmltooling::XMLObject,desc); \
         DECL_XMLOBJECT_CONTENT(proper); \
     END_XMLOBJECT
 
 #define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname,proper) \
     class linkage cname##Impl \
         : public cname, \
-            public AbstractDOMCachingXMLObject, \
-            public AbstractValidatingXMLObject, \
-            public AbstractXMLObjectMarshaller, \
-            public AbstractXMLObjectUnmarshaller \
+            public xmltooling::AbstractDOMCachingXMLObject, \
+            public xmltooling::AbstractValidatingXMLObject, \
+            public xmltooling::AbstractXMLObjectMarshaller, \
+            public xmltooling::AbstractXMLObjectUnmarshaller \
     { \
     public: \
         virtual ~cname##Impl() {} \
         cname##Impl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) \
-            : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_##proper(NULL) { \
+            : xmltooling::AbstractXMLObject(nsURI, localName, prefix, schemaType), m_##proper(NULL) { \
         } \
         cname##Impl(const cname##Impl& src) \
-            : AbstractXMLObject(src), \
-                AbstractDOMCachingXMLObject(src), \
-                AbstractValidatingXMLObject(src), \
+            : xmltooling::AbstractXMLObject(src), \
+                xmltooling::AbstractDOMCachingXMLObject(src), \
+                xmltooling::AbstractValidatingXMLObject(src), \
                 m_##proper(XMLString::replicate(src.m_##proper)) { \
         } \
         IMPL_XMLOBJECT_CLONE(cname) \
             return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
         } \
         virtual cname* buildObject( \
-            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL \
+            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL \
             ) const
 
 /**
  * @param cname the base name of the Validator specialization
  */
  #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
-    class linkage cname##SchemaValidator : public Validator \
+    class linkage cname##SchemaValidator : public xmltooling::Validator \
     { \
     public: \
         virtual ~cname##SchemaValidator() {} \
         virtual cname##SchemaValidator* clone() const { \
             return new cname##SchemaValidator(); \
         } \
-        virtual void validate(const XMLObject* xmlObject) const { \
+        virtual void validate(const xmltooling::XMLObject* xmlObject) const { \
             const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
             if (!ptr) \
-                throw ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
+                throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
 
 /**
  * Ends the declaration of a Validator specialization.
 #define XMLOBJECTVALIDATOR_CHECKTYPE(cname) \
     const cname* ptr=dynamic_cast<const cname*>(xmlObject); \
     if (!ptr) \
-        throw ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
+        throw xmltooling::ValidationException(#cname"SchemaValidator: unsupported object type ($1).",xmltooling::params(1,typeid(xmlObject).name()))
 
 /**
  * Validator code that checks for a required attribute, content, or singleton.
  */
 #define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
     if (!ptr->get##proper()) \
-        throw ValidationException(#cname" must have "#proper".")
+        throw xmltooling::ValidationException(#cname" must have "#proper".")
 
 /**
  * Validator code that checks for one of a pair of
  */
 #define XMLOBJECTVALIDATOR_ONEOF(cname,proper1,proper2) \
     if (!ptr->get##proper1() && !ptr->get##proper2()) \
-        throw ValidationException(#cname" must have "#proper1" or "#proper2".")
+        throw xmltooling::ValidationException(#cname" must have "#proper1" or "#proper2".")
 
 /**
  * Validator code that checks for one of a set of three
  */
 #define XMLOBJECTVALIDATOR_ONEOF3(cname,proper1,proper2,proper3) \
     if (!ptr->get##proper1() && !ptr->get##proper2() && !ptr->get##proper3()) \
-        throw ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
+        throw xmltooling::ValidationException(#cname" must have "#proper1", "#proper2", or "#proper3".")
 
 /**
  * Validator code that checks a co-constraint (if one present, the other must be)
  */
 #define XMLOBJECTVALIDATOR_NONEORBOTH(cname,proper1,proper2) \
     if ((ptr->get##proper1() && !ptr->get##proper2()) || (!ptr->get##proper1() && ptr->get##proper2())) \
-        throw ValidationException(#cname" cannot have "#proper1" without "#proper2".")
+        throw xmltooling::ValidationException(#cname" cannot have "#proper1" without "#proper2".")
 
 /**
  * Validator code that checks for a non-empty collection.
  */
 #define XMLOBJECTVALIDATOR_NONEMPTY(cname,proper) \
     if (ptr->get##proper##s().empty()) \
-        throw ValidationException(#cname" must have at least one "#proper".")
+        throw xmltooling::ValidationException(#cname" must have at least one "#proper".")
 
 /**
  * Declares/defines a Validator specialization that checks object type and
 
 #include <utility>
 
+/**
+ * @namespace xmltooling
+ * Public namespace of XML Tooling library
+ */
 namespace xmltooling {
 
     /**
index e0f7856..a17476e 100644 (file)
@@ -35,6 +35,7 @@
 #include <xercesc/util/XMLUniDefs.hpp>\r
 #include <log4cpp/Category.hh>\r
 \r
+using namespace xmlsignature;\r
 using namespace xmltooling;\r
 using namespace log4cpp;\r
 using namespace std;\r
index 786c792..a3b21f0 100644 (file)
@@ -33,9 +33,9 @@
 #include <typeinfo>
 
 #define DECL_XMLSIGOBJECTBUILDER(cname) \
-    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,XMLConstants::XMLSIG_NS,XMLConstants::XMLSIG_PREFIX)
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmltooling::XMLConstants::XMLSIG_NS,xmltooling::XMLConstants::XMLSIG_PREFIX)
 
-namespace xmltooling {
+namespace xmlsignature {
 
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,KeyName,Name,XML Digital Signature version 20020212 KeyName element);
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,MgmtData,Data,XML Digital Signature version 20020212 MgmtData element);
@@ -48,11 +48,9 @@ namespace xmltooling {
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,G,Value,XML Digital Signature version 20020212 G element);
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Y,Value,XML Digital Signature version 20020212 Y element);
     DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,J,Value,XML Digital Signature version 20020212 J element);
+    DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,XPath,Expression,XML Digital Signature version 20020212 XPath element);
 
-    /**
-     * XML Digital Signature version 20020212 DSAKeyValue element.
-     */
-    BEGIN_XMLOBJECT(XMLTOOL_API,DSAKeyValue,XMLObject);
+    BEGIN_XMLOBJECT(XMLTOOL_API,DSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 DSAKeyValue element);
         DECL_XMLOBJECT_CHILD(P);
         DECL_XMLOBJECT_CHILD(Q);
         DECL_XMLOBJECT_CHILD(G);
@@ -64,20 +62,14 @@ namespace xmltooling {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
-    /**
-     * XML Digital Signature version 20020212 RSAKeyValue element.
-     */
-    BEGIN_XMLOBJECT(XMLTOOL_API,RSAKeyValue,XMLObject);
+    BEGIN_XMLOBJECT(XMLTOOL_API,RSAKeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 RSAKeyValue element);
         DECL_XMLOBJECT_CHILD(Modulus);
         DECL_XMLOBJECT_CHILD(Exponent);
         /** RSAKeyValueType local name */
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
-    /**
-     * XML Digital Signature version 20020212 KeyValue element.
-     */
-    BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,XMLObject);
+    BEGIN_XMLOBJECT(XMLTOOL_API,KeyValue,xmltooling::XMLObject,XML Digital Signature version 20020212 KeyValue element);
         DECL_XMLOBJECT_CHILD(DSAKeyValue);
         DECL_XMLOBJECT_CHILD(RSAKeyValue);
         DECL_XMLOBJECT_CHILD(XMLObject);
@@ -86,10 +78,20 @@ namespace xmltooling {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
-    /**
-     * XML Digital Signature version 20020212 KeyInfo element.
-     */
-    BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,ElementProxy);
+    BEGIN_XMLOBJECT(XMLTOOL_API,Transform,xmltooling::ElementProxy,XML Digital Signature version 20020212 Transform element);
+        DECL_XMLOBJECT_ATTRIB(Algorithm,ALGORITHM);
+        DECL_XMLOBJECT_CHILDREN(XPath);
+        /** TransformType local name */
+        static const XMLCh TYPE_NAME[];
+    END_XMLOBJECT;
+
+    BEGIN_XMLOBJECT(XMLTOOL_API,Transforms,xmltooling::XMLObject,XML Digital Signature version 20020212 Transforms element);
+        DECL_XMLOBJECT_CHILDREN(Transform);
+        /** TransformsType local name */
+        static const XMLCh TYPE_NAME[];
+    END_XMLOBJECT;
+
+    BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,xmltooling::ElementProxy,XML Digital Signature version 20020212 KeyInfo element);
         DECL_XMLOBJECT_ATTRIB(Id,ID);
         DECL_XMLOBJECT_CHILDREN(KeyName);
         DECL_XMLOBJECT_CHILDREN(MgmtData);
@@ -97,6 +99,9 @@ namespace xmltooling {
         static const XMLCh TYPE_NAME[];
     END_XMLOBJECT;
 
+    DECL_XMLSIGOBJECTBUILDER(XPath);
+    DECL_XMLSIGOBJECTBUILDER(Transform);
+    DECL_XMLSIGOBJECTBUILDER(Transforms);
     DECL_XMLSIGOBJECTBUILDER(KeyName);
     DECL_XMLSIGOBJECTBUILDER(MgmtData);
     DECL_XMLSIGOBJECTBUILDER(Modulus);
@@ -125,6 +130,7 @@ namespace xmltooling {
     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,G,Value);
     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,Y,Value);
     XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,J,Value);
+    XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,XPath,Expression);
 
     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,RSAKeyValue);
         XMLOBJECTVALIDATOR_REQUIRE(RSAKeyValue,Modulus);
@@ -141,6 +147,14 @@ namespace xmltooling {
         XMLOBJECTVALIDATOR_ONEOF3(KeyValue,DSAKeyValue,RSAKeyValue,XMLObject);
     END_XMLOBJECTVALIDATOR;
 
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Transform);
+        XMLOBJECTVALIDATOR_REQUIRE(Transform,Algorithm);
+    END_XMLOBJECTVALIDATOR;
+
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Transforms);
+        XMLOBJECTVALIDATOR_NONEMPTY(Transforms,Transform);
+    END_XMLOBJECTVALIDATOR;
+
     BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,KeyInfo);
         XMLOBJECTVALIDATOR_NONEMPTY(KeyInfo,XMLObject);
     END_XMLOBJECTVALIDATOR;
index 707ad2c..717fa74 100644 (file)
 #include <xmltooling/signature/SigningContext.h>\r
 #include <xmltooling/signature/VerifyingContext.h>\r
 \r
-namespace xmltooling {\r
+/**\r
+ * @namespace xmlsignature\r
+ * Public namespace of XML Signature classes\r
+ */\r
+namespace xmlsignature {\r
 \r
     /**\r
      * XMLObject representing XML Digital Signature, version 20020212, Signature element.\r
      * The default signature settings include Exclusive c14n w/o comments, SHA-1 digests,\r
      * and RSA-SHA1 signing. \r
      */\r
-    class XMLTOOL_API Signature : public virtual XMLObject\r
+    class XMLTOOL_API Signature : public virtual xmltooling::XMLObject\r
     {\r
     public:\r
         virtual ~Signature() {}\r
@@ -79,11 +83,11 @@ namespace xmltooling {
     /**\r
      * Builder for Signature objects.\r
      */\r
-    class XMLTOOL_API SignatureBuilder : public XMLObjectBuilder\r
+    class XMLTOOL_API SignatureBuilder : public xmltooling::XMLObjectBuilder\r
     {\r
     public:\r
         virtual Signature* buildObject(\r
-            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
+            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const xmltooling::QName* schemaType=NULL\r
             ) const;\r
             \r
         /**\r
index 2e6d249..af2e7f4 100644 (file)
@@ -31,7 +31,7 @@
     #pragma warning( disable : 4250 4251 )\r
 #endif\r
 \r
-namespace xmltooling {\r
+namespace xmlsignature {\r
 \r
     /**\r
      * Interface to signing process supplied by a signing application\r
index 9dfe2cb..7e0e436 100644 (file)
@@ -25,7 +25,7 @@
 \r
 #include <xsec/dsig/DSIGSignature.hpp>\r
 \r
-namespace xmltooling {\r
+namespace xmlsignature {\r
 \r
     /**\r
      * Interface to signature verification process supplied by a relying party\r
index ee095f6..746cd0a 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace xmlsignature;
 using namespace xmltooling;
 using namespace std;
 
@@ -39,7 +40,7 @@ using namespace std;
     #pragma warning( disable : 4250 4251 )
 #endif
 
-namespace xmltooling {
+namespace xmlsignature {
     
     class XMLTOOL_DLLLOCAL DSAKeyValueImpl : public DSAKeyValue,
         public AbstractDOMCachingXMLObject,
@@ -219,7 +220,104 @@ namespace xmltooling {
             throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString().c_str()));
         }
     };
-    
+
+    class XMLTOOL_DLLLOCAL TransformImpl : public Transform,
+        public AbstractDOMCachingXMLObject,
+        public AbstractElementProxy,
+        public AbstractValidatingXMLObject,
+        public AbstractXMLObjectMarshaller,
+        public AbstractXMLObjectUnmarshaller
+    {
+    public:
+        virtual ~TransformImpl() {}
+
+        TransformImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+            : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Algorithm(NULL) {
+        }
+            
+        TransformImpl(const TransformImpl& src)
+                : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractElementProxy(src),
+                    AbstractValidatingXMLObject(src), m_Algorithm(XMLString::replicate(src.m_Algorithm)) {
+            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
+                if (*i) {
+                    XPath* x=dynamic_cast<XPath*>(*i);
+                    if (x) {
+                        getXPaths().push_back(x->cloneXPath());
+                        continue;
+                    }
+                    getXMLObjects().push_back((*i)->clone());
+                }
+            }
+        }
+        
+        IMPL_XMLOBJECT_CLONE(Transform);
+        IMPL_XMLOBJECT_ATTRIB(Algorithm);
+        IMPL_XMLOBJECT_CHILDREN(XPath,m_children.end());
+
+    protected:
+        void marshallAttributes(DOMElement* domElement) const {
+            MARSHALL_XMLOBJECT_ATTRIB(Algorithm,ALGORITHM,NULL);
+        }
+
+        void marshallElementContent(DOMElement* domElement) const {
+            if(getTextContent()) {
+                domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent()));
+            }
+        }
+
+        void processElementContent(const XMLCh* elementContent) {
+            setTextContent(elementContent);
+        }
+
+        void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+            PROC_XMLOBJECT_CHILDREN(XPath,XMLConstants::XMLSIG_NS);
+            
+            // Unknown child.
+            const XMLCh* nsURI=root->getNamespaceURI();
+            if (!XMLString::equals(nsURI,XMLConstants::XMLSIG_NS) && nsURI && *nsURI)
+                getXMLObjects().push_back(childXMLObject);
+            
+            throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString().c_str()));
+        }
+
+        void processAttribute(const DOMAttr* attribute) {
+            PROC_XMLOBJECT_ATTRIB(Algorithm,ALGORITHM,NULL);
+        }
+    };
+
+    class XMLTOOL_DLLLOCAL TransformsImpl : public Transforms,
+        public AbstractDOMCachingXMLObject,
+        public AbstractValidatingXMLObject,
+        public AbstractXMLObjectMarshaller,
+        public AbstractXMLObjectUnmarshaller
+    {
+    public:
+        virtual ~TransformsImpl() {}
+
+        TransformsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+            : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
+        }
+            
+        TransformsImpl(const TransformsImpl& src)
+                : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+            VectorOf(Transform) v=getTransforms();
+            for (vector<Transform*>::const_iterator i=src.m_Transforms.begin(); i!=src.m_Transforms.end(); i++) {
+                if (*i) {
+                    v.push_back((*i)->cloneTransform());
+                }
+            }
+        }
+        
+        IMPL_XMLOBJECT_CLONE(Transforms);
+        IMPL_XMLOBJECT_CHILDREN(Transform,m_children.end());
+
+    protected:
+        void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+            PROC_XMLOBJECT_CHILDREN(Transform,XMLConstants::XMLSIG_NS);
+            throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString().c_str()));
+        }
+    };
+
     class XMLTOOL_DLLLOCAL KeyInfoImpl : public KeyInfo,
         public AbstractDOMCachingXMLObject,
         public AbstractElementProxy,
@@ -267,10 +365,7 @@ namespace xmltooling {
 
     protected:
         void marshallAttributes(DOMElement* domElement) const {
-            if(getId()) {
-                domElement->setAttributeNS(NULL, ID_ATTRIB_NAME, getId());
-                domElement->setIdAttributeNS(NULL, ID_ATTRIB_NAME);
-            }
+            MARSHALL_XMLOBJECT_ID_ATTRIB(Id,ID,NULL);
         }
 
         void marshallElementContent(DOMElement* domElement) const {
@@ -297,10 +392,7 @@ namespace xmltooling {
         }
 
         void processAttribute(const DOMAttr* attribute) {
-            if (XMLHelper::isNodeNamed(attribute, NULL, ID_ATTRIB_NAME)) {
-                setId(attribute->getValue());
-                static_cast<DOMElement*>(attribute->getParentNode())->setIdAttributeNode(attribute);
-            }
+            PROC_XMLOBJECT_ID_ATTRIB(Id,ID,NULL);
         }
     };
     
@@ -315,6 +407,7 @@ namespace xmltooling {
     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,G,Value);
     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Y,Value);
     DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,J,Value);
+    DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,XPath,Expression);
 };
 
 #if defined (_MSC_VER)
@@ -323,6 +416,9 @@ namespace xmltooling {
 
 // Builder Implementations
 
+IMPL_XMLOBJECTBUILDER(XPath);
+IMPL_XMLOBJECTBUILDER(Transform);
+IMPL_XMLOBJECTBUILDER(Transforms);
 IMPL_XMLOBJECTBUILDER(KeyName);
 IMPL_XMLOBJECTBUILDER(MgmtData);
 IMPL_XMLOBJECTBUILDER(Modulus);
@@ -359,3 +455,9 @@ const XMLCh Q::LOCAL_NAME[] =               UNICODE_LITERAL_1(Q);
 const XMLCh G::LOCAL_NAME[] =               UNICODE_LITERAL_1(G);
 const XMLCh Y::LOCAL_NAME[] =               UNICODE_LITERAL_1(Y);
 const XMLCh J::LOCAL_NAME[] =               UNICODE_LITERAL_1(J);
+const XMLCh XPath::LOCAL_NAME[] =           UNICODE_LITERAL_5(X,P,a,t,h);
+const XMLCh Transform::LOCAL_NAME[] =       UNICODE_LITERAL_9(T,r,a,n,s,f,o,r,m);
+const XMLCh Transform::TYPE_NAME[] =        UNICODE_LITERAL_13(T,r,a,n,s,f,o,r,m,T,y,p,e);
+const XMLCh Transform::ALGORITHM_ATTRIB_NAME[] = UNICODE_LITERAL_9(A,l,g,o,r,i,t,h,m);
+const XMLCh Transforms::LOCAL_NAME[] =      UNICODE_LITERAL_10(T,r,a,n,s,f,o,r,m,s);
+const XMLCh Transforms::TYPE_NAME[] =       UNICODE_LITERAL_14(T,r,a,n,s,f,o,r,m,s,T,y,p,e);
index b561814..adc8df5 100644 (file)
@@ -36,6 +36,7 @@
 #include <xsec/enc/XSECCryptoException.hpp>\r
 #include <xsec/framework/XSECException.hpp>\r
 \r
+using namespace xmlsignature;\r
 using namespace xmltooling;\r
 using namespace log4cpp;\r
 using namespace std;\r
@@ -45,7 +46,7 @@ using namespace std;
     #pragma warning( disable : 4250 4251 )\r
 #endif\r
 \r
-namespace xmltooling {\r
+namespace xmlsignature {\r
     \r
     class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
     {\r
index ee5fa88..6371026 100644 (file)
@@ -31,6 +31,7 @@
 #include <xmltooling/util/XMLHelper.h>
 #include <xmltooling/util/XMLObjectChildrenList.h>
 
+using namespace xmlsignature;
 using namespace xmltooling;
 using namespace std;