Evolving macros, reduce casting in accessors, add const collection access.
authorScott Cantor <cantor.2@osu.edu>
Sat, 1 Apr 2006 21:55:46 +0000 (21:55 +0000)
committerScott Cantor <cantor.2@osu.edu>
Sat, 1 Apr 2006 21:55:46 +0000 (21:55 +0000)
16 files changed:
xmltooling/AbstractElementProxy.h
xmltooling/AbstractXMLObject.cpp
xmltooling/AbstractXMLObject.h
xmltooling/ElementProxy.h
xmltooling/Makefile.am
xmltooling/XMLToolingConfig.cpp
xmltooling/base.h
xmltooling/signature/KeyInfo.h
xmltooling/signature/Signature.h
xmltooling/signature/impl/KeyInfoImpl.cpp
xmltooling/signature/impl/KeyInfoImpl.h [deleted file]
xmltooling/signature/impl/XMLSecSignatureImpl.cpp
xmltooling/signature/impl/XMLSecSignatureImpl.h [deleted file]
xmltooling/xmltooling.vcproj
xmltoolingtest/ComplexXMLObjectTest.h
xmltoolingtest/XMLObjectBaseTestCase.h

index 1bbd34e..19bad7b 100644 (file)
@@ -49,7 +49,11 @@ namespace xmltooling {
         \r
         virtual ListOf(XMLObject) getXMLObjects();\r
     \r
-     protected:\r
+        virtual const std::list<XMLObject*>& getXMLObjects() const {\r
+            return m_children;\r
+        }\r
+\r
+    protected:\r
         AbstractElementProxy() : m_value(NULL) {}\r
         \r
         /** Copy constructor. */\r
index bb40e91..780304a 100644 (file)
@@ -61,17 +61,15 @@ XMLObject* AbstractXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObjec
         if (newValue) {
             releaseThisandParentDOM();
             newValue->setParent(this);
-            return newValue;
-        }
-        else {
-            return NULL;
         }
+        return newValue;
     }
 
     if (oldValue != newValue) {
         delete oldValue;
         releaseThisandParentDOM();
-        newValue->setParent(this);
+        if (newValue)
+            newValue->setParent(this);
     }
 
     return newValue;
index 7a4ff1f..251a60f 100644 (file)
@@ -125,11 +125,13 @@ namespace xmltooling {
          * A helper function for derived classes, for assignment of (singleton) XML objects.\r
          * \r
          * It is indifferent to whether either the old or the new version of the value is null. \r
-         * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
+         * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate.\r
+         * Note that since the new value (even if NULL) is always returned, it may be more efficient\r
+         * to discard the return value and just assign independently if a dynamic cast would be involved.\r
          * \r
          * @param oldValue - current value\r
          * @param newValue - proposed new value\r
-         * @return the value to assign \r
+         * @return the new value \r
          * \r
          * @throws XMLObjectException if the new child already has a parent.\r
          */\r
index 874139b..53b3d48 100644 (file)
@@ -52,7 +52,6 @@ namespace xmltooling {
          * @param value         value to set, or NULL to clear\r
          */\r
         virtual void setTextContent(const XMLCh* value)=0;\r
-        \r
 \r
         /**\r
          * Gets a mutable list of child objects\r
@@ -60,6 +59,13 @@ namespace xmltooling {
          * @return  mutable list of child objects\r
          */\r
         virtual ListOf(XMLObject) getXMLObjects()=0;\r
+\r
+        /**\r
+         * Gets an immutable list of child objects\r
+         * \r
+         * @return  immutable list of child objects\r
+         */\r
+        virtual const std::list<XMLObject*>& getXMLObjects() const=0;\r
     };\r
     \r
 };\r
index 5b4e2bc..fa5ee26 100644 (file)
@@ -60,9 +60,7 @@ valinclude_HEADERS = \
     validation/Validator.h
 
 noinst_HEADERS = \
-    internal.h \
-    signature/impl/KeyInfoImpl.h \
-    signature/impl/XMLSecSignatureImpl.h
+    internal.h
 
 if BUILD_XMLSEC
 xmlsec_sources = \
index 3cfbe79..2c8d410 100644 (file)
  */
 
 #include "internal.h"
-
-#define XMLTOOLING_DEFINE_CONSTANTS
-#include <xercesc/util/XMLUniDefs.hpp>
-
 #include "exceptions.h"
 #include "XMLToolingConfig.h"
 #include "impl/UnknownElement.h"
-#include "signature/impl/KeyInfoImpl.h"
-#include "signature/impl/XMLSecSignatureImpl.h"
+#include "signature/KeyInfo.h"
+#include "signature/Signature.h"
 #include "util/NDC.h"
 #include "util/XMLConstants.h"
 #include "validation/Validator.h"
@@ -52,6 +48,17 @@ using namespace log4cpp;
 using namespace xmltooling;
 using namespace std;
 
