Add implicit support for a "null" protocol.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / MetadataImpl.cpp
index 4ff0864..91615d9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2006 Internet2
+ *  Copyright 2001-2007 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "exceptions.h"
 #include "saml2/metadata/Metadata.h"
 
-#include <xmltooling/AbstractChildlessElement.h>
 #include <xmltooling/AbstractComplexElement.h>
-#include <xmltooling/AbstractElementProxy.h>
 #include <xmltooling/AbstractSimpleElement.h>
 #include <xmltooling/impl/AnyElement.h>
 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
 #include <xmltooling/util/XMLHelper.h>
-#include <xmltooling/validation/AbstractValidatingXMLObject.h>
 
 #include <ctime>
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace samlconstants;
 using namespace opensaml::saml2md;
 using namespace opensaml::saml2;
 using namespace opensaml;
@@ -44,6 +42,8 @@ using namespace xmlencryption;
 using namespace xmlsignature;
 using namespace xmltooling;
 using namespace std;
+using xmlconstants::XMLSIG_NS;
+using xmlconstants::XML_BOOL_NULL;
 
 #if defined (_MSC_VER)
     #pragma warning( push )
@@ -62,11 +62,12 @@ namespace opensaml {
         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SurName);
         DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,TelephoneNumber);
 
+        DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,ActionNamespace);
+        DECL_XMLOBJECTIMPL_SIMPLE(SAML_DLLLOCAL,SourceID);
+
         class SAML_DLLLOCAL localizedNameTypeImpl : public virtual localizedNameType,
             public AbstractSimpleElement,
-            public AbstractChildlessElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -90,32 +91,28 @@ namespace opensaml {
             }
                 
             localizedNameTypeImpl(const localizedNameTypeImpl& src)
-                    : AbstractXMLObject(src), AbstractSimpleElement(src),
-                        AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setLang(src.getLang());
             }
             
             IMPL_XMLOBJECT_CLONE(localizedNameType);
-            IMPL_XMLOBJECT_CONTENT;
             IMPL_STRING_ATTRIB(Lang);
     
         protected:
             void marshallAttributes(DOMElement* domElement) const {
-                MARSHALL_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
+                MARSHALL_STRING_ATTRIB(Lang,LANG,xmlconstants::XML_NS);
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                PROC_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
+                PROC_STRING_ATTRIB(Lang,LANG,xmlconstants::XML_NS);
                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
             }
         };
 
         class SAML_DLLLOCAL localizedURITypeImpl : public virtual localizedURIType,
             public AbstractSimpleElement,
-            public AbstractChildlessElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -139,23 +136,21 @@ namespace opensaml {
             }
                 
             localizedURITypeImpl(const localizedURITypeImpl& src)
-                    : AbstractXMLObject(src), AbstractSimpleElement(src),
-                        AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setLang(src.getLang());
             }
             
             IMPL_XMLOBJECT_CLONE(localizedURIType);
-            IMPL_XMLOBJECT_CONTENT;
             IMPL_STRING_ATTRIB(Lang);
     
         protected:
             void marshallAttributes(DOMElement* domElement) const {
-                MARSHALL_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
+                MARSHALL_STRING_ATTRIB(Lang,LANG,xmlconstants::XML_NS);
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                PROC_STRING_ATTRIB(Lang,LANG,XMLConstants::XML_NS);
+                PROC_STRING_ATTRIB(Lang,LANG,xmlconstants::XML_NS);
                 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
             }
         };
@@ -241,9 +236,8 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions,
+            public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractElementProxy,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -255,23 +249,21 @@ namespace opensaml {
             }
                 
             ExtensionsImpl(const ExtensionsImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractElementProxy(src),
-                        AbstractValidatingXMLObject(src) {
-                for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
-                    if (*i) {
-                        getXMLObjects().push_back((*i)->clone());
-                    }
-                }
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
+                VectorOf(XMLObject) v=getUnknownXMLObjects();
+                for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
+                    v.push_back((*i)->clone());
             }
             
             IMPL_XMLOBJECT_CLONE(Extensions);
+            IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
     
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
                 // Unknown child.
                 const XMLCh* nsURI=root->getNamespaceURI();
