Plug a few memory leaks.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / MetadataImpl.cpp
index e853b65..cc23134 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  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.
  * You may obtain a copy of the License at
@@ -16,7 +16,7 @@
 
 /**
  * MetadataImpl.cpp
- * 
+ *
  * Implementation classes for SAML 2.0 Assertions schema
  */
 
@@ -24,9 +24,7 @@
 #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>
@@ -36,6 +34,7 @@
 #include <ctime>
 #include <xercesc/util/XMLUniDefs.hpp>
 
+using namespace samlconstants;
 using namespace opensaml::saml2md;
 using namespace opensaml::saml2;
 using namespace opensaml;
@@ -43,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 )
@@ -61,9 +62,11 @@ 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 AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -71,46 +74,44 @@ namespace opensaml {
             void init() {
                 m_Lang=NULL;
             }
-            
+
         protected:
             localizedNameTypeImpl() {
                 init();
             }
-            
+
         public:
             virtual ~localizedNameTypeImpl() {
                 XMLString::release(&m_Lang);
             }
-    
+
             localizedNameTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             localizedNameTypeImpl(const localizedNameTypeImpl& 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 AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -118,39 +119,38 @@ namespace opensaml {
             void init() {
                 m_Lang=NULL;
             }
-            
+
         protected:
             localizedURITypeImpl() {
                 init();
             }
-            
+
         public:
             virtual ~localizedURITypeImpl() {
                 XMLString::release(&m_Lang);
             }
-    
+
             localizedURITypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             localizedURITypeImpl(const localizedURITypeImpl& 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);
             }
         };
@@ -159,28 +159,28 @@ namespace opensaml {
         {
         public:
             virtual ~OrganizationNameImpl() {}
-    
+
             OrganizationNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             OrganizationNameImpl(const OrganizationNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(OrganizationName);
             localizedNameType* clonelocalizedNameType() const {
                 return new OrganizationNameImpl(*this);
             }
         };
-               
+
         class SAML_DLLLOCAL OrganizationDisplayNameImpl : public virtual OrganizationDisplayName, public localizedNameTypeImpl
         {
         public:
             virtual ~OrganizationDisplayNameImpl() {}
-    
+
             OrganizationDisplayNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             OrganizationDisplayNameImpl(const OrganizationDisplayNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(OrganizationDisplayName);
             localizedNameType* clonelocalizedNameType() const {
                 return new OrganizationDisplayNameImpl(*this);
@@ -191,12 +191,12 @@ namespace opensaml {
         {
         public:
             virtual ~OrganizationURLImpl() {}
-    
+
             OrganizationURLImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             OrganizationURLImpl(const OrganizationURLImpl& src) : AbstractXMLObject(src), localizedURITypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(OrganizationURL);
             localizedURIType* clonelocalizedURIType() const {
                 return new OrganizationURLImpl(*this);
@@ -207,12 +207,12 @@ namespace opensaml {
         {
         public:
             virtual ~ServiceNameImpl() {}
-    
+
             ServiceNameImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             ServiceNameImpl(const ServiceNameImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(ServiceName);
             localizedNameType* clonelocalizedNameType() const {
                 return new ServiceNameImpl(*this);
@@ -223,12 +223,12 @@ namespace opensaml {
         {
         public:
             virtual ~ServiceDescriptionImpl() {}
-    
+
             ServiceDescriptionImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             ServiceDescriptionImpl(const ServiceDescriptionImpl& src) : AbstractXMLObject(src), localizedNameTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(ServiceDescription);
             localizedNameType* clonelocalizedNameType() const {
                 return new ServiceDescriptionImpl(*this);
@@ -236,38 +236,37 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL ExtensionsImpl : public virtual Extensions,
-            public AbstractElementProxy,
+            public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
         {
         public:
             virtual ~ExtensionsImpl() {}
-    
+
             ExtensionsImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
-                
+
             ExtensionsImpl(const ExtensionsImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src), AbstractElementProxy(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;
                 }
-                
+
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
         };
@@ -281,7 +280,7 @@ namespace opensaml {
         {
             list<XMLObject*>::iterator m_pos_OrganizationDisplayName;
             list<XMLObject*>::iterator m_pos_OrganizationURL;
-            
+
             void init() {
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -295,14 +294,15 @@ namespace opensaml {
             }
         public:
             virtual ~OrganizationImpl() {}
-    
+
             OrganizationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             OrganizationImpl(const OrganizationImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
@@ -325,36 +325,28 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(Organization);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(OrganizationName,m_pos_OrganizationDisplayName);
             IMPL_TYPED_CHILDREN(OrganizationDisplayName,m_pos_OrganizationURL);
             IMPL_TYPED_CHILDREN(OrganizationURL,m_children.end());
-    
+
         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);
             }
         };
 
@@ -366,7 +358,7 @@ namespace opensaml {
             public AbstractXMLObjectUnmarshaller
         {
             list<XMLObject*>::iterator m_pos_TelephoneNumber;
-            
+
             void init() {
                 m_ContactType=NULL;
                 m_children.push_back(NULL);
@@ -389,15 +381,18 @@ namespace opensaml {
                 ++m_pos_TelephoneNumber;
             }
         public:
-            virtual ~ContactPersonImpl() {}
-    
+            virtual ~ContactPersonImpl() {
+                XMLString::release(&m_ContactType);
+            }
+
             ContactPersonImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             ContactPersonImpl(const ContactPersonImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
@@ -407,7 +402,7 @@ namespace opensaml {
                     setGivenName(src.getGivenName()->cloneGivenName());
                 if (src.getSurName())
                     setSurName(src.getSurName()->cloneSurName());
-                
+
                 VectorOf(EmailAddress) v=getEmailAddresss();
                 for (vector<EmailAddress*>::const_iterator i=src.m_EmailAddresss.begin(); i!=src.m_EmailAddresss.end(); i++) {
                     if (*i) {
@@ -421,7 +416,7 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(ContactPerson);
             IMPL_STRING_ATTRIB(ContactType);
             IMPL_TYPED_CHILD(Extensions);
@@ -430,50 +425,40 @@ namespace opensaml {
             IMPL_TYPED_CHILD(SurName);
             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 AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -481,26 +466,25 @@ namespace opensaml {
             void init() {
                 m_Namespace=NULL;
             }
-            
+
         public:
             virtual ~AdditionalMetadataLocationImpl() {
                 XMLString::release(&m_Namespace);
             }
-    
+
             AdditionalMetadataLocationImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                     : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             AdditionalMetadataLocationImpl(const AdditionalMetadataLocationImpl& src)
                     : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
             }
-            
+
             IMPL_XMLOBJECT_CLONE(AdditionalMetadataLocation);
-            IMPL_XMLOBJECT_CONTENT;
             IMPL_STRING_ATTRIB(Namespace);
-    
+
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_STRING_ATTRIB(Namespace,NAMESPACE,NULL);
@@ -528,13 +512,14 @@ namespace opensaml {
             virtual ~KeyDescriptorImpl() {
                 XMLString::release(&m_Use);
             }
-    
+
             KeyDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
-            KeyDescriptorImpl(const KeyDescriptorImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+
+            KeyDescriptorImpl(const KeyDescriptorImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setUse(src.getUse());
                 if (src.getKeyInfo())
@@ -546,20 +531,20 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(KeyDescriptor);
             IMPL_STRING_ATTRIB(Use);
             IMPL_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature);
             IMPL_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,m_children.end());
-    
+
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_STRING_ATTRIB(Use,USE,NULL);
             }
 
             void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-                PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLConstants::XMLSIG_NS,false);
-                PROC_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,SAMLConstants::SAML20MD_NS,false);
+                PROC_TYPED_FOREIGN_CHILD(KeyInfo,xmlsignature,XMLSIG_NS,false);
+                PROC_TYPED_FOREIGN_CHILDREN(EncryptionMethod,xmlencryption,SAML20MD_NS,false);
                 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
             }
 
@@ -570,8 +555,8 @@ namespace opensaml {
         };
 
         class SAML_DLLLOCAL EndpointTypeImpl : public virtual EndpointType,
-            public AbstractElementProxy,
             public AbstractAttributeExtensibleXMLObject,
+            public AbstractComplexElement,
             public AbstractDOMCachingXMLObject,
             public AbstractXMLObjectMarshaller,
             public AbstractXMLObjectUnmarshaller
@@ -579,42 +564,43 @@ namespace opensaml {
             void init() {
                 m_Binding=m_Location=m_ResponseLocation=NULL;
             }
-        
+
         protected:
             EndpointTypeImpl() {
                 init();
             }
-            
+
         public:
             virtual ~EndpointTypeImpl() {
                 XMLString::release(&m_Binding);
                 XMLString::release(&m_Location);
                 XMLString::release(&m_ResponseLocation);
             }
-    
+
             EndpointTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
             }
-                
+
             EndpointTypeImpl(const EndpointTypeImpl& src)
-                    : AbstractXMLObject(src), AbstractElementProxy(src),
-                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src),
+                        AbstractAttributeExtensibleXMLObject(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);
-    
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+            IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
+
+            void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),BINDING_ATTRIB_NAME)) {
                         setBinding(value);
@@ -629,38 +615,28 @@ 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);
             }
         };
 
@@ -668,9 +644,9 @@ namespace opensaml {
         {
             void init() {
                 m_Index=NULL;
-                m_isDefault=XMLConstants::XML_BOOL_NULL;
+                m_isDefault=XML_BOOL_NULL;
             }
-        
+
         protected:
             IndexedEndpointTypeImpl() {
                 init();
@@ -679,24 +655,24 @@ namespace opensaml {
             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.m_Index);
                 isDefault(src.m_isDefault);
             }
-            
+
             IMPL_XMLOBJECT_CLONE(IndexedEndpointType);
             EndpointType* cloneEndpointType() const {
                 return new IndexedEndpointTypeImpl(*this);
             }
-            
+
             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(value);
@@ -707,9 +683,9 @@ namespace opensaml {
                         return;
                     }
                 }
-                EndpointTypeImpl::setAttribute(qualifiedName, value);
+                EndpointTypeImpl::setAttribute(qualifiedName, value, ID);
             }
-        
+
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_INTEGER_ATTRIB(Index,INDEX,NULL);
@@ -722,12 +698,12 @@ namespace opensaml {
         {
         public:
             virtual ~ArtifactResolutionServiceImpl() {}
-    
+
             ArtifactResolutionServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             ArtifactResolutionServiceImpl(const ArtifactResolutionServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(ArtifactResolutionService);
             IndexedEndpointType* cloneIndexedEndpointType() const {
                 return new ArtifactResolutionServiceImpl(*this);
@@ -741,12 +717,12 @@ namespace opensaml {
         {
         public:
             virtual ~SingleLogoutServiceImpl() {}
-    
+
             SingleLogoutServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             SingleLogoutServiceImpl(const SingleLogoutServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(SingleLogoutService);
             EndpointType* cloneEndpointType() const {
                 return new SingleLogoutServiceImpl(*this);
@@ -757,12 +733,12 @@ namespace opensaml {
         {
         public:
             virtual ~ManageNameIDServiceImpl() {}
-    
+
             ManageNameIDServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             ManageNameIDServiceImpl(const ManageNameIDServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(ManageNameIDService);
             EndpointType* cloneEndpointType() const {
                 return new ManageNameIDServiceImpl(*this);
@@ -773,12 +749,12 @@ namespace opensaml {
         {
         public:
             virtual ~SingleSignOnServiceImpl() {}
-    
+
             SingleSignOnServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             SingleSignOnServiceImpl(const SingleSignOnServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(SingleSignOnService);
             EndpointType* cloneEndpointType() const {
                 return new SingleSignOnServiceImpl(*this);
@@ -789,28 +765,28 @@ namespace opensaml {
         {
         public:
             virtual ~NameIDMappingServiceImpl() {}
-    
+
             NameIDMappingServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             NameIDMappingServiceImpl(const NameIDMappingServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(NameIDMappingService);
             EndpointType* cloneEndpointType() const {
                 return new NameIDMappingServiceImpl(*this);
             }
         };
-               
+
         class SAML_DLLLOCAL AssertionIDRequestServiceImpl : public virtual AssertionIDRequestService, public EndpointTypeImpl
         {
         public:
             virtual ~AssertionIDRequestServiceImpl() {}
-    
+
             AssertionIDRequestServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             AssertionIDRequestServiceImpl(const AssertionIDRequestServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(AssertionIDRequestService);
             EndpointType* cloneEndpointType() const {
                 return new AssertionIDRequestServiceImpl(*this);
@@ -821,12 +797,12 @@ namespace opensaml {
         {
         public:
             virtual ~AssertionConsumerServiceImpl() {}
-    
+
             AssertionConsumerServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             AssertionConsumerServiceImpl(const AssertionConsumerServiceImpl& src) : AbstractXMLObject(src), IndexedEndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(AssertionConsumerService);
             EndpointType* cloneEndpointType() const {
                 return new AssertionConsumerServiceImpl(*this);
@@ -840,12 +816,12 @@ namespace opensaml {
         {
         public:
             virtual ~AuthnQueryServiceImpl() {}
-    
+
             AuthnQueryServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             AuthnQueryServiceImpl(const AuthnQueryServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(AuthnQueryService);
             EndpointType* cloneEndpointType() const {
                 return new AuthnQueryServiceImpl(*this);
@@ -856,12 +832,12 @@ namespace opensaml {
         {
         public:
             virtual ~AuthzServiceImpl() {}
-    
+
             AuthzServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             AuthzServiceImpl(const AuthzServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(AuthzService);
             EndpointType* cloneEndpointType() const {
                 return new AuthzServiceImpl(*this);
@@ -872,12 +848,12 @@ namespace opensaml {
         {
         public:
             virtual ~AttributeServiceImpl() {}
-    
+
             AttributeServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {}
-                
+
             AttributeServiceImpl(const AttributeServiceImpl& src) : AbstractXMLObject(src), EndpointTypeImpl(src) {}
-            
+
             IMPL_XMLOBJECT_CLONE(AttributeService);
             EndpointType* cloneEndpointType() const {
                 return new AttributeServiceImpl(*this);
@@ -910,14 +886,14 @@ namespace opensaml {
                 m_pos_ContactPerson=m_pos_Organization;
                 ++m_pos_ContactPerson;
             }
-            
+
         protected:
             list<XMLObject*>::iterator m_pos_ContactPerson;
 
             RoleDescriptorImpl() {
                 init();
             }
-            
+
         public:
             virtual ~RoleDescriptorImpl() {
                 XMLString::release(&m_ID);
@@ -926,14 +902,15 @@ namespace opensaml {
                 delete m_ValidUntil;
                 delete m_CacheDuration;
             }
-    
+
             RoleDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             RoleDescriptorImpl(const RoleDescriptorImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setProtocolSupportEnumeration(src.getProtocolSupportEnumeration());
@@ -946,7 +923,7 @@ namespace opensaml {
                     setExtensions(src.getExtensions()->cloneExtensions());
                 if (src.getOrganization())
                     setOrganization(src.getOrganization()->cloneOrganization());
-                
+
                 VectorOf(KeyDescriptor) v=getKeyDescriptors();
                 for (vector<KeyDescriptor*>::const_iterator i=src.m_KeyDescriptors.begin(); i!=src.m_KeyDescriptors.end(); i++) {
                     if (*i) {
@@ -961,10 +938,6 @@ namespace opensaml {
                 }
             }
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -974,7 +947,7 @@ namespace opensaml {
             Signature* getSignature() const {
                 return m_Signature;
             }
-            
+
             void setSignature(Signature* sig) {
                 prepareForAssignment(m_Signature,sig);
                 *m_pos_Signature=m_Signature=sig;
@@ -982,18 +955,20 @@ namespace opensaml {
                 if (m_Signature)
                     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,LLONG_MAX);
-            IMPL_DATETIME_ATTRIB(CacheDuration,0);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DURATION_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);
@@ -1024,8 +999,30 @@ namespace opensaml {
                 }
                 return false;
             }
-    
-            void setAttribute(QName& qualifiedName, const XMLCh* value) {
+
+            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(const QName& qualifiedName, const XMLCh* value, bool ID=false) {
                 if (!qualifiedName.hasNamespaceURI()) {
                     if (XMLString::equals(qualifiedName.getLocalPart(),ID_ATTRIB_NAME)) {
                         setID(value);
@@ -1048,7 +1045,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1058,30 +1055,49 @@ 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);
+            }
+        };
+
+        class SAML_DLLLOCAL RoleDescriptorTypeImpl : public virtual RoleDescriptorType, public RoleDescriptorImpl
+        {
+        public:
+            virtual ~RoleDescriptorTypeImpl() {}
+
+            RoleDescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
+                : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
+            }
+
+            RoleDescriptorTypeImpl(const RoleDescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(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(RoleDescriptorType);
+            RoleDescriptor* cloneRoleDescriptor() const {
+                return new RoleDescriptorTypeImpl(*this);
+            }
+
+            IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject,m_children.end());
+
+        protected:
+            void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
+                getUnknownXMLObjects().push_back(childXMLObject);
             }
         };
 
@@ -1101,25 +1117,25 @@ namespace opensaml {
                 m_pos_NameIDFormat=m_pos_ManageNameIDService;
                 ++m_pos_NameIDFormat;
             }
-        
+
         protected:
             list<XMLObject*>::iterator m_pos_ArtifactResolutionService;
             list<XMLObject*>::iterator m_pos_SingleLogoutService;
             list<XMLObject*>::iterator m_pos_ManageNameIDService;
             list<XMLObject*>::iterator m_pos_NameIDFormat;
-            
+
             SSODescriptorTypeImpl() {
                 init();
             }
-        
+
         public:
             virtual ~SSODescriptorTypeImpl() {}
-    
+
             SSODescriptorTypeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             SSODescriptorTypeImpl(const SSODescriptorTypeImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
                 init();
                 VectorOf(ArtifactResolutionService) v=getArtifactResolutionServices();
@@ -1147,7 +1163,7 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_TYPED_CHILDREN(ArtifactResolutionService,m_pos_ArtifactResolutionService);
             IMPL_TYPED_CHILDREN(SingleLogoutService,m_pos_SingleLogoutService);
             IMPL_TYPED_CHILDREN(ManageNameIDService,m_pos_ManageNameIDService);
@@ -1155,10 +1171,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,9 +1185,9 @@ namespace opensaml {
             list<XMLObject*>::iterator m_pos_NameIDMappingService;
             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
             list<XMLObject*>::iterator m_pos_AttributeProfile;
-            
+
             void init() {
-                m_WantAuthnRequestsSigned=XMLConstants::XML_BOOL_NULL;
+                m_WantAuthnRequestsSigned=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -1185,15 +1201,15 @@ namespace opensaml {
                 m_pos_AttributeProfile=m_pos_AssertionIDRequestService;
                 ++m_pos_AttributeProfile;
             }
-        
+
         public:
             virtual ~IDPSSODescriptorImpl() {}
-    
+
             IDPSSODescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             IDPSSODescriptorImpl(const IDPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
                 init();
                 WantAuthnRequestsSigned(src.m_WantAuthnRequestsSigned);
@@ -1228,7 +1244,7 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(IDPSSODescriptor);
             SSODescriptorType* cloneSSODescriptorType() const {
                 return new IDPSSODescriptorImpl(*this);
@@ -1236,7 +1252,7 @@ namespace opensaml {
             RoleDescriptor* cloneRoleDescriptor() const {
                 return new IDPSSODescriptorImpl(*this);
             }
-            
+
             IMPL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned);
             IMPL_TYPED_CHILDREN(SingleSignOnService,m_pos_SingleSignOnService);
             IMPL_TYPED_CHILDREN(NameIDMappingService,m_pos_NameIDMappingService);
@@ -1244,14 +1260,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)) {
                         setWantAuthnRequestsSigned(value);
                         return;
                     }
                 }
-                RoleDescriptorImpl::setAttribute(qualifiedName, value);
+                RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1259,13 +1275,13 @@ namespace opensaml {
                 MARSHALL_BOOLEAN_ATTRIB(WantAuthnRequestsSigned,WANTAUTHNREQUESTSSIGNED,NULL);
                 RoleDescriptorImpl::marshallAttributes(domElement);
             }
-            
+
             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);
             }
         };
@@ -1279,7 +1295,7 @@ namespace opensaml {
         {
             void init() {
                 m_Name=m_NameFormat=m_FriendlyName=NULL;
-                m_isRequired=XMLConstants::XML_BOOL_NULL;
+                m_isRequired=XML_BOOL_NULL;
             }
         public:
             virtual ~RequestedAttributeImpl() {
@@ -1287,14 +1303,15 @@ namespace opensaml {
                 XMLString::release(&m_NameFormat);
                 XMLString::release(&m_FriendlyName);
             }
-    
+
             RequestedAttributeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             RequestedAttributeImpl(const RequestedAttributeImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setName(src.getName());
                 setNameFormat(src.getNameFormat());
@@ -1307,19 +1324,19 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(RequestedAttribute);
             Attribute* cloneAttribute() const {
                 return new RequestedAttributeImpl(*this);
             }
-            
+
             IMPL_STRING_ATTRIB(Name);
             IMPL_STRING_ATTRIB(NameFormat);
             IMPL_STRING_ATTRIB(FriendlyName);
             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);
@@ -1338,7 +1355,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1347,15 +1364,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) {
@@ -1363,8 +1372,7 @@ namespace opensaml {
             }
 
             void processAttribute(const DOMAttr* attribute) {
-                QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); 
-                setAttribute(q,attribute->getNodeValue());
+                unmarshallExtensionAttribute(attribute);
             }
         };
 
@@ -1376,10 +1384,10 @@ namespace opensaml {
         {
             list<XMLObject*>::iterator m_pos_ServiceDescription;
             list<XMLObject*>::iterator m_pos_RequestedAttribute;
-            
+
                void init() {
                 m_Index=NULL;
-                m_isDefault=XMLConstants::XML_BOOL_NULL;
+                m_isDefault=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
                 m_pos_ServiceDescription=m_children.begin();
@@ -1391,14 +1399,14 @@ namespace opensaml {
             virtual ~AttributeConsumingServiceImpl() {
                 XMLString::release(&m_Index);
             }
-    
+
             AttributeConsumingServiceImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             AttributeConsumingServiceImpl(const AttributeConsumingServiceImpl& src)
-                    : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setIndex(src.m_Index);
                 isDefault(src.m_isDefault);
@@ -1421,14 +1429,14 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(AttributeConsumingService);
             IMPL_INTEGER_ATTRIB(Index);
             IMPL_BOOLEAN_ATTRIB(isDefault);
             IMPL_TYPED_CHILDREN(ServiceName,m_pos_ServiceDescription);
             IMPL_TYPED_CHILDREN(ServiceDescription,m_pos_RequestedAttribute);
             IMPL_TYPED_CHILDREN(RequestedAttribute,m_children.end());
-    
+
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_INTEGER_ATTRIB(Index,INDEX,NULL);
@@ -1436,9 +1444,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);
             }
 
@@ -1452,23 +1460,23 @@ namespace opensaml {
         class SAML_DLLLOCAL SPSSODescriptorImpl : public virtual SPSSODescriptor, public SSODescriptorTypeImpl
         {
             list<XMLObject*>::iterator m_pos_AssertionConsumerService;
-            
+
             void init() {
-                m_AuthnRequestsSigned=XMLConstants::XML_BOOL_NULL;
-                m_WantAssertionsSigned=XMLConstants::XML_BOOL_NULL;
+                m_AuthnRequestsSigned=XML_BOOL_NULL;
+                m_WantAssertionsSigned=XML_BOOL_NULL;
                 m_children.push_back(NULL);
                 m_pos_AssertionConsumerService=m_pos_NameIDFormat;
                 ++m_pos_AssertionConsumerService;
             }
-        
+
         public:
             virtual ~SPSSODescriptorImpl() {}
-    
+
             SPSSODescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             SPSSODescriptorImpl(const SPSSODescriptorImpl& src) : AbstractXMLObject(src), SSODescriptorTypeImpl(src) {
                 init();
                 AuthnRequestsSigned(src.m_AuthnRequestsSigned);
@@ -1486,7 +1494,7 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(SPSSODescriptor);
             SSODescriptorType* cloneSSODescriptorType() const {
                 return cloneSPSSODescriptor();
@@ -1494,13 +1502,13 @@ namespace opensaml {
             RoleDescriptor* cloneRoleDescriptor() const {
                 return cloneSPSSODescriptor();
             }
-            
+
             IMPL_BOOLEAN_ATTRIB(AuthnRequestsSigned);
             IMPL_BOOLEAN_ATTRIB(WantAssertionsSigned);
             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)) {
                         setAuthnRequestsSigned(value);
@@ -1511,7 +1519,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                RoleDescriptorImpl::setAttribute(qualifiedName, value);
+                RoleDescriptorImpl::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1520,10 +1528,10 @@ namespace opensaml {
                 MARSHALL_BOOLEAN_ATTRIB(WantAssertionsSigned,WANTASSERTIONSSIGNED,NULL);
                 RoleDescriptorImpl::marshallAttributes(domElement);
             }
-            
+
             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);
             }
         };
@@ -1532,7 +1540,7 @@ namespace opensaml {
         {
             list<XMLObject*>::iterator m_pos_AuthnQueryService;
             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
-            
+
             void init() {
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -1541,15 +1549,15 @@ namespace opensaml {
                 m_pos_AssertionIDRequestService=m_pos_AuthnQueryService;
                 ++m_pos_AssertionIDRequestService;
             }
-        
+
         public:
             virtual ~AuthnAuthorityDescriptorImpl() {}
-    
+
             AuthnAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             AuthnAuthorityDescriptorImpl(const AuthnAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
                 init();
                 VectorOf(AuthnQueryService) v=getAuthnQueryServices();
@@ -1571,21 +1579,21 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(AuthnAuthorityDescriptor);
             RoleDescriptor* cloneRoleDescriptor() const {
                 return cloneAuthnAuthorityDescriptor();
             }
-            
+
             IMPL_TYPED_CHILDREN(AuthnQueryService,m_pos_AuthnQueryService);
             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
             IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end());
 
         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);
             }
         };
@@ -1594,7 +1602,7 @@ namespace opensaml {
         {
             list<XMLObject*>::iterator m_pos_AuthzService;
             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
-            
+
             void init() {
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -1603,15 +1611,15 @@ namespace opensaml {
                 m_pos_AssertionIDRequestService=m_pos_AuthzService;
                 ++m_pos_AssertionIDRequestService;
             }
-        
+
         public:
             virtual ~PDPDescriptorImpl() {}
-    
+
             PDPDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             PDPDescriptorImpl(const PDPDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
                 init();
                 VectorOf(AuthzService) v=getAuthzServices();
@@ -1633,21 +1641,21 @@ namespace opensaml {
                     }
                 }
             }
-            
+
             IMPL_XMLOBJECT_CLONE(PDPDescriptor);
             RoleDescriptor* cloneRoleDescriptor() const {
                 return clonePDPDescriptor();
             }
-            
+
             IMPL_TYPED_CHILDREN(AuthzService,m_pos_AuthzService);
             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
             IMPL_TYPED_CHILDREN(NameIDFormat,m_children.end());
 
         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);
             }
         };
@@ -1658,7 +1666,7 @@ namespace opensaml {
             list<XMLObject*>::iterator m_pos_AssertionIDRequestService;
             list<XMLObject*>::iterator m_pos_NameIDFormat;
             list<XMLObject*>::iterator m_pos_AttributeProfile;
-        
+
             void init() {
                 m_children.push_back(NULL);
                 m_children.push_back(NULL);
@@ -1673,15 +1681,15 @@ namespace opensaml {
                 m_pos_AttributeProfile=m_pos_NameIDFormat;
                 ++m_pos_AttributeProfile;
             }
-        
+
         public:
             virtual ~AttributeAuthorityDescriptorImpl() {}
-    
+
             AttributeAuthorityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             AttributeAuthorityDescriptorImpl(const AttributeAuthorityDescriptorImpl& src) : AbstractXMLObject(src), RoleDescriptorImpl(src) {
                 init();
                 VectorOf(AttributeService) v=getAttributeServices();
@@ -1720,7 +1728,7 @@ namespace opensaml {
             RoleDescriptor* cloneRoleDescriptor() const {
                 return cloneAttributeAuthorityDescriptor();
             }
-            
+
             IMPL_TYPED_CHILDREN(AttributeService,m_pos_AttributeService);
             IMPL_TYPED_CHILDREN(AssertionIDRequestService,m_pos_AssertionIDRequestService);
             IMPL_TYPED_CHILDREN(NameIDFormat,m_pos_NameIDFormat);
@@ -1729,15 +1737,164 @@ 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,
@@ -1762,7 +1919,7 @@ namespace opensaml {
                 m_pos_AffiliateMember=m_pos_Extensions;
                 ++m_pos_AffiliateMember;
             }
-            
+
         public:
             virtual ~AffiliationDescriptorImpl() {
                 XMLString::release(&m_ID);
@@ -1770,14 +1927,15 @@ namespace opensaml {
                 delete m_ValidUntil;
                 delete m_CacheDuration;
             }
-    
+
             AffiliationDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             AffiliationDescriptorImpl(const AffiliationDescriptorImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setAffiliationOwnerID(src.getAffiliationOwnerID());
@@ -1787,7 +1945,7 @@ namespace opensaml {
                     setSignature(src.getSignature()->cloneSignature());
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
-                
+
                 VectorOf(KeyDescriptor) v=getKeyDescriptors();
                 for (vector<KeyDescriptor*>::const_iterator i=src.m_KeyDescriptors.begin(); i!=src.m_KeyDescriptors.end(); i++) {
                     if (*i) {
@@ -1804,10 +1962,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(AffiliationDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -1817,7 +1971,7 @@ namespace opensaml {
             Signature* getSignature() const {
                 return m_Signature;
             }
-            
+
             void setSignature(Signature* sig) {
                 prepareForAssignment(m_Signature,sig);
                 *m_pos_Signature=m_Signature=sig;
@@ -1825,16 +1979,16 @@ namespace opensaml {
                 if (m_Signature)
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
-            
-            IMPL_STRING_ATTRIB(ID);
+
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(AffiliationOwnerID);
-            IMPL_DATETIME_ATTRIB(ValidUntil,LLONG_MAX);
-            IMPL_DATETIME_ATTRIB(CacheDuration,0);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DURATION_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);
@@ -1853,7 +2007,7 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
         protected:
@@ -1862,29 +2016,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);
             }
         };
 
@@ -1920,7 +2065,7 @@ namespace opensaml {
                 m_pos_ContactPerson=m_pos_Organization;
                 ++m_pos_ContactPerson;
             }
-            
+
         public:
             virtual ~EntityDescriptorImpl() {
                 XMLString::release(&m_ID);
@@ -1928,14 +2073,15 @@ namespace opensaml {
                 delete m_ValidUntil;
                 delete m_CacheDuration;
             }
-    
+
             EntityDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
+
             EntityDescriptorImpl(const EntityDescriptorImpl& src)
-                    : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
+                    : AbstractXMLObject(src), AbstractComplexElement(src),
+                        AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setEntityID(src.getEntityID());
@@ -1949,7 +2095,7 @@ namespace opensaml {
                     setAffiliationDescriptor(src.getAffiliationDescriptor()->cloneAffiliationDescriptor());
                 if (src.getOrganization())
                     setOrganization(src.getOrganization()->cloneOrganization());
-                
+
                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                     if (*i) {
                         IDPSSODescriptor* idp=dynamic_cast<IDPSSODescriptor*>(*i);
@@ -1957,7 +2103,7 @@ namespace opensaml {
                             getIDPSSODescriptors().push_back(idp->cloneIDPSSODescriptor());
                             continue;
                         }
-                        
+
                         SPSSODescriptor* sp=dynamic_cast<SPSSODescriptor*>(*i);
                         if (sp) {
                             getSPSSODescriptors().push_back(sp->cloneSPSSODescriptor());
@@ -1981,7 +2127,25 @@ namespace opensaml {
                             getPDPDescriptors().push_back(pdp->clonePDPDescriptor());
                             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());
@@ -2006,10 +2170,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(EntityDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -2019,7 +2179,7 @@ namespace opensaml {
             Signature* getSignature() const {
                 return m_Signature;
             }
-            
+
             void setSignature(Signature* sig) {
                 prepareForAssignment(m_Signature,sig);
                 *m_pos_Signature=m_Signature=sig;
@@ -2027,11 +2187,11 @@ namespace opensaml {
                 if (m_Signature)
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
-            
-            IMPL_STRING_ATTRIB(ID);
+
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(EntityID);
-            IMPL_DATETIME_ATTRIB(ValidUntil,LLONG_MAX);
-            IMPL_DATETIME_ATTRIB(CacheDuration,0);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DURATION_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(RoleDescriptor,m_pos_AffiliationDescriptor);
             IMPL_TYPED_CHILDREN(IDPSSODescriptor,m_pos_AffiliationDescriptor);
@@ -2039,12 +2199,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);
@@ -2063,55 +2226,31 @@ namespace opensaml {
                         return;
                     }
                 }
-                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+                AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
             }
 
-            const IDPSSODescriptor* getIDPSSODescriptor(const XMLCh* protocol) const {
-                for (vector<IDPSSODescriptor*>::const_iterator i=m_IDPSSODescriptors.begin(); i!=m_IDPSSODescriptors.end(); i++) {
-                    if ((*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
-            }
-            
-            const SPSSODescriptor* getSPSSODescriptor(const XMLCh* protocol) const {
-                for (vector<SPSSODescriptor*>::const_iterator i=m_SPSSODescriptors.begin(); i!=m_SPSSODescriptors.end(); i++) {
-                    if ((*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
-            }
-            
-            const AuthnAuthorityDescriptor* getAuthnAuthorityDescriptor(const XMLCh* protocol) const {
-                for (vector<AuthnAuthorityDescriptor*>::const_iterator i=m_AuthnAuthorityDescriptors.begin(); i!=m_AuthnAuthorityDescriptors.end(); i++) {
-                    if ((*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
-            }
-            
-            const AttributeAuthorityDescriptor* getAttributeAuthorityDescriptor(const XMLCh* protocol) const {
-                for (vector<AttributeAuthorityDescriptor*>::const_iterator i=m_AttributeAuthorityDescriptors.begin(); i!=m_AttributeAuthorityDescriptors.end(); i++) {
-                    if ((*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
-            }
-            
-            const PDPDescriptor* getPDPDescriptor(const XMLCh* protocol) const {
-                for (vector<PDPDescriptor*>::const_iterator i=m_PDPDescriptors.begin(); i!=m_PDPDescriptors.end(); i++) {
-                    if ((*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
-            }
-            
-            const RoleDescriptor* getRoleDescriptor(xmltooling::QName& qname, const XMLCh* protocol) const {
-                for (vector<RoleDescriptor*>::const_iterator i=m_RoleDescriptors.begin(); i!=m_RoleDescriptors.end(); i++) {
-                    if ((*i)->getSchemaType() && qname==(*((*i)->getSchemaType())) && (*i)->hasSupport(protocol) && (*i)->isValid())
-                        return (*i);
-                }
-                return NULL;
+            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:
@@ -2120,37 +2259,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);
             }
         };
 
@@ -2172,7 +2305,7 @@ namespace opensaml {
                 m_pos_Extensions=m_pos_Signature;
                 ++m_pos_Extensions;
             }
-            
+
         public:
             virtual ~EntitiesDescriptorImpl() {
                 XMLString::release(&m_ID);
@@ -2180,13 +2313,14 @@ namespace opensaml {
                 delete m_ValidUntil;
                 delete m_CacheDuration;
             }
-    
+
             EntitiesDescriptorImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
                 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
                 init();
             }
-                
-            EntitiesDescriptorImpl(const EntitiesDescriptorImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
+
+            EntitiesDescriptorImpl(const EntitiesDescriptorImpl& src)
+                    : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
                 init();
                 setID(src.getID());
                 setName(src.getName());
@@ -2196,7 +2330,7 @@ namespace opensaml {
                     setSignature(src.getSignature()->cloneSignature());
                 if (src.getExtensions())
                     setExtensions(src.getExtensions()->cloneExtensions());
-                
+
                 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
                     if (*i) {
                         EntityDescriptor* e=dynamic_cast<EntityDescriptor*>(*i);
@@ -2204,7 +2338,7 @@ namespace opensaml {
                             getEntityDescriptors().push_back(e->cloneEntityDescriptor());
                             continue;
                         }
-                        
+
                         EntitiesDescriptor* es=dynamic_cast<EntitiesDescriptor*>(*i);
                         if (es) {
                             getEntitiesDescriptors().push_back(es->cloneEntitiesDescriptor());
@@ -2216,10 +2350,6 @@ namespace opensaml {
 
             IMPL_XMLOBJECT_CLONE(EntitiesDescriptor);
 
-            const XMLCh* getId() const {
-                return getID();
-            }
-
             //IMPL_TYPED_CHILD(Signature);
             // Need customized setter.
         protected:
@@ -2229,7 +2359,7 @@ namespace opensaml {
             Signature* getSignature() const {
                 return m_Signature;
             }
-            
+
             void setSignature(Signature* sig) {
                 prepareForAssignment(m_Signature,sig);
                 *m_pos_Signature=m_Signature=sig;
@@ -2237,15 +2367,15 @@ namespace opensaml {
                 if (m_Signature)
                     m_Signature->setContentReference(new opensaml::ContentReference(*this));
             }
-            
-            IMPL_STRING_ATTRIB(ID);
+
+            IMPL_ID_ATTRIB(ID);
             IMPL_STRING_ATTRIB(Name);
-            IMPL_DATETIME_ATTRIB(ValidUntil,LLONG_MAX);
-            IMPL_DATETIME_ATTRIB(CacheDuration,0);
+            IMPL_DATETIME_ATTRIB(ValidUntil,SAMLTIME_MAX);
+            IMPL_DURATION_ATTRIB(CacheDuration,0);
             IMPL_TYPED_CHILD(Extensions);
             IMPL_TYPED_CHILDREN(EntityDescriptor,m_children.end());
             IMPL_TYPED_CHILDREN(EntitiesDescriptor,m_children.end());
-    
+
         protected:
             void marshallAttributes(DOMElement* domElement) const {
                 MARSHALL_ID_ATTRIB(ID,ID,NULL);
@@ -2255,10 +2385,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);
             }
 
@@ -2277,6 +2407,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);
@@ -2288,9 +2427,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);
@@ -2322,6 +2464,21 @@ IMPL_XMLOBJECTBUILDER(SPSSODescriptor);
 IMPL_XMLOBJECTBUILDER(SurName);
 IMPL_XMLOBJECTBUILDER(TelephoneNumber);
 
+IMPL_XMLOBJECTBUILDER(ActionNamespace);
+IMPL_XMLOBJECTBUILDER(SourceID);
+
+#ifdef HAVE_COVARIANT_RETURNS
+RoleDescriptor* RoleDescriptorBuilder::buildObject(
+#else
+xmltooling::XMLObject* RoleDescriptorBuilder::buildObject(
+#endif
+    const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType
+    ) const
+{
+    return new RoleDescriptorTypeImpl(nsURI,localName,prefix,schemaType);
+}
+
+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);
@@ -2340,10 +2497,16 @@ 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);
@@ -2400,6 +2563,9 @@ 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);
@@ -2411,6 +2577,7 @@ const XMLCh ServiceDescription::LOCAL_NAME[] =          UNICODE_LITERAL_18(S,e,r
 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);