+#define REGISTER_ELEMENT(namespaceURI,cname) \
+    q=QName(namespaceURI,cname##::LOCAL_NAME); \
+    XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
+    Validator::registerValidator(q,new cname##SchemaValidator())
+    
+#define REGISTER_TYPE(namespaceURI,cname) \
+    q=QName(namespaceURI,cname##::TYPE_NAME); \
+    XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \
+    Validator::registerValidator(q,new cname##SchemaValidator())
+
+
 DECL_EXCEPTION_FACTORY(XMLParserException);
 DECL_EXCEPTION_FACTORY(XMLObjectException);
 DECL_EXCEPTION_FACTORY(MarshallingException);
@@ -158,23 +165,18 @@ bool XMLToolingInternalConfig::init()
         // default registrations
         XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
         
-        QName q(XMLConstants::XMLSIG_NS,KeyInfo::LOCAL_NAME);
-        XMLObjectBuilder::registerBuilder(q,new KeyInfoBuilderImpl());
-        Validator::registerValidator(q,new KeyInfoSchemaValidator());
-        q=QName(XMLConstants::XMLSIG_NS,KeyInfo::TYPE_NAME);
-        XMLObjectBuilder::registerBuilder(q,new KeyInfoBuilderImpl());
-        Validator::registerValidator(q,new KeyInfoSchemaValidator());
-
-        q=QName(XMLConstants::XMLSIG_NS,KeyName::LOCAL_NAME);
-        XMLObjectBuilder::registerBuilder(q,new KeyNameBuilderImpl());
-        Validator::registerValidator(q,new KeyNameSchemaValidator());
-
-        q=QName(XMLConstants::XMLSIG_NS,MgmtData::LOCAL_NAME);
-        XMLObjectBuilder::registerBuilder(q,new MgmtDataBuilderImpl());
-        Validator::registerValidator(q,new MgmtDataSchemaValidator());
+        QName q;
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,KeyInfo);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,KeyName);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,MgmtData);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,RSAKeyValue);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,Exponent);
+        REGISTER_ELEMENT(XMLConstants::XMLSIG_NS,Modulus);
+        REGISTER_TYPE(XMLConstants::XMLSIG_NS,KeyInfo);
+        REGISTER_TYPE(XMLConstants::XMLSIG_NS,RSAKeyValue);
 
 #ifndef XMLTOOLING_NO_XMLSEC
-        XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new XMLSecSignatureBuilder());
+        XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new SignatureBuilder());
 #endif
 
         REGISTER_EXCEPTION_FACTORY(XMLParserException);
index de15fe1..7de34c5 100644 (file)
         type(const type&); \
         type& operator=(const type&);
 