-                if (!XMLString::equals(nsURI,SAMLConstants::SAML20MD_NS) && nsURI && *nsURI) {
-                    getXMLObjects().push_back(childXMLObject);
+                if (!XMLString::equals(nsURI,SAML20MD_NS) && nsURI && *nsURI) {
+                    getUnknownXMLObjects().push_back(childXMLObject);
                     return;
                 }
                 
@@ -283,7 +275,6 @@ namespace opensaml {
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -310,10 +301,8 @@ namespace opensaml {
             }
                 
             OrganizationImpl(const OrganizationImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
@@ -345,27 +334,19 @@ namespace opensaml {
     
         protected:
             void marshallAttributes(DOMElement* domElement) const {
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(OrganizationName,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(OrganizationDisplayName,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(OrganizationURL,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(OrganizationName,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(OrganizationDisplayName,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(OrganizationURL,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
@@ -373,7 +354,6 @@ namespace opensaml {
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -409,10 +389,8 @@ namespace opensaml {
             }
                 
             ContactPersonImpl(const ContactPersonImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
@@ -446,51 +424,40 @@ namespace opensaml {
             IMPL_TYPED_CHILDREN(EmailAddress,m_pos_TelephoneNumber);
             IMPL_TYPED_CHILDREN(TelephoneNumber,m_children.end());
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),CONTACTTYPE_ATTRIB_NAME)) {
                         setContactType(value);
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_STRING_ATTRIB(ContactType,CONTACTTYPE,NULL);
-                
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(Company,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(GivenName,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(SurName,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(EmailAddress,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(TelephoneNumber,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(Company,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(GivenName,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(SurName,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(EmailAddress,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(TelephoneNumber,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
         class SAML_DLLLOCAL AdditionalMetadataLocationImpl : public virtual AdditionalMetadataLocation,
             public AbstractSimpleElement,
-            public AbstractChildlessElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -509,13 +476,11 @@ namespace opensaml {
             }
                 
             AdditionalMetadataLocationImpl(const AdditionalMetadataLocationImpl& src)
-                    : AbstractXMLObject(src), AbstractSimpleElement(src),
-                        AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
             }
             
             IMPL_XMLOBJECT_CLONE(AdditionalMetadataLocation);
-            IMPL_XMLOBJECT_CONTENT;
             IMPL_STRING_ATTRIB(Namespace);
     
         protected:
@@ -532,7 +497,6 @@ namespace opensaml {
         class SAML_DLLLOCAL KeyDescriptorImpl : public virtual KeyDescriptor,
             public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -553,7 +517,7 @@ namespace opensaml {
             }
                 
             KeyDescriptorImpl(const KeyDescriptorImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setUse(src.getUse());
                 if (src.getKeyInfo())
@@ -577,8 +541,8 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,XMLConstants::XMLENC_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
@@ -589,10 +553,9 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL EndpointTypeImpl : public virtual EndpointType,
-            public AbstractDOMCachingXMLObject,
-            public AbstractElementProxy,
             public AbstractAttributeExtensibleXMLObject,
-            public AbstractValidatingXMLObject,
+            public AbstractComplexElement,
+            public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -618,26 +581,24 @@ namespace opensaml {
                 
             EndpointTypeImpl(const EndpointTypeImpl& src)
                     : AbstractXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractElementProxy(src),
                         AbstractAttributeExtensibleXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                        AbstractComplexElement(src),
+                        AbstractDOMCachingXMLObject(src) {
                 setBinding(src.getBinding());
                 setLocation(src.getLocation());
                 setResponseLocation(src.getResponseLocation());
-                for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
-                    if (*i) {
-                        getXMLObjects().push_back((*i)->clone());
-                    }
-                }
+                VectorOf(XMLObject) v=getUnknownXMLObjects();
+                for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
+                    v.push_back((*i)->clone());
             }
             
             IMPL_XMLOBJECT_CLONE(EndpointType);
             IMPL_STRING_ATTRIB(Binding);
             IMPL_STRING_ATTRIB(Location);
             IMPL_STRING_ATTRIB(ResponseLocation);
+            IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),BINDING_ATTRIB_NAME)) {
                         setBinding(value);
@@ -652,46 +613,36 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_STRING_ATTRIB(Binding,BINDING,NULL);
                 MARSHALL_STRING_ATTRIB(Location,LOCATION,NULL);
                 MARSHALL_STRING_ATTRIB(ResponseLocation,RESPONSELOCATION,NULL);
-                
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
                 // Unknown child.
                 const XMLCh* nsURI=root->getNamespaceURI();
-                if (!XMLString::equals(nsURI,SAMLConstants::SAML20MD_NS) && nsURI && *nsURI) {
-                    getXMLObjects().push_back(childXMLObject);
+                if (!XMLString::equals(nsURI,SAML20MD_NS) && nsURI && *nsURI) {
+                    getUnknownXMLObjects().push_back(childXMLObject);
                     return;
                 }
-                
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
         class SAML_DLLLOCAL IndexedEndpointTypeImpl : public virtual IndexedEndpointType, public EndpointTypeImpl
         {
             void init() {
-                m_Index=0;
-                m_isDefault=false;
+                m_Index=NULL;
+                m_isDefault=XML_BOOL_NULL;
             }
         
         protected:
@@ -699,14 +650,16 @@ namespace opensaml {
                 init();
             }
         public:
-            virtual ~IndexedEndpointTypeImpl() {}
+            virtual ~IndexedEndpointTypeImpl() {
+                XMLString::release(&m_Index);
+            }
     
             IndexedEndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
                 
             IndexedEndpointTypeImpl(const IndexedEndpointTypeImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {
-                setIndex(src.getIndex());
-                isDefault(src.isDefault());
+                setIndex(src.m_Index);
+                isDefault(src.m_isDefault);
             }
             
             IMPL_XMLOBJECT_CLONE(IndexedEndpointType);
@@ -717,23 +670,18 @@ namespace opensaml {
             IMPL_INTEGER_ATTRIB(Index);
             IMPL_BOOLEAN_ATTRIB(isDefault);
 
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),INDEX_ATTRIB_NAME)) {
-                        setIndex(XMLString::parseInt(value));
+                        setIndex(value);
                         return;
                     }
                     else if (XMLString::equals(qualifiedName.getLocalPart(),ISDEFAULT_ATTRIB_NAME)) {
-                        if (value) {
-                            if (*value==chLatin_t || *value==chDigit_1)
-                                isDefault(true);
-                            else if (*value==chLatin_f || *value==chDigit_0)
-                                isDefault(false);
-                        }
+                        setisDefault(value);
                         return;
                     }
                 }
-                EndpointTypeImpl::setAttribute(qualifiedName, value);
+                EndpointTypeImpl::setAttribute(qualifiedName, value, ID);
             }
         
         protected:
@@ -915,7 +863,6 @@ namespace opensaml {
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -960,10 +907,8 @@ namespace opensaml {
             }
                 
             RoleDescriptorImpl(const RoleDescriptorImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setProtocolSupportEnumeration(src.getProtocolSupportEnumeration());
@@ -991,10 +936,6 @@ namespace opensaml {
                 }
             }
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -1013,17 +954,73 @@ namespace opensaml {
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
             
-            IMPL_STRING_ATTRIB(ID);
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(ProtocolSupportEnumeration);
             IMPL_STRING_ATTRIB(ErrorURL);
-            IMPL_DATETIME_ATTRIB(ValidUntil);
-            IMPL_DATETIME_ATTRIB(CacheDuration);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DATETIME_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(KeyDescriptor,m_pos_Organization);
             IMPL_TYPED_CHILD(Organization);
             IMPL_TYPED_CHILDREN(ContactPerson,m_pos_ContactPerson);
+
+            bool hasSupport(const XMLCh* protocol) const {
+                if (!protocol || !*protocol)
+                    return true;
+                if (m_ProtocolSupportEnumeration) {
+                    // Look for first character.
+                    unsigned int len=XMLString::stringLen(protocol);
+                    unsigned int pos=0;
+                    int index=XMLString::indexOf(m_ProtocolSupportEnumeration,protocol[0],pos);
+                    while (index>=0) {
+                        // Only possible match is if it's the first character or a space comes before it.
+                        if (index==0 || m_ProtocolSupportEnumeration[index-1]==chSpace) {
+                            // See if rest of protocol string is present.
+                            if (0==XMLString::compareNString(m_ProtocolSupportEnumeration+index+1,protocol+1,len-1)) {
+                                // Only possible match is if it's the last character or a space comes after it.
+                                if (m_ProtocolSupportEnumeration[index+len]==chNull || m_ProtocolSupportEnumeration[index+len]==chSpace)
+                                    return true;
+                                else
+                                    pos=index+len;
+                            }
+                            else {
+                                // Move past last search and start again.
+                                pos=index+1;
+                            }
+                        }
+                        else {
+                            // Move past last search and start again.
+                            pos=index+1;
+                        }
+                        index=XMLString::indexOf(m_ProtocolSupportEnumeration,protocol[0],pos);
+                    }
+                }
+                return false;
+            }
+
+            void addSupport(const XMLCh* protocol) {
+                if (hasSupport(protocol))
+                    return;
+                if (m_ProtocolSupportEnumeration && *m_ProtocolSupportEnumeration) {
+#ifdef HAVE_GOOD_STL
+                    xstring pse(m_ProtocolSupportEnumeration);
+                    pse = pse + chSpace + protocol;
+                    setProtocolSupportEnumeration(pse.c_str());
+#else
+                    auto_ptr_char temp(m_ProtocolSupportEnumeration);
+                    auto_ptr_char temp2(protocol);
+                    string pse(temp.get());
+                    pse = pse + ' ' + temp2.get();
+                    auto_ptr_XMLCh temp3(pse.c_str());
+                    setProtocolSupportEnumeration(temp3.get());
+#endif
+                }
+                else {
+                    setProtocolSupportEnumeration(protocol);
+                }
+            }
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
                         setID(value);
@@ -1046,7 +1043,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1056,30 +1053,21 @@ namespace opensaml {
                 MARSHALL_STRING_ATTRIB(ErrorURL,ERRORURL,NULL);
                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
-                
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(KeyDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(Organization,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(ContactPerson,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(KeyDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(Organization,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ContactPerson,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
                 PROC_ID_ATTRIB(ID,ID,NULL);
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
@@ -1153,10 +1141,10 @@ namespace opensaml {
 
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(ArtifactResolutionService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(SingleLogoutService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(ManageNameIDService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ArtifactResolutionService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(SingleLogoutService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ManageNameIDService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(NameIDFormat,SAML20MD_NS,false);
                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -1169,7 +1157,7 @@ namespace opensaml {
             list<XMLObject*>::iterator m_pos_AttributeProfile;
             
             void init() {
-                m_WantAuthnRequestsSigned=false;
+                m_WantAuthnRequestsSigned=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -1194,7 +1182,7 @@ namespace opensaml {
                 
             IDPSSODescriptorImpl(const IDPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
                 init();
-                WantAuthnRequestsSigned(src.WantAuthnRequestsSigned());
+                WantAuthnRequestsSigned(src.m_WantAuthnRequestsSigned);
                 VectorOf(SingleSignOnService) v=getSingleSignOnServices();
                 for (vector<SingleSignOnService*>::const_iterator i=src.m_SingleSignOnServices.begin(); i!=src.m_SingleSignOnServices.end(); i++) {
                     if (*i) {
@@ -1242,19 +1230,14 @@ namespace opensaml {
             IMPL_TYPED_CHILDREN(AttributeProfile,m_pos_AttributeProfile);
             IMPL_TYPED_FOREIGN_CHILDREN(Attribute,saml2,m_children.end());
 
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),WANTAUTHNREQUESTSSIGNED_ATTRIB_NAME)) {
-                        if (value) {
-                            if (*value==chLatin_t || *value==chDigit_1)
-                                WantAuthnRequestsSigned(true);
-                            else if (*value==chLatin_f || *value==chDigit_0)
-                                WantAuthnRequestsSigned(false);
-                        }
+                        setWantAuthnRequestsSigned(value);
                         return;
                     }
                 }
-                RoleDescriptorImpl::setAttribute(qualifiedName, value);
+                RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1264,11 +1247,11 @@ namespace opensaml {
             }
             
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(SingleSignOnService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(NameIDMappingService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AttributeProfile,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false);
+                PROC_TYPED_CHILDREN(SingleSignOnService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(NameIDMappingService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AttributeProfile,SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAML20_NS,false);
                 SSODescriptorTypeImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -1277,13 +1260,12 @@ namespace opensaml {
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
             void init() {
                 m_Name=m_NameFormat=m_FriendlyName=NULL;
-                m_isRequired=false;
+                m_isRequired=XML_BOOL_NULL;
             }
         public:
             virtual ~RequestedAttributeImpl() {
@@ -1298,15 +1280,13 @@ namespace opensaml {
             }
                 
             RequestedAttributeImpl(const RequestedAttributeImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setName(src.getName());
                 setNameFormat(src.getNameFormat());
                 setFriendlyName(src.getFriendlyName());
-                isRequired(src.isRequired());
+                isRequired(src.m_isRequired);
                 VectorOf(XMLObject) v=getAttributeValues();
                 for (vector<XMLObject*>::const_iterator i=src.m_AttributeValues.begin(); i!=src.m_AttributeValues.end(); i++) {
                     if (*i) {
@@ -1326,7 +1306,7 @@ namespace opensaml {
             IMPL_BOOLEAN_ATTRIB(isRequired);
             IMPL_XMLOBJECT_CHILDREN(AttributeValue,m_children.end());
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),NAME_ATTRIB_NAME)) {
                         setName(value);
@@ -1341,16 +1321,11 @@ namespace opensaml {
                         return;
                     }
                     else if (XMLString::equals(qualifiedName.getLocalPart(),ISREQUIRED_ATTRIB_NAME)) {
-                        if (value) {
-                            if (*value==chLatin_t || *value==chDigit_1)
-                                isRequired(true);
-                            else if (*value==chLatin_f || *value==chDigit_0)
-                                isRequired(false);
-                        }
+                        setisRequired(value);
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1359,15 +1334,7 @@ namespace opensaml {
                 MARSHALL_STRING_ATTRIB(NameFormat,NAMEFORMAT,NULL);
                 MARSHALL_STRING_ATTRIB(FriendlyName,FRIENDLYNAME,NULL);
                 MARSHALL_BOOLEAN_ATTRIB(isRequired,ISREQUIRED,NULL);
-
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
@@ -1375,15 +1342,13 @@ namespace opensaml {
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
         class SAML_DLLLOCAL AttributeConsumingServiceImpl : public virtual AttributeConsumingService,
             public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -1391,8 +1356,8 @@ namespace opensaml {
             list<XMLObject*>::iterator m_pos_RequestedAttribute;
             
                void init() {
-                m_Index=1;
-                m_isDefault=false;
+                m_Index=NULL;
+                m_isDefault=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
                 m_pos_ServiceDescription=m_children.begin();
@@ -1401,7 +1366,9 @@ namespace opensaml {
             }
 
         public:
-            virtual ~AttributeConsumingServiceImpl() {}
+            virtual ~AttributeConsumingServiceImpl() {
+                XMLString::release(&m_Index);
+            }
     
             AttributeConsumingServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
@@ -1409,10 +1376,10 @@ namespace opensaml {
             }
                 
             AttributeConsumingServiceImpl(const AttributeConsumingServiceImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
-                setIndex(src.getIndex());
-                isDefault(src.isDefault());
+                setIndex(src.m_Index);
+                isDefault(src.m_isDefault);
                 VectorOf(ServiceName) v=getServiceNames();
                 for (vector<ServiceName*>::const_iterator i=src.m_ServiceNames.begin(); i!=src.m_ServiceNames.end(); i++) {
                     if (*i) {
@@ -1447,9 +1414,9 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(ServiceName,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(ServiceDescription,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(RequestedAttribute,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ServiceName,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ServiceDescription,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(RequestedAttribute,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
@@ -1465,8 +1432,8 @@ namespace opensaml {
             list<XMLObject*>::iterator m_pos_AssertionConsumerService;
             
             void init() {
-                m_AuthnRequestsSigned=false;
-                m_WantAssertionsSigned=false;
+                m_AuthnRequestsSigned=XML_BOOL_NULL;
+                m_WantAssertionsSigned=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_pos_AssertionConsumerService=m_pos_NameIDFormat;
                 ++m_pos_AssertionConsumerService;
@@ -1482,8 +1449,8 @@ namespace opensaml {
                 
             SPSSODescriptorImpl(const SPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
                 init();
-                AuthnRequestsSigned(src.AuthnRequestsSigned());
-                WantAssertionsSigned(src.WantAssertionsSigned());
+                AuthnRequestsSigned(src.m_AuthnRequestsSigned);
+                WantAssertionsSigned(src.m_WantAssertionsSigned);
                 VectorOf(AssertionConsumerService) v=getAssertionConsumerServices();
                 for (vector<AssertionConsumerService*>::const_iterator i=src.m_AssertionConsumerServices.begin(); i!=src.m_AssertionConsumerServices.end(); i++) {
                     if (*i) {
@@ -1511,28 +1478,18 @@ namespace opensaml {
             IMPL_TYPED_CHILDREN(AssertionConsumerService,m_pos_AssertionConsumerService);
             IMPL_TYPED_CHILDREN(AttributeConsumingService,m_children.end());
 
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),AUTHNREQUESTSSIGNED_ATTRIB_NAME)) {
-                        if (value) {
-                            if (*value==chLatin_t || *value==chDigit_1)
-                                AuthnRequestsSigned(true);
-                            else if (*value==chLatin_f || *value==chDigit_0)
-                                AuthnRequestsSigned(false);
-                        }
+                        setAuthnRequestsSigned(value);
                         return;
                     }
                     else if (XMLString::equals(qualifiedName.getLocalPart(),WANTASSERTIONSSIGNED_ATTRIB_NAME)) {
-                        if (value) {
-                            if (*value==chLatin_t || *value==chDigit_1)
-                                WantAssertionsSigned(true);
-                            else if (*value==chLatin_f || *value==chDigit_0)
-                                WantAssertionsSigned(false);
-                        }
+                        setWantAssertionsSigned(value);
                         return;
                     }
                 }
-                RoleDescriptorImpl::setAttribute(qualifiedName, value);
+                RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1543,8 +1500,8 @@ namespace opensaml {
             }
             
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(AssertionConsumerService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AttributeConsumingService,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AssertionConsumerService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AttributeConsumingService,SAML20MD_NS,false);
                 SSODescriptorTypeImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -1604,9 +1561,9 @@ namespace opensaml {
 
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(AuthnQueryService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AuthnQueryService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(NameIDFormat,SAML20MD_NS,false);
                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -1666,9 +1623,9 @@ namespace opensaml {
 
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(AuthzService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AuthzService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(NameIDFormat,SAML20MD_NS,false);
                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
             }
         };
@@ -1750,21 +1707,169 @@ namespace opensaml {
 
         protected:
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_CHILDREN(AttributeService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(NameIDFormat,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AttributeProfile,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAMLConstants::SAML20_NS,false);
+                PROC_TYPED_CHILDREN(AttributeService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AssertionIDRequestService,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(NameIDFormat,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AttributeProfile,SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILDREN(Attribute,saml2,SAML20_NS,false);
                 RoleDescriptorImpl::processChildElement(childXMLObject,root);
             }
         };
 
+        class SAML_DLLLOCAL QueryDescriptorTypeImpl : public virtual QueryDescriptorType, public RoleDescriptorImpl
+        {
+            void init() {
+                m_WantAssertionsSigned=XML_BOOL_NULL;
+                m_children.push_back(NULL);
+                m_pos_NameIDFormat=m_pos_ContactPerson;
+                ++m_pos_NameIDFormat;
+            }
+        
+        protected:
+            list<XMLObject*>::iterator m_pos_NameIDFormat;
+            
+            QueryDescriptorTypeImpl() {
+                init();
+            }
+        
+        public:
+            virtual ~QueryDescriptorTypeImpl() {}
+    
+            QueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+                : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
+                init();
+            }
+                
+            QueryDescriptorTypeImpl(const QueryDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
+                init();
+                WantAssertionsSigned(src.m_WantAssertionsSigned);
+                VectorOf(NameIDFormat) y=getNameIDFormats();
+                for (vector<NameIDFormat*>::const_iterator m=src.m_NameIDFormats.begin(); m!=src.m_NameIDFormats.end(); m++) {
+                    if (*m) {
+                        y.push_back((*m)->cloneNameIDFormat());
+                    }
+                }
+            }
+            
+            IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned);
+            IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat);
+
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
+                if (!qualifiedName.hasNamespaceURI()) {
+                    if (XMLString::equals(qualifiedName.getLocalPart(),WANTASSERTIONSSIGNED_ATTRIB_NAME)) {
+                        setWantAssertionsSigned(value);
+                        return;
+                    }
+                }
+                RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
+            }
+
+        protected:
+            void marshallAttributes(DOMElement* domElement) const {
+                MARSHALL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,NULL);
+                RoleDescriptorImpl::marshallAttributes(domElement);
+            }
+
+            void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+                PROC_TYPED_CHILDREN(NameIDFormat,SAML20MD_NS,false);
+                RoleDescriptorImpl::processChildElement(childXMLObject,root);
+            }
+        };
+
+        class SAML_DLLLOCAL AuthnQueryDescriptorTypeImpl : public virtual AuthnQueryDescriptorType, public QueryDescriptorTypeImpl
+        {
+        public:
+            virtual ~AuthnQueryDescriptorTypeImpl() {}
+    
+            AuthnQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+                : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
+                
+            AuthnQueryDescriptorTypeImpl(const AuthnQueryDescriptorTypeImpl& src) : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {}
+            
+            IMPL_XMLOBJECT_CLONE(AuthnQueryDescriptorType);
+            QueryDescriptorType* cloneQueryDescriptorType() const {
+                return new AuthnQueryDescriptorTypeImpl(*this);
+            }
+            RoleDescriptor* cloneRoleDescriptor() const {
+                return new AuthnQueryDescriptorTypeImpl(*this);
+            }
+        };
+
+        class SAML_DLLLOCAL AttributeQueryDescriptorTypeImpl : public virtual AttributeQueryDescriptorType, public QueryDescriptorTypeImpl
+        {
+        public:
+            virtual ~AttributeQueryDescriptorTypeImpl() {}
+    
+            AttributeQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+                : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
+                
+            AttributeQueryDescriptorTypeImpl(const AttributeQueryDescriptorTypeImpl& src)
+                    : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {
+                VectorOf(AttributeConsumingService) w=getAttributeConsumingServices();
+                for (vector<AttributeConsumingService*>::const_iterator j=src.m_AttributeConsumingServices.begin(); j!=src.m_AttributeConsumingServices.end(); j++) {
+                    if (*j) {
+                        w.push_back((*j)->cloneAttributeConsumingService());
+                    }
+                }
+            }
+            
+            IMPL_XMLOBJECT_CLONE(AttributeQueryDescriptorType);
+            QueryDescriptorType* cloneQueryDescriptorType() const {
+                return new AttributeQueryDescriptorTypeImpl(*this);
+            }
+            RoleDescriptor* cloneRoleDescriptor() const {
+                return new AttributeQueryDescriptorTypeImpl(*this);
+            }
+            
+            IMPL_TYPED_CHILDREN(AttributeConsumingService,m_children.end());
+
+        protected:
+            void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+                PROC_TYPED_CHILDREN(AttributeConsumingService,SAML20MD_NS,false);
+                QueryDescriptorTypeImpl::processChildElement(childXMLObject,root);
+            }
+        };
+
+        class SAML_DLLLOCAL AuthzDecisionQueryDescriptorTypeImpl : public virtual AuthzDecisionQueryDescriptorType, public QueryDescriptorTypeImpl
+        {
+        public:
+            virtual ~AuthzDecisionQueryDescriptorTypeImpl() {}
+    
+            AuthzDecisionQueryDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+                : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
+                
+            AuthzDecisionQueryDescriptorTypeImpl(const AuthzDecisionQueryDescriptorTypeImpl& src)
+                    : AbstractXMLObject(src), QueryDescriptorTypeImpl(src) {
+                VectorOf(ActionNamespace) w=getActionNamespaces();
+                for (vector<ActionNamespace*>::const_iterator j=src.m_ActionNamespaces.begin(); j!=src.m_ActionNamespaces.end(); j++) {
+                    if (*j) {
+                        w.push_back((*j)->cloneActionNamespace());
+                    }
+                }
+            }
+            
+            IMPL_XMLOBJECT_CLONE(AuthzDecisionQueryDescriptorType);
+            QueryDescriptorType* cloneQueryDescriptorType() const {
+                return new AuthzDecisionQueryDescriptorTypeImpl(*this);
+            }
+            RoleDescriptor* cloneRoleDescriptor() const {
+                return new AuthzDecisionQueryDescriptorTypeImpl(*this);
+            }
+            
+            IMPL_TYPED_CHILDREN(ActionNamespace,m_children.end());
+
+        protected:
+            void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+                PROC_TYPED_CHILDREN(ActionNamespace,samlconstants::SAML20MD_QUERY_EXT_NS,false);
+                QueryDescriptorTypeImpl::processChildElement(childXMLObject,root);
+            }
+        };
+
         class SAML_DLLLOCAL AffiliationDescriptorImpl : public virtual AffiliationDescriptor,
             public virtual SignableObject,
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -1799,10 +1904,8 @@ namespace opensaml {
             }
                 
             AffiliationDescriptorImpl(const AffiliationDescriptorImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setAffiliationOwnerID(src.getAffiliationOwnerID());
@@ -1829,10 +1932,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(AffiliationDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -1851,15 +1950,15 @@ namespace opensaml {
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
             
-            IMPL_STRING_ATTRIB(ID);
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(AffiliationOwnerID);
-            IMPL_DATETIME_ATTRIB(ValidUntil);
-            IMPL_DATETIME_ATTRIB(CacheDuration);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DATETIME_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(AffiliateMember,m_pos_AffiliateMember);
             IMPL_TYPED_CHILDREN(KeyDescriptor,m_children.end());
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
                         setID(value);
@@ -1878,7 +1977,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1887,29 +1986,20 @@ namespace opensaml {
                 MARSHALL_STRING_ATTRIB(AffiliationOwnerID,AFFILIATIONOWNERID,NULL);
                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
-                
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AffiliateMember,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(KeyDescriptor,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AffiliateMember,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(KeyDescriptor,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
                 PROC_ID_ATTRIB(ID,ID,NULL);
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
@@ -1918,7 +2008,6 @@ namespace opensaml {
             public AbstractComplexElement,
             public AbstractAttributeExtensibleXMLObject,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -1961,10 +2050,8 @@ namespace opensaml {
             }
                 
             EntityDescriptorImpl(const EntityDescriptorImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractAttributeExtensibleXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setEntityID(src.getEntityID());
@@ -2011,6 +2098,24 @@ namespace opensaml {
                             continue;
                         }
     
+                        AuthnQueryDescriptorType* authnq=dynamic_cast<AuthnQueryDescriptorType*>(*i);
+                        if (authnq) {
+                            getAuthnQueryDescriptorTypes().push_back(authnq->cloneAuthnQueryDescriptorType());
+                            continue;
+                        }
+
+                        AttributeQueryDescriptorType* attrq=dynamic_cast<AttributeQueryDescriptorType*>(*i);
+                        if (attrq) {
+                            getAttributeQueryDescriptorTypes().push_back(attrq->cloneAttributeQueryDescriptorType());
+                            continue;
+                        }
+
+                        AuthzDecisionQueryDescriptorType* authzq=dynamic_cast<AuthzDecisionQueryDescriptorType*>(*i);
+                        if (authzq) {
+                            getAuthzDecisionQueryDescriptorTypes().push_back(authzq->cloneAuthzDecisionQueryDescriptorType());
+                            continue;
+                        }
+
                         RoleDescriptor* role=dynamic_cast<RoleDescriptor*>(*i);
                         if (role) {
                             getRoleDescriptors().push_back(role->cloneRoleDescriptor());
@@ -2035,10 +2140,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(EntityDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -2057,10 +2158,10 @@ namespace opensaml {
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
             
-            IMPL_STRING_ATTRIB(ID);
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(EntityID);
-            IMPL_DATETIME_ATTRIB(ValidUntil);
-            IMPL_DATETIME_ATTRIB(CacheDuration);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DATETIME_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(RoleDescriptor,m_pos_AffiliationDescriptor);
             IMPL_TYPED_CHILDREN(IDPSSODescriptor,m_pos_AffiliationDescriptor);
@@ -2068,12 +2169,15 @@ namespace opensaml {
             IMPL_TYPED_CHILDREN(AuthnAuthorityDescriptor,m_pos_AffiliationDescriptor);
             IMPL_TYPED_CHILDREN(AttributeAuthorityDescriptor,m_pos_AffiliationDescriptor);
             IMPL_TYPED_CHILDREN(PDPDescriptor,m_pos_AffiliationDescriptor);
+            IMPL_TYPED_CHILDREN(AuthnQueryDescriptorType,m_pos_AffiliationDescriptor);
+            IMPL_TYPED_CHILDREN(AttributeQueryDescriptorType,m_pos_AffiliationDescriptor);
+            IMPL_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType,m_pos_AffiliationDescriptor);
             IMPL_TYPED_CHILD(AffiliationDescriptor);
             IMPL_TYPED_CHILD(Organization);
             IMPL_TYPED_CHILDREN(ContactPerson,m_pos_ContactPerson);
             IMPL_TYPED_CHILDREN(AdditionalMetadataLocation,m_children.end());
     
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
                         setID(value);
@@ -2092,7 +2196,31 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
+            }
+
+            const RoleDescriptor* getRoleDescriptor(const xmltooling::QName& qname, const XMLCh* protocol) const {
+                // Check for "known" elements/types.
+                if (qname == IDPSSODescriptor::ELEMENT_QNAME)
+                    return find_if(m_IDPSSODescriptors, isValidForProtocol(protocol));
+                if (qname == SPSSODescriptor::ELEMENT_QNAME)
+                    return find_if(m_SPSSODescriptors, isValidForProtocol(protocol));
+                if (qname == AuthnAuthorityDescriptor::ELEMENT_QNAME)
+                    return find_if(m_AuthnAuthorityDescriptors, isValidForProtocol(protocol));
+                if (qname == AttributeAuthorityDescriptor::ELEMENT_QNAME)
+                    return find_if(m_AttributeAuthorityDescriptors, isValidForProtocol(protocol));
+                if (qname == PDPDescriptor::ELEMENT_QNAME)
+                    return find_if(m_PDPDescriptors, isValidForProtocol(protocol));
+                if (qname == AuthnQueryDescriptorType::TYPE_QNAME)
+                    return find_if(m_AuthnQueryDescriptorTypes, isValidForProtocol(protocol));
+                if (qname == AttributeQueryDescriptorType::TYPE_QNAME)
+                    return find_if(m_AttributeQueryDescriptorTypes, isValidForProtocol(protocol));
+                if (qname == AuthzDecisionQueryDescriptorType::TYPE_QNAME)
+                    return find_if(m_AuthzDecisionQueryDescriptorTypes, isValidForProtocol(protocol));
+                
+                vector<RoleDescriptor*>::const_iterator i =
+                    find_if(m_RoleDescriptors.begin(), m_RoleDescriptors.end(), ofTypeValidForProtocol(qname,protocol));
+                return (i!=m_RoleDescriptors.end()) ? *i : NULL;
             }
 
         protected:
@@ -2101,37 +2229,31 @@ namespace opensaml {
                 MARSHALL_STRING_ATTRIB(EntityID,ENTITYID,NULL);
                 MARSHALL_DATETIME_ATTRIB(ValidUntil,VALIDUNTIL,NULL);
                 MARSHALL_DATETIME_ATTRIB(CacheDuration,CACHEDURATION,NULL);
-                
-                // Take care of wildcard.
-                for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                    DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
-                    if (i->first.hasPrefix())
-                        attr->setPrefix(i->first.getPrefix());
-                    attr->setNodeValue(i->second);
-                    domElement->setAttributeNode(attr);
-                }
+                marshallExtensionAttributes(domElement);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(RoleDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(IDPSSODescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(SPSSODescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AuthnAuthorityDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AttributeAuthorityDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(PDPDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(AffiliationDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILD(Organization,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(ContactPerson,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(AdditionalMetadataLocation,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(IDPSSODescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(SPSSODescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AuthnAuthorityDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AttributeAuthorityDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(PDPDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AuthnQueryDescriptorType,samlconstants::SAML20MD_QUERY_EXT_NS,false);
+                PROC_TYPED_CHILDREN(AttributeQueryDescriptorType,samlconstants::SAML20MD_QUERY_EXT_NS,false);
+                PROC_TYPED_CHILDREN(AuthzDecisionQueryDescriptorType,samlconstants::SAML20MD_QUERY_EXT_NS,false);
+                PROC_TYPED_CHILDREN(RoleDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(AffiliationDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILD(Organization,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(ContactPerson,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(AdditionalMetadataLocation,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
             void processAttribute(const DOMAttr* attribute) {
                 PROC_ID_ATTRIB(ID,ID,NULL);
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
@@ -2139,7 +2261,6 @@ namespace opensaml {
             public virtual SignableObject,
             public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
-            public AbstractValidatingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
@@ -2169,9 +2290,7 @@ namespace opensaml {
             }
                 
             EntitiesDescriptorImpl(const EntitiesDescriptorImpl& src)
-                    : AbstractXMLObject(src),
-                        AbstractDOMCachingXMLObject(src),
-                        AbstractValidatingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setName(src.getName());
@@ -2201,10 +2320,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(EntitiesDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -2223,10 +2338,10 @@ namespace opensaml {
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
             
-            IMPL_STRING_ATTRIB(ID);
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(Name);
-            IMPL_DATETIME_ATTRIB(ValidUntil);
-            IMPL_DATETIME_ATTRIB(CacheDuration);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DATETIME_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(EntityDescriptor,m_children.end());
             IMPL_TYPED_CHILDREN(EntitiesDescriptor,m_children.end());
@@ -2240,10 +2355,10 @@ namespace opensaml {
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_CHILD(Extensions,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(EntityDescriptor,SAMLConstants::SAML20MD_NS,false);
-                PROC_TYPED_CHILDREN(EntitiesDescriptor,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(Signature,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_CHILD(Extensions,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(EntityDescriptor,SAML20MD_NS,false);
+                PROC_TYPED_CHILDREN(EntitiesDescriptor,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
@@ -2262,6 +2377,15 @@ namespace opensaml {
     #pragma warning( pop )
 #endif
 
+IMPL_ELEMENT_QNAME(IDPSSODescriptor, SAML20MD_NS, SAML20MD_PREFIX);
+IMPL_ELEMENT_QNAME(SPSSODescriptor, SAML20MD_NS, SAML20MD_PREFIX);
+IMPL_ELEMENT_QNAME(AuthnAuthorityDescriptor, SAML20MD_NS, SAML20MD_PREFIX);
+IMPL_ELEMENT_QNAME(AttributeAuthorityDescriptor, SAML20MD_NS, SAML20MD_PREFIX);
+IMPL_ELEMENT_QNAME(PDPDescriptor, SAML20MD_NS, SAML20MD_PREFIX);
+IMPL_TYPE_QNAME(AuthnQueryDescriptorType, SAML20MD_QUERY_EXT_NS, SAML20MD_QUERY_EXT_PREFIX);
+IMPL_TYPE_QNAME(AttributeQueryDescriptorType, SAML20MD_QUERY_EXT_NS, SAML20MD_QUERY_EXT_PREFIX);
+IMPL_TYPE_QNAME(AuthzDecisionQueryDescriptorType, SAML20MD_QUERY_EXT_NS, SAML20MD_QUERY_EXT_PREFIX);
+
 // Builder Implementations
 
 IMPL_XMLOBJECTBUILDER(AdditionalMetadataLocation);
@@ -2273,9 +2397,12 @@ IMPL_XMLOBJECTBUILDER(AssertionIDRequestService);
 IMPL_XMLOBJECTBUILDER(AttributeAuthorityDescriptor);
 IMPL_XMLOBJECTBUILDER(AttributeConsumingService);
 IMPL_XMLOBJECTBUILDER(AttributeProfile);
+IMPL_XMLOBJECTBUILDER(AttributeQueryDescriptorType);
 IMPL_XMLOBJECTBUILDER(AttributeService);
 IMPL_XMLOBJECTBUILDER(AuthnAuthorityDescriptor);
+IMPL_XMLOBJECTBUILDER(AuthnQueryDescriptorType);
 IMPL_XMLOBJECTBUILDER(AuthnQueryService);
+IMPL_XMLOBJECTBUILDER(AuthzDecisionQueryDescriptorType);
 IMPL_XMLOBJECTBUILDER(AuthzService);
 IMPL_XMLOBJECTBUILDER(Company);
 IMPL_XMLOBJECTBUILDER(ContactPerson);
@@ -2307,6 +2434,10 @@ IMPL_XMLOBJECTBUILDER(SPSSODescriptor);
 IMPL_XMLOBJECTBUILDER(SurName);
 IMPL_XMLOBJECTBUILDER(TelephoneNumber);
 
+IMPL_XMLOBJECTBUILDER(ActionNamespace);
+IMPL_XMLOBJECTBUILDER(SourceID);
+
+const XMLCh ActionNamespace::LOCAL_NAME[] =             UNICODE_LITERAL_15(A,c,t,i,o,n,N,a,m,e,s,p,a,c,e);
 const XMLCh AdditionalMetadataLocation::LOCAL_NAME[] =  UNICODE_LITERAL_26(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n);
 const XMLCh AdditionalMetadataLocation::TYPE_NAME[] =   UNICODE_LITERAL_30(A,d,d,i,t,i,o,n,a,l,M,e,t,a,d,a,t,a,L,o,c,a,t,i,o,n,T,y,p,e);
 const XMLCh AdditionalMetadataLocation::NAMESPACE_ATTRIB_NAME[] =   UNICODE_LITERAL_9(n,a,m,e,s,p,a,c,e);
@@ -2314,8 +2445,6 @@ const XMLCh AffiliateMember::LOCAL_NAME[] =             UNICODE_LITERAL_15(A,f,f
 const XMLCh AffiliationDescriptor::LOCAL_NAME[] =       UNICODE_LITERAL_21(A,f,f,i,l,i,a,t,i,o,n,D,e,s,c,r,i,p,t,o,r);
 const XMLCh AffiliationDescriptor::TYPE_NAME[] =        UNICODE_LITERAL_25(A,f,f,i,l,i,a,t,i,o,n,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh AffiliationDescriptor::ID_ATTRIB_NAME[] =   UNICODE_LITERAL_2(I,D);
-const XMLCh AffiliationDescriptor::VALIDUNTIL_ATTRIB_NAME[] =   UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);
-const XMLCh AffiliationDescriptor::CACHEDURATION_ATTRIB_NAME[] =    UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
 const XMLCh AffiliationDescriptor::AFFILIATIONOWNERID_ATTRIB_NAME[] =   UNICODE_LITERAL_18(a,f,f,i,l,i,a,t,i,o,n,O,w,n,e,r,I,D);
 const XMLCh ArtifactResolutionService::LOCAL_NAME[] =   UNICODE_LITERAL_25(A,r,t,i,f,a,c,t,R,e,s,o,l,u,t,i,o,n,S,e,r,v,i,c,e);
 const XMLCh AssertionConsumerService::LOCAL_NAME[] =    UNICODE_LITERAL_24(A,s,s,e,r,t,i,o,n,C,o,n,s,u,m,e,r,S,e,r,v,i,c,e);
@@ -2327,11 +2456,18 @@ const XMLCh AttributeConsumingService::TYPE_NAME[] =    UNICODE_LITERAL_29(A,t,t
 const XMLCh AttributeConsumingService::INDEX_ATTRIB_NAME[] =    UNICODE_LITERAL_5(i,n,d,e,x);
 const XMLCh AttributeConsumingService::ISDEFAULT_ATTRIB_NAME[] =    UNICODE_LITERAL_9(i,s,D,e,f,a,u,l,t);
 const XMLCh AttributeProfile::LOCAL_NAME[] =            UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,P,r,o,f,i,l,e);
+const XMLCh AttributeQueryDescriptorType::LOCAL_NAME[] =UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
+const XMLCh AttributeQueryDescriptorType::TYPE_NAME[] = UNICODE_LITERAL_28(A,t,t,r,i,b,u,t,e,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh AttributeService::LOCAL_NAME[] =            UNICODE_LITERAL_16(A,t,t,r,i,b,u,t,e,S,e,r,v,i,c,e);
 const XMLCh AuthnAuthorityDescriptor::LOCAL_NAME[] =    UNICODE_LITERAL_24(A,u,t,h,n,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r);
 const XMLCh AuthnAuthorityDescriptor::TYPE_NAME[] =     UNICODE_LITERAL_28(A,u,t,h,n,A,u,t,h,o,r,i,t,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
+const XMLCh AuthnQueryDescriptorType::LOCAL_NAME[] =    UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
+const XMLCh AuthnQueryDescriptorType::TYPE_NAME[] =     UNICODE_LITERAL_24(A,u,t,h,n,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh AuthnQueryService::LOCAL_NAME[] =           UNICODE_LITERAL_17(A,u,t,h,n,Q,u,e,r,y,S,e,r,v,i,c,e);
+const XMLCh AuthzDecisionQueryDescriptorType::LOCAL_NAME[] =    UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
+const XMLCh AuthzDecisionQueryDescriptorType::TYPE_NAME[] = UNICODE_LITERAL_32(A,u,t,h,z,D,e,c,i,s,i,o,n,Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh AuthzService::LOCAL_NAME[] =                UNICODE_LITERAL_12(A,u,t,h,z,S,e,r,v,i,c,e);
+const XMLCh CacheableSAMLObject::CACHEDURATION_ATTRIB_NAME[] =  UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
 const XMLCh Company::LOCAL_NAME[] =                     UNICODE_LITERAL_7(C,o,m,p,a,n,y);
 const XMLCh ContactPerson::LOCAL_NAME[] =               UNICODE_LITERAL_13(C,o,n,t,a,c,t,P,e,r,s,o,n);
 const XMLCh ContactPerson::TYPE_NAME[] =                UNICODE_LITERAL_11(C,o,n,t,a,c,t,T,y,p,e);
@@ -2350,14 +2486,10 @@ const XMLCh EndpointType::RESPONSELOCATION_ATTRIB_NAME[] =  UNICODE_LITERAL_16(R
 const XMLCh EntitiesDescriptor::LOCAL_NAME[] =          UNICODE_LITERAL_18(E,n,t,i,t,i,e,s,D,e,s,c,r,i,p,t,o,r);
 const XMLCh EntitiesDescriptor::TYPE_NAME[] =           UNICODE_LITERAL_22(E,n,t,i,t,i,e,s,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh EntitiesDescriptor::ID_ATTRIB_NAME[] =      UNICODE_LITERAL_2(I,D);
-const XMLCh EntitiesDescriptor::VALIDUNTIL_ATTRIB_NAME[] =    UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);
-const XMLCh EntitiesDescriptor::CACHEDURATION_ATTRIB_NAME[] = UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
 const XMLCh EntitiesDescriptor::NAME_ATTRIB_NAME[] =    UNICODE_LITERAL_4(N,a,m,e);
 const XMLCh EntityDescriptor::LOCAL_NAME[] =            UNICODE_LITERAL_16(E,n,t,i,t,y,D,e,s,c,r,i,p,t,o,r);
 const XMLCh EntityDescriptor::TYPE_NAME[] =             UNICODE_LITERAL_20(E,n,t,i,t,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh EntityDescriptor::ID_ATTRIB_NAME[] =        UNICODE_LITERAL_2(I,D);
-const XMLCh EntityDescriptor::VALIDUNTIL_ATTRIB_NAME[] =    UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);
-const XMLCh EntityDescriptor::CACHEDURATION_ATTRIB_NAME[] = UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
 const XMLCh EntityDescriptor::ENTITYID_ATTRIB_NAME[] =  UNICODE_LITERAL_8(e,n,t,i,t,y,I,D);
 const XMLCh Extensions::LOCAL_NAME[] =                  UNICODE_LITERAL_10(E,x,t,e,n,s,i,o,n,s);
 const XMLCh Extensions::TYPE_NAME[] =                   UNICODE_LITERAL_14(E,x,t,e,n,s,i,o,n,s,T,y,p,e);
@@ -2390,19 +2522,21 @@ const XMLCh OrganizationDisplayName::LOCAL_NAME[] =     UNICODE_LITERAL_23(O,r,g
 const XMLCh OrganizationURL::LOCAL_NAME[] =             UNICODE_LITERAL_15(O,r,g,a,n,i,z,a,t,i,o,n,U,R,L);
 const XMLCh PDPDescriptor::LOCAL_NAME[] =               UNICODE_LITERAL_13(P,D,P,D,e,s,c,r,i,p,t,o,r);
 const XMLCh PDPDescriptor::TYPE_NAME[] =                UNICODE_LITERAL_17(P,D,P,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
+const XMLCh QueryDescriptorType::LOCAL_NAME[] =         {chNull};
+const XMLCh QueryDescriptorType::TYPE_NAME[] =          UNICODE_LITERAL_19(Q,u,e,r,y,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
+const XMLCh QueryDescriptorType::WANTASSERTIONSSIGNED_ATTRIB_NAME[] =   UNICODE_LITERAL_20(W,a,n,t,A,s,s,e,r,t,i,o,n,s,S,i,g,n,e,d);
 const XMLCh RequestedAttribute::LOCAL_NAME[] =          UNICODE_LITERAL_18(R,e,q,u,e,s,t,e,d,A,t,t,r,i,b,u,t,e);
 const XMLCh RequestedAttribute::TYPE_NAME[] =           UNICODE_LITERAL_22(R,e,q,u,e,s,t,e,d,A,t,t,r,i,b,u,t,e,T,y,p,e);
 const XMLCh RequestedAttribute::ISREQUIRED_ATTRIB_NAME[] =  UNICODE_LITERAL_10(i,s,R,e,q,u,i,r,e,d);
 const XMLCh RoleDescriptor::LOCAL_NAME[] =              UNICODE_LITERAL_14(R,o,l,e,D,e,s,c,r,i,p,t,o,r);
 const XMLCh RoleDescriptor::ID_ATTRIB_NAME[] =          UNICODE_LITERAL_2(I,D);
-const XMLCh RoleDescriptor::VALIDUNTIL_ATTRIB_NAME[] =  UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);
-const XMLCh RoleDescriptor::CACHEDURATION_ATTRIB_NAME[] =   UNICODE_LITERAL_13(c,a,c,h,e,D,u,r,a,t,i,o,n);
 const XMLCh RoleDescriptor::PROTOCOLSUPPORTENUMERATION_ATTRIB_NAME[] =  UNICODE_LITERAL_26(p,r,o,t,o,c,o,l,S,u,p,p,o,r,t,E,n,u,m,e,r,a,t,i,o,n);
 const XMLCh RoleDescriptor::ERRORURL_ATTRIB_NAME[] =    UNICODE_LITERAL_8(e,r,r,o,r,U,R,L);
 const XMLCh ServiceDescription::LOCAL_NAME[] =          UNICODE_LITERAL_18(S,e,r,v,i,c,e,D,e,s,c,r,i,p,t,i,o,n);
 const XMLCh ServiceName::LOCAL_NAME[] =                 UNICODE_LITERAL_11(S,e,r,v,i,c,e,N,a,m,e);
 const XMLCh SingleLogoutService::LOCAL_NAME[] =         UNICODE_LITERAL_19(S,i,n,g,l,e,L,o,g,o,u,t,S,e,r,v,i,c,e);
 const XMLCh SingleSignOnService::LOCAL_NAME[] =         UNICODE_LITERAL_19(S,i,n,g,l,e,S,i,g,n,O,n,S,e,r,v,i,c,e);
+const XMLCh SourceID::LOCAL_NAME[] =                    UNICODE_LITERAL_8(S,o,u,r,c,e,I,D);
 const XMLCh SPSSODescriptor::LOCAL_NAME[] =             UNICODE_LITERAL_15(S,P,S,S,O,D,e,s,c,r,i,p,t,o,r);
 const XMLCh SPSSODescriptor::TYPE_NAME[] =              UNICODE_LITERAL_19(S,P,S,S,O,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh SPSSODescriptor::AUTHNREQUESTSSIGNED_ATTRIB_NAME[] =    UNICODE_LITERAL_19(A,u,t,h,n,R,e,q,u,e,s,t,s,S,i,g,n,e,d);
@@ -2411,3 +2545,4 @@ const XMLCh SSODescriptorType::LOCAL_NAME[] =           {chNull};
 const XMLCh SSODescriptorType::TYPE_NAME[] =            UNICODE_LITERAL_17(S,S,O,D,e,s,c,r,i,p,t,o,r,T,y,p,e);
 const XMLCh SurName::LOCAL_NAME[] =                     UNICODE_LITERAL_7(S,u,r,N,a,m,e);
 const XMLCh TelephoneNumber::LOCAL_NAME[] =             UNICODE_LITERAL_15(T,e,l,e,p,h,o,n,e,N,u,m,b,e,r);
+const XMLCh TimeBoundSAMLObject::VALIDUNTIL_ATTRIB_NAME[] =   UNICODE_LITERAL_10(v,a,l,i,d,U,n,t,i,l);