+#define UNICODE_LITERAL_1(a) {chLatin_##a, chNull}
+#define UNICODE_LITERAL_2(a,b) {chLatin_##a, chLatin_##b, chNull}
+#define UNICODE_LITERAL_3(a,b,c) {chLatin_##a, chLatin_##b, chLatin_##c, chNull}
+#define UNICODE_LITERAL_4(a,b,c,d) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chNull}
+#define UNICODE_LITERAL_5(a,b,c,d,e) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chNull}
+#define UNICODE_LITERAL_6(a,b,c,d,e,f) {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chNull}
+#define UNICODE_LITERAL_7(a,b,c,d,e,f,g) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chNull}
+#define UNICODE_LITERAL_8(a,b,c,d,e,f,g,h) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chNull}
+#define UNICODE_LITERAL_9(a,b,c,d,e,f,g,h,i) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, chNull}
+#define UNICODE_LITERAL_10(a,b,c,d,e,f,g,h,i,j) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chNull}
+#define UNICODE_LITERAL_11(a,b,c,d,e,f,g,h,i,j,k) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chNull}
+#define UNICODE_LITERAL_12(a,b,c,d,e,f,g,h,i,j,k,l) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chNull}
+#define UNICODE_LITERAL_13(a,b,c,d,e,f,g,h,i,j,k,l,m) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chNull}
+#define UNICODE_LITERAL_14(a,b,c,d,e,f,g,h,i,j,k,l,m,n) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chNull}
+#define UNICODE_LITERAL_15(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chNull}
+#define UNICODE_LITERAL_16(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chNull}
+#define UNICODE_LITERAL_17(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chNull}
+#define UNICODE_LITERAL_18(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, chNull}
+#define UNICODE_LITERAL_19(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chNull}
+#define UNICODE_LITERAL_20(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chNull}
+#define UNICODE_LITERAL_21(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chNull}
+#define UNICODE_LITERAL_22(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chNull}
+#define UNICODE_LITERAL_23(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chNull}
+#define UNICODE_LITERAL_24(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chNull}
+#define UNICODE_LITERAL_25(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chNull}
+#define UNICODE_LITERAL_26(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) \
+    {chLatin_##a, chLatin_##b, chLatin_##c, chLatin_##d, chLatin_##e, chLatin_##f, chLatin_##g, chLatin_##h, chLatin_##i, \
+        chLatin_##j, chLatin_##k, chLatin_##l, chLatin_##m, chLatin_##n, chLatin_##o, chLatin_##p, chLatin_##q, chLatin_##r, \
+        chLatin_##s, chLatin_##t, chLatin_##u, chLatin_##v, chLatin_##w, chLatin_##x, chLatin_##y, chLatin_##z, chNull}
+
 /**
  * Begins the declaration of an XMLObject specialization.
  * Basic boilerplate includes a protected constructor, empty virtual destructor,
  * and Unicode constants for the default associated element's name and prefix.
  * 
- * @param cname the name of the class to declare
- * @param base  the base class to derive from using public virtual inheritance
+ * @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
  */
-#define BEGIN_XMLOBJECT(cname,base) \
-    class XMLTOOL_API cname : public virtual base, public virtual ValidatingXMLObject { \
+#define BEGIN_XMLOBJECT(linkage,cname,base) \
+    class linkage cname : public virtual base, public virtual ValidatingXMLObject { \
     protected: \
         cname() {} \
     public: \
  * @param upcased   the upcased name of the attribute
  */
 #define DECL_XMLOBJECT_ATTRIB(proper,upcased) \
-    XMLTOOLING_DOXYGEN(proper attribute name) \
-    static const XMLCh upcased##_ATTRIB_NAME[]; \
-    XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
-    virtual const XMLCh* get##proper() const=0; \
-    XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
-    virtual void set##proper(const XMLCh* proper)=0
+    public: \
+        XMLTOOLING_DOXYGEN(proper attribute name) \
+        static const XMLCh upcased##_ATTRIB_NAME[]; \
+        XMLTOOLING_DOXYGEN(Returns the proper attribute.) \
+        virtual const XMLCh* get##proper() const=0; \
+        XMLTOOLING_DOXYGEN(Sets the proper attribute.) \
+        virtual void set##proper(const XMLCh* proper)=0
 
 /**
  * Implements get/set methods and a private member for a named XML attribute.
         }
 
 /**
+ * Declares abstract get/set methods for a typed XML child object.
+ * 
+ * @param proper    the proper name of the child type
+ */
+#define DECL_XMLOBJECT_CHILD(proper) \
+    public: \
+        XMLTOOLING_DOXYGEN(Returns the proper child.) \
+        virtual proper* get##proper() const=0; \
+        XMLTOOLING_DOXYGEN(Sets the proper child.) \
+        virtual void set##proper(proper* child)=0
+
+/**
+ * Implements get/set methods and a private list iterator member for a typed XML child object.
+ * 
+ * @param proper    the proper name of the child type
+ */
+#define IMPL_XMLOBJECT_CHILD(proper) \
+    private: \
+        proper* m_##proper; \
+        std::list<XMLObject*>::iterator m_pos_##proper; \
+    public: \
+        proper* get##proper() const { \
+            return m_##proper; \
+        } \
+        void set##proper(proper* child) { \
+            prepareForAssignment(m_##proper,child); \
+            *m_pos_##proper = m_##proper = child; \
+        }
+
+/**
+ * Declares abstract get/set methods for a typed XML child collection.
+ * 
+ * @param proper    the proper name of the child type
+ */
+#define DECL_XMLOBJECT_CHILDREN(proper) \
+    public: \
+        XMLTOOLING_DOXYGEN(Returns modifiable proper collection.) \
+        virtual VectorOf(proper) get##proper##s()=0; \
+        XMLTOOLING_DOXYGEN(Returns reference to immutable proper collection.) \
+        virtual const std::vector<proper*>& get##proper##s() const=0
+
+/**
+ * Implements get method and a private vector member for a typed XML child collection.
+ * 
+ * @param proper    the proper name of the child type
+ * @param fence     insertion fence for new objects of the child collection in backing list
+ */
+#define IMPL_XMLOBJECT_CHILDREN(proper,fence) \
+    private: \
+        std::vector<proper*> m_##proper##s; \
+    public: \
+        VectorOf(proper) get##proper##s() { \
+            return VectorOf(proper)(this, m_##proper##s, &m_children, fence); \
+        } \
+        const std::vector<proper*>& get##proper##s() const { \
+            return m_##proper##s; \
+        } 
+
+/**
+ * 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)) { \
+        proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
+        if (typesafe) { \
+            get##proper##s().push_back(typesafe); \
+            return; \
+        } \
+    }
+
+/**
+ * Implements unmarshalling process branch for typed child singleton element
+ * 
+ * @param proper        the proper name of the child type
+ * @param namespaceURI  the XML namespace of the child element
+ */
+#define PROC_XMLOBJECT_CHILD(proper,namespaceURI) \
+    if (XMLHelper::isNodeNamed(root,namespaceURI,proper##::LOCAL_NAME)) { \
+        proper* typesafe=dynamic_cast<proper*>(childXMLObject); \
+        if (typesafe) { \
+            set##proper(typesafe); \
+            return; \
+        } \
+    }
+
+/**
  * Declares abstract get/set methods for named XML element content.
  * 
  * @param proper    the proper name to label the element's content
     }
 
 /**
+ * Declares and defines an implementation class for an XMLObject with
+ * a simple content model and type, handling it as string data.
+ * 
+ * @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
+ */
+#define DECL_XMLOBJECTIMPL_SIMPLE(linkage,cname,proper) \
+    class linkage cname##Impl \
+        : public cname, \
+            public AbstractDOMCachingXMLObject, \
+            public AbstractValidatingXMLObject, \
+            public AbstractXMLObjectMarshaller, \
+            public 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) { \
+        } \
+        cname##Impl(const cname##Impl& src) \
+            : AbstractXMLObject(src), \
+                AbstractDOMCachingXMLObject(src), \
+                AbstractValidatingXMLObject(src), \
+                m_##proper(XMLString::replicate(src.m_##proper)) { \
+        } \
+        IMPL_XMLOBJECT_CLONE(cname) \
+        IMPL_XMLOBJECT_CONTENT(proper) \
+    }
+    
+/**
  * Begins the declaration of an XMLObjectBuilder specialization.
  * Basic boilerplate includes an empty virtual destructor, and
- * a default builder.
+ * a default builder that defaults the element name.
  * 
- * @param cname the name of the XMLObject specialization
+ * @param linkage           linkage specifier for the class
+ * @param cname             the name of the XMLObject specialization
+ * @param namespaceURI      the XML namespace of the default associated element
+ * @param namespacePrefix   the XML namespace prefix of the default associated element
  */
-#define BEGIN_XMLOBJECTBUILDER(cname) \
+#define BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
     XMLTOOLING_DOXYGEN(Builder for cname objects.) \
-    class XMLTOOL_API cname##Builder : public xmltooling::XMLObjectBuilder { \
+    class linkage cname##Builder : public xmltooling::XMLObjectBuilder { \
     public: \
         virtual ~cname##Builder() {} \
         XMLTOOLING_DOXYGEN(Default builder.) \
-        virtual cname* buildObject() const=0
+        virtual cname* buildObject() const { \
+            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
 
 /**
  * Ends the declaration of an XMLObjectBuilder specialization.
 #define END_XMLOBJECTBUILDER }
 
 /**
- * Begins the declaration of an XMLObjectBuilder specialization implementation class.
+ * Declares a generic XMLObjectBuilder specialization.
  * 
+ * @param linkage           linkage specifier for the class
  * @param cname             the name of the XMLObject specialization
  * @param namespaceURI      the XML namespace of the default associated element
  * @param namespacePrefix   the XML namespace prefix of the default associated element
  */
-#define BEGIN_XMLOBJECTBUILDERIMPL(cname,namespaceURI,namespacePrefix) \
-    class XMLTOOL_DLLLOCAL cname##BuilderImpl : public cname##Builder { \
-    public: \
-        cname* buildObject( \
-            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL \
-            ) const; \
-        cname* buildObject() const { \
-            return buildObject(namespaceURI,cname::LOCAL_NAME,namespacePrefix); \
-        }
+ #define DECL_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix) \
+    BEGIN_XMLOBJECTBUILDER(linkage,cname,namespaceURI,namespacePrefix); \
+    END_XMLOBJECTBUILDER
 
 /**
- * Begins the declaration of an XMLObjectBuilder specialization implementation class.
+ * Implements the standard XMLObjectBuilder specialization function. 
  * 
  * @param cname the name of the XMLObject specialization
  */
 #define IMPL_XMLOBJECTBUILDER(cname) \
-    cname* cname##BuilderImpl::buildObject( \
+    cname* cname##Builder::buildObject( \
         const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType \
         ) const \
     { \
     }
 
 /**
- * Ends the declaration of an XMLObjectBuilder specialization implementation class.
- */
-#define END_XMLOBJECTBUILDERIMPL }
-
-/**
- * Begins the declaration of a Validator specialization.
+ * Begins the declaration of a Schema Validator specialization.
  * 
+ * @param linkage           linkage specifier for the class
  * @param cname the base name of the Validator specialization
  */
- #define BEGIN_XMLOBJECTVALIDATOR(cname) \
-    class cname##Validator : public Validator \
+ #define BEGIN_XMLOBJECTVALIDATOR(linkage,cname) \
+    class linkage cname##SchemaValidator : public Validator \
     { \
     public: \
-        virtual ~cname##Validator() {} \
-        Validator* clone() const { \
-            return new cname##Validator(); \
+        virtual ~cname##SchemaValidator() {} \
+        virtual cname##SchemaValidator* clone() const { \
+            return new cname##SchemaValidator(); \
         } \
-        void validate(const XMLObject* xmlObject) const
+        virtual void validate(const 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()))
 
 /**
  * Ends the declaration of a Validator specialization.
  */
-#define END_XMLOBJECTVALIDATOR }
+#define END_XMLOBJECTVALIDATOR } }
 
+/**
+ * Validator code that checks the object type.
+ * 
+ * @param cname     the name of the XMLObject 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()))
+
+/**
+ * Validator code that checks for a required attribute, content, or singleton.
+ * 
+ * @param cname     the name of the XMLObject specialization
+ * @param proper    the proper name of the attribute, content, or singleton member 
+ */
+#define XMLOBJECTVALIDATOR_REQUIRE(cname,proper) \
+    if (!ptr->get##proper()) \
+        throw ValidationException(#cname" must have "#proper".")
+
+/**
+ * Validator code that checks for a non-empty collection.
+ * 
+ * @param cname     the name of the XMLObject specialization
+ * @param proper    the proper name of the collection item 
+ */
+#define XMLOBJECTVALIDATOR_CHECKEMPTY(cname,proper) \
+    if (ptr->get##proper##s().empty()) \
+        throw ValidationException(#cname" must have at least one "#proper".")
 
 #include <utility>
 
index 83c9e4c..50c8637 100644 (file)
 #define __xmltooling_keyinfo_h__\r
 \r
 #include <xmltooling/ElementProxy.h>\r
+#include <xmltooling/exceptions.h>\r
 #include <xmltooling/XMLObjectBuilder.h>\r
+#include <xmltooling/util/XMLConstants.h>\r
 #include <xmltooling/validation/ValidatingXMLObject.h>\r
 \r
+#include <typeinfo.h>\r
+\r
+#define DECL_XMLSIGOBJECTBUILDER(cname) \\r
+    DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,XMLConstants::XMLSIG_NS,XMLConstants::XMLSIG_PREFIX)\r
+\r
 namespace xmltooling {\r
 \r
     /**\r
-     * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element.\r
+     * XMLObject representing XML Digital Signature, version 20020212, KeyName element.\r
      */\r
-    BEGIN_XMLOBJECT(KeyInfo,ElementProxy);\r
-        DECL_XMLOBJECT_ATTRIB(Id,ID);\r
-        static const XMLCh TYPE_NAME[];\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,KeyName,XMLObject);\r
+        DECL_XMLOBJECT_CONTENT(Name);\r
     END_XMLOBJECT;\r
 \r
-    BEGIN_XMLOBJECTBUILDER(KeyInfo);\r
-    END_XMLOBJECTBUILDER;\r
-\r
-#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
-    const XMLCh KeyInfo::LOCAL_NAME[] = {\r
-        chLatin_K, chLatin_e, chLatin_y, chLatin_I, chLatin_n, chLatin_f, chLatin_o, chNull\r
-    }; \r
-    const XMLCh KeyInfo::TYPE_NAME[] = {\r
-        chLatin_K, chLatin_e, chLatin_y, chLatin_I, chLatin_n, chLatin_f, chLatin_o,\r
-        chLatin_T, chLatin_y, chLatin_p, chLatin_e, chNull\r
-    }; \r
-    const XMLCh KeyInfo::ID_ATTRIB_NAME[] = {\r
-        chLatin_I, chLatin_d, chNull\r
-    };\r
-#endif\r
+    /**\r
+     * XMLObject representing XML Digital Signature, version 20020212, MgmtData element.\r
+     */\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,MgmtData,XMLObject);\r
+        DECL_XMLOBJECT_CONTENT(Data);\r
+    END_XMLOBJECT;\r
 \r
     /**\r
-     * XMLObject representing XML Digital Signature, version 20020212, KeyName element.\r
+     * XMLObject representing XML Digital Signature, version 20020212, Modulus element.\r
      */\r
-    BEGIN_XMLOBJECT(KeyName,XMLObject);\r
-        DECL_XMLOBJECT_CONTENT(Name);\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,Modulus,XMLObject);\r
+        DECL_XMLOBJECT_CONTENT(Value);\r
     END_XMLOBJECT;\r
 \r
-    BEGIN_XMLOBJECTBUILDER(KeyName);\r
-    END_XMLOBJECTBUILDER;\r
+    /**\r
+     * XMLObject representing XML Digital Signature, version 20020212, Exponent element.\r
+     */\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,Exponent,XMLObject);\r
+        DECL_XMLOBJECT_CONTENT(Value);\r
+    END_XMLOBJECT;\r
 \r
-#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
-    const XMLCh KeyName::LOCAL_NAME[] = {\r
-        chLatin_K, chLatin_e, chLatin_y, chLatin_N, chLatin_a, chLatin_m, chLatin_e, chNull\r
-    }; \r
-#endif\r
+    /**\r
+     * XMLObject representing XML Digital Signature, version 20020212, RSAKeyValue element.\r
+     */\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,RSAKeyValue,XMLObject);\r
+        DECL_XMLOBJECT_CHILD(Modulus);\r
+        DECL_XMLOBJECT_CHILD(Exponent);\r
+        /** RSAKeyValueType local name */\r
+        static const XMLCh TYPE_NAME[];\r
+    END_XMLOBJECT;\r
 \r
     /**\r
-     * XMLObject representing XML Digital Signature, version 20020212, MgmtData element.\r
+     * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element.\r
      */\r
-    BEGIN_XMLOBJECT(MgmtData,XMLObject);\r
-        DECL_XMLOBJECT_CONTENT(Data);\r
+    BEGIN_XMLOBJECT(XMLTOOL_API,KeyInfo,ElementProxy);\r
+        DECL_XMLOBJECT_ATTRIB(Id,ID);\r
+        DECL_XMLOBJECT_CHILDREN(KeyName);\r
+        DECL_XMLOBJECT_CHILDREN(MgmtData);\r
+        /** KeyInfoType local name */\r
+        static const XMLCh TYPE_NAME[];\r
     END_XMLOBJECT;\r
 \r
-    BEGIN_XMLOBJECTBUILDER(MgmtData);\r
-    END_XMLOBJECTBUILDER;\r
+    DECL_XMLSIGOBJECTBUILDER(KeyName);\r
+    DECL_XMLSIGOBJECTBUILDER(MgmtData);\r
+    DECL_XMLSIGOBJECTBUILDER(Modulus);\r
+    DECL_XMLSIGOBJECTBUILDER(Exponent);\r
+    DECL_XMLSIGOBJECTBUILDER(RSAKeyValue);\r
+    DECL_XMLSIGOBJECTBUILDER(KeyInfo);\r
+    \r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,KeyName);\r
+        XMLOBJECTVALIDATOR_REQUIRE(KeyName,Name);\r
+    END_XMLOBJECTVALIDATOR;\r
+    \r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,MgmtData);\r
+        XMLOBJECTVALIDATOR_REQUIRE(MgmtData,Data);\r
+    END_XMLOBJECTVALIDATOR;\r
+\r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Modulus);\r
+        XMLOBJECTVALIDATOR_REQUIRE(Modulus,Value);\r
+    END_XMLOBJECTVALIDATOR;\r
+\r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Exponent);\r
+        XMLOBJECTVALIDATOR_REQUIRE(Exponent,Value);\r
+    END_XMLOBJECTVALIDATOR;\r
+\r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,RSAKeyValue);\r
+        XMLOBJECTVALIDATOR_REQUIRE(RSAKeyValue,Modulus);\r
+        XMLOBJECTVALIDATOR_REQUIRE(RSAKeyValue,Exponent);\r
+    END_XMLOBJECTVALIDATOR;\r
+\r
+    BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,KeyInfo);\r
+        XMLOBJECTVALIDATOR_CHECKEMPTY(KeyInfo,XMLObject);\r
+    END_XMLOBJECTVALIDATOR;\r
 \r
-#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
-    const XMLCh MgmtData::LOCAL_NAME[] = {\r
-        chLatin_M, chLatin_g, chLatin_m, chLatin_t, chLatin_D, chLatin_a, chLatin_t, chLatin_a, chNull\r
-    }; \r
-#endif\r
 };\r
 \r
 #endif /* __xmltooling_keyinfo_h__ */\r
index bf886fc..707ad2c 100644 (file)
@@ -39,9 +39,6 @@ namespace xmltooling {
     public:\r
         virtual ~Signature() {}\r
 \r
-        /** Element prefix */\r
-        static const XMLCh PREFIX[];\r
-\r
         /** Element local name */\r
         static const XMLCh LOCAL_NAME[];\r
 \r
@@ -79,28 +76,24 @@ namespace xmltooling {
         Signature() {}\r
     };\r
 \r
-#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
-    const XMLCh Signature::LOCAL_NAME[] = {\r
-        chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
-    }; \r
-    const XMLCh Signature::PREFIX[] = {\r
-        chLatin_d, chLatin_s, chNull\r
-    };\r
-#endif\r
-\r
     /**\r
      * Builder for Signature objects.\r
      */\r
     class XMLTOOL_API SignatureBuilder : public XMLObjectBuilder\r
     {\r
     public:\r
-        virtual ~SignatureBuilder() {}\r
-\r
+        virtual Signature* buildObject(\r
+            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
+            ) const;\r
+            \r
         /**\r
-         * Default builder.\r
+         * Default builder\r
+         * \r
+         * @return empty Signature object\r
          */\r
-        virtual Signature* buildObject() const=0;\r
+        virtual Signature* buildObject() const;\r
     };\r
+\r
 };\r
 \r
 #endif /* __xmltooling_sig_h__ */\r
index 44dc6ab..b31de4e 100644 (file)
 #include "exceptions.h"\r
 #include "io/AbstractXMLObjectMarshaller.h"\r
 #include "io/AbstractXMLObjectUnmarshaller.h"\r
-#include "signature/impl/KeyInfoImpl.h"\r
+#include "signature/KeyInfo.h"\r
 #include "util/XMLHelper.h"\r
 #include "validation/AbstractValidatingXMLObject.h"\r
 \r
-#include <typeinfo.h>\r
+#include <xercesc/util/XMLUniDefs.hpp>\r
 \r
 using namespace xmltooling;\r
 using namespace std;\r
@@ -41,6 +41,53 @@ using namespace std;
 \r
 namespace xmltooling {\r
     \r
+    class XMLTOOL_DLLLOCAL RSAKeyValueImpl\r
+        : public RSAKeyValue,\r
+            public AbstractDOMCachingXMLObject,\r
+            public AbstractValidatingXMLObject,\r
+            public AbstractXMLObjectMarshaller,\r
+            public AbstractXMLObjectUnmarshaller\r
+    {\r
+    public:\r
+        virtual ~RSAKeyValueImpl() {}\r
+\r
+        RSAKeyValueImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)\r
+            : AbstractXMLObject(nsURI, localName, prefix, schemaType) {\r
+            init();\r
+        }\r
+            \r
+        RSAKeyValueImpl(const RSAKeyValueImpl& src)\r
+            : AbstractXMLObject(src),\r
+                AbstractDOMCachingXMLObject(src),\r
+                AbstractValidatingXMLObject(src) {\r
+            init();\r
+            setModulus(src.getModulus());\r
+            setExponent(src.getExponent());\r
+        }\r
+        \r
+        void init() {\r
+            m_Modulus=NULL;\r
+            m_Exponent=NULL;\r
+            m_children.push_back(NULL);\r
+            m_children.push_back(NULL);\r
+            m_pos_Modulus=m_children.begin();\r
+            m_pos_Exponent=m_children.begin();\r
+            m_pos_Exponent++;\r
+        }\r
+        \r
+        IMPL_XMLOBJECT_CLONE(RSAKeyValue);\r
+        IMPL_XMLOBJECT_CHILD(Modulus);\r
+        IMPL_XMLOBJECT_CHILD(Exponent);\r
+\r
+    protected:\r
+        void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {\r
+            PROC_XMLOBJECT_CHILD(Modulus,XMLConstants::XMLSIG_NS);\r
+            PROC_XMLOBJECT_CHILD(Exponent,XMLConstants::XMLSIG_NS);\r
+            \r
+            throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString()));\r
+        }\r
+    };\r
+    \r
     class XMLTOOL_DLLLOCAL KeyInfoImpl\r
         : public KeyInfo,\r
             public AbstractDOMCachingXMLObject,\r
@@ -64,12 +111,26 @@ namespace xmltooling {
                 m_Id(XMLString::replicate(src.m_Id)) {\r
                     \r
             for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {\r
-                getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);\r
+                if (*i) {\r
+                    KeyName* kn=dynamic_cast<KeyName*>(*i);\r
+                    if (kn) {\r
+                        getKeyNames().push_back(kn->cloneKeyName());\r
+                        continue;\r
+                    }\r
+                    MgmtData* md=dynamic_cast<MgmtData*>(*i);\r
+                    if (md) {\r
+                        getMgmtDatas().push_back(md->cloneMgmtData());\r
+                        continue;\r
+                    }\r
+                    getXMLObjects().push_back((*i)->clone());\r
+                }\r
             }\r
         }\r
         \r
         IMPL_XMLOBJECT_CLONE(KeyInfo);\r
         IMPL_XMLOBJECT_ATTRIB(Id);\r
+        IMPL_XMLOBJECT_CHILDREN(KeyName,m_children.end());\r
+        IMPL_XMLOBJECT_CHILDREN(MgmtData,m_children.end());\r
 \r
     protected:\r
         void marshallAttributes(DOMElement* domElement) const {\r
@@ -90,7 +151,15 @@ namespace xmltooling {
         }\r
 \r
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {\r
-            getXMLObjects().push_back(childXMLObject);\r
+            PROC_XMLOBJECT_CHILDREN(KeyName,XMLConstants::XMLSIG_NS);\r
+            PROC_XMLOBJECT_CHILDREN(MgmtData,XMLConstants::XMLSIG_NS);\r
+            \r
+            // Unknown child.\r
+            const XMLCh* nsURI=childXMLObject->getElementQName().getNamespaceURI();\r
+            if (!XMLString::equals(nsURI,XMLConstants::XMLSIG_NS) && nsURI && *nsURI)\r
+                getXMLObjects().push_back(childXMLObject);\r
+            \r
+            throw UnmarshallingException("Invalid child element: $1",params(1,childXMLObject->getElementQName().toString()));\r
         }\r
 \r
         void processAttribute(const DOMAttr* attribute) {\r
@@ -101,55 +170,10 @@ namespace xmltooling {
         }\r
     };\r
     \r
-    class XMLTOOL_DLLLOCAL KeyNameImpl\r
-        : public KeyName,\r
-            public AbstractDOMCachingXMLObject,\r
-            public AbstractValidatingXMLObject,\r
-            public AbstractXMLObjectMarshaller,\r
-            public AbstractXMLObjectUnmarshaller\r
-    {\r
-    public:\r
-        virtual ~KeyNameImpl() {}\r
-\r
-        KeyNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)\r
-            : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Name(NULL) {\r
-        }\r
-            \r
-        KeyNameImpl(const KeyNameImpl& src)\r
-            : AbstractXMLObject(src),\r
-                AbstractDOMCachingXMLObject(src),\r
-                AbstractValidatingXMLObject(src),\r
-                m_Name(XMLString::replicate(src.m_Name)) {\r
-        }\r
-        \r
-        IMPL_XMLOBJECT_CLONE(KeyName);\r
-        IMPL_XMLOBJECT_CONTENT(Name);\r
-    };\r
-\r
-    class XMLTOOL_DLLLOCAL MgmtDataImpl\r
-        : public MgmtData,\r
-            public AbstractDOMCachingXMLObject,\r
-            public AbstractValidatingXMLObject,\r
-            public AbstractXMLObjectMarshaller,\r
-            public AbstractXMLObjectUnmarshaller\r
-    {\r
-    public:\r
-        virtual ~MgmtDataImpl() {}\r
-\r
-        MgmtDataImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)\r
-            : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Data(NULL) {\r
-        }\r
-            \r
-        MgmtDataImpl(const MgmtDataImpl& src)\r
-            : AbstractXMLObject(src),\r
-                AbstractDOMCachingXMLObject(src),\r
-                AbstractValidatingXMLObject(src),\r
-                m_Data(XMLString::replicate(src.m_Data)) {\r
-        }\r
-        \r
-        IMPL_XMLOBJECT_CLONE(MgmtData);\r
-        IMPL_XMLOBJECT_CONTENT(Data);\r
-    };\r
+    DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,KeyName,Name);\r
+    DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,MgmtData,Data);\r
+    DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Modulus,Value);\r
+    DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Exponent,Value);\r
 };\r
 \r
 #if defined (_MSC_VER)\r
@@ -161,32 +185,16 @@ namespace xmltooling {
 IMPL_XMLOBJECTBUILDER(KeyInfo);\r
 IMPL_XMLOBJECTBUILDER(KeyName);\r
 IMPL_XMLOBJECTBUILDER(MgmtData);\r
-\r
-// Validators\r
-\r
-void KeyInfoSchemaValidator::validate(const XMLObject* xmlObject) const\r
-{\r
-    const KeyInfo* ptr=dynamic_cast<const KeyInfo*>(xmlObject);\r
-    if (!ptr)\r
-        throw ValidationException("KeyInfoSchemaValidator: unsupported object type ($1)",params(1,typeid(xmlObject).name()));\r
-    if (!ptr->hasChildren())\r
-        throw ValidationException("KeyInfo is empty");\r
-}\r
-\r
-void KeyNameSchemaValidator::validate(const XMLObject* xmlObject) const\r
-{\r
-    const KeyName* ptr=dynamic_cast<const KeyName*>(xmlObject);\r
-    if (!ptr)\r
-        throw ValidationException("KeyNameSchemaValidator: unsupported object type ($1)",params(1,typeid(xmlObject).name()));\r
-    if (XMLString::stringLen(ptr->getName())==0)\r
-        throw ValidationException("KeyName is empty");\r
-}\r
-\r
-void MgmtDataSchemaValidator::validate(const XMLObject* xmlObject) const\r
-{\r
-    const MgmtData* ptr=dynamic_cast<const MgmtData*>(xmlObject);\r
-    if (!ptr)\r
-        throw ValidationException("MgmtDataSchemaValidator: unsupported object type ($1)",params(1,typeid(xmlObject).name()));\r
-    if (XMLString::stringLen(ptr->getData())==0)\r
-        throw ValidationException("MgmtData is empty");\r
-}\r
+IMPL_XMLOBJECTBUILDER(Modulus);\r
+IMPL_XMLOBJECTBUILDER(Exponent);\r
+IMPL_XMLOBJECTBUILDER(RSAKeyValue);\r
+\r
+const XMLCh KeyInfo::LOCAL_NAME[] =         UNICODE_LITERAL_7(K,e,y,I,n,f,o);\r
+const XMLCh KeyInfo::TYPE_NAME[] =          UNICODE_LITERAL_11(K,e,y,I,n,f,o,T,y,p,e);\r
+const XMLCh KeyInfo::ID_ATTRIB_NAME[] =     UNICODE_LITERAL_2(I,d);\r
+const XMLCh MgmtData::LOCAL_NAME[] =        UNICODE_LITERAL_8(M,g,m,t,D,a,t,a);\r
+const XMLCh KeyName::LOCAL_NAME[] =         UNICODE_LITERAL_7(K,e,y,N,a,m,e);\r
+const XMLCh Modulus::LOCAL_NAME[] =         UNICODE_LITERAL_7(M,o,d,u,l,u,s);\r
+const XMLCh Exponent::LOCAL_NAME[] =        UNICODE_LITERAL_8(E,x,p,o,n,e,n,t);\r
+const XMLCh RSAKeyValue::LOCAL_NAME[] =     UNICODE_LITERAL_11(R,S,A,K,e,y,V,a,l,u,e);\r
+const XMLCh RSAKeyValue::TYPE_NAME[] =      UNICODE_LITERAL_15(R,S,A,K,e,y,V,a,l,u,e,T,y,p,e);\r
diff --git a/xmltooling/signature/impl/KeyInfoImpl.h b/xmltooling/signature/impl/KeyInfoImpl.h
deleted file mode 100644 (file)
index cb18679..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*\r
-*  Copyright 2001-2006 Internet2\r
- * \r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * KeyInfoImpl.h\r
- * \r
- * Builder class for KeyInfo \r
- */\r
-\r
-#ifndef __xmltooling_keyinfoimpl_h__\r
-#define __xmltooling_keyinfoimpl_h__\r
-\r
-#include <xmltooling/signature/KeyInfo.h>\r
-#include <xmltooling/util/XMLConstants.h>\r
-#include <xmltooling/validation/Validator.h>\r
-\r
-#define BEGIN_XMLSIGOBJECTBUILDERIMPL(cname) \\r
-    BEGIN_XMLOBJECTBUILDERIMPL(cname,XMLConstants::XMLSIG_NS,XMLConstants::XMLSIG_PREFIX)\r
-\r
-namespace xmltooling {\r
-    \r
-    BEGIN_XMLSIGOBJECTBUILDERIMPL(KeyInfo);\r
-    END_XMLOBJECTBUILDERIMPL;\r
-\r
-    BEGIN_XMLSIGOBJECTBUILDERIMPL(KeyName);\r
-    END_XMLOBJECTBUILDERIMPL;\r
-\r
-    BEGIN_XMLSIGOBJECTBUILDERIMPL(MgmtData);\r
-    END_XMLOBJECTBUILDERIMPL;\r
-    \r
-    BEGIN_XMLOBJECTVALIDATOR(KeyInfoSchema);\r
-    END_XMLOBJECTVALIDATOR;\r
-\r
-    BEGIN_XMLOBJECTVALIDATOR(KeyNameSchema);\r
-    END_XMLOBJECTVALIDATOR;\r
-\r
-    BEGIN_XMLOBJECTVALIDATOR(MgmtDataSchema);\r
-    END_XMLOBJECTVALIDATOR;\r
-};\r
-\r
-#endif /* __xmltooling_keyinfoimpl_h__ */\r
index d320a3d..b561814 100644 (file)
@@ -23,7 +23,7 @@
 #include "internal.h"\r
 #include "exceptions.h"\r
 #include "impl/UnknownElement.h"\r
-#include "signature/impl/XMLSecSignatureImpl.h"\r
+#include "signature/Signature.h"\r
 #include "util/NDC.h"\r
 #include "util/XMLConstants.h"\r
 #include "util/XMLHelper.h"\r
@@ -31,6 +31,7 @@
 #include <log4cpp/Category.hh>\r
 #include <xercesc/framework/MemBufInputSource.hpp>\r
 #include <xercesc/framework/Wrapper4InputSource.hpp>\r
+#include <xercesc/util/XMLUniDefs.hpp>\r
 #include <xsec/dsig/DSIGKeyInfoX509.hpp>\r
 #include <xsec/enc/XSECCryptoException.hpp>\r
 #include <xsec/framework/XSECException.hpp>\r
@@ -236,7 +237,7 @@ DOMElement* XMLSecSignatureImpl::marshall(DOMDocument* document, MarshallingCont
             bindDocument=true;\r
         }\r
         m_signature=XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->newSignature();\r
-        m_signature->setDSIGNSPrefix(Signature::PREFIX);\r
+        m_signature->setDSIGNSPrefix(XMLConstants::XMLSIG_PREFIX);\r
         cachedDOM=m_signature->createBlankSignature(document, getCanonicalizationMethod(), getSignatureAlgorithm());\r
     }\r
     else {\r
@@ -339,7 +340,7 @@ DOMElement* XMLSecSignatureImpl::marshall(DOMElement* parentElement, Marshalling
         // Fresh signature, so we just create an empty one.\r
         log.debug("creating empty Signature element");\r
         m_signature=XMLToolingInternalConfig::getInternalConfig().m_xsecProvider->newSignature();\r
-        m_signature->setDSIGNSPrefix(Signature::PREFIX);\r
+        m_signature->setDSIGNSPrefix(XMLConstants::XMLSIG_PREFIX);\r
         cachedDOM=m_signature->createBlankSignature(\r
             parentElement->getOwnerDocument(), getCanonicalizationMethod(), getSignatureAlgorithm()\r
             );\r
@@ -401,7 +402,7 @@ XMLObject* XMLSecSignatureImpl::unmarshall(DOMElement* element, bool bindDocumen
     return this;\r
 }\r
 \r
-Signature* XMLSecSignatureBuilder::buildObject(\r
+Signature* SignatureBuilder::buildObject(\r
     const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType\r
     ) const\r
 {\r
@@ -410,7 +411,9 @@ Signature* XMLSecSignatureBuilder::buildObject(
     return buildObject();\r
 }\r
 \r
-Signature* XMLSecSignatureBuilder::buildObject() const\r
+Signature* SignatureBuilder::buildObject() const\r
 {\r
     return new XMLSecSignatureImpl();\r
 }\r
+\r
+const XMLCh Signature::LOCAL_NAME[] = UNICODE_LITERAL_9(S,i,g,n,a,t,u,r,e);\r
diff --git a/xmltooling/signature/impl/XMLSecSignatureImpl.h b/xmltooling/signature/impl/XMLSecSignatureImpl.h
deleted file mode 100644 (file)
index 41b2470..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*\r
-*  Copyright 2001-2006 Internet2\r
- * \r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * XMLSecSignatureImpl.h\r
- * \r
- * Builder class for XMLSec-based signature-handling\r
- */\r
-\r
-#if !defined(__xmltooling_xmlsecsig_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
-#define __xmltooling_xmlsecsig_h__\r
-\r
-#include <xmltooling/signature/Signature.h>\r
-\r
-namespace xmltooling {\r
-\r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public SignatureBuilder\r
-    {\r
-    public:\r
-        Signature* buildObject(\r
-            const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix=NULL, const QName* schemaType=NULL\r
-            ) const;\r
-        Signature* buildObject() const;\r
-    };\r
-\r
-};\r
-\r
-#endif /* __xmltooling_xmlsecsig_h__ */\r
index 14d79d6..768d15f 100644 (file)
                                        RelativePath=".\signature\SigningContext.h"\r
                                        >\r
                                </File>\r
-                               <Filter\r
-                                       Name="impl"\r
-                                       >\r
-                                       <File\r
-                                               RelativePath=".\signature\impl\KeyInfoImpl.h"\r
-                                               >\r
-                                       </File>\r
-                                       <File\r
-                                               RelativePath=".\signature\impl\XMLSecSignatureImpl.h"\r
-                                               >\r
-                                       </File>\r
-                               </Filter>\r
                        </Filter>\r
                </Filter>\r
                <Filter\r
index 847931c..4b93174 100644 (file)
@@ -46,7 +46,7 @@ public:
             dynamic_cast<ElementProxy*>(b->buildFromDocument(doc))\r
             );\r
         TS_ASSERT(wcObject.get()!=NULL);\r
-\r
+        \r
         ListOf(XMLObject) kids=wcObject->getXMLObjects();\r
         TSM_ASSERT_EQUALS("Number of child elements was not expected value", 2, kids.size());\r
         \r
index ba1116f..ee5fa88 100644 (file)
@@ -110,6 +110,10 @@ public:
     VectorOf(SimpleXMLObject) getSimpleXMLObjects() {
         return VectorOf(SimpleXMLObject)(this, m_simples, &m_children, m_children.end());
     }
+    
+    const std::vector<SimpleXMLObject*>& getSimpleXMLObjects() const {
+        return m_simples;
+    }
 
 protected:
     void marshallAttributes(DOMElement* domElement) const {