Move scoped attribute subclass, add TargetedID plugin.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 1 May 2005 03:31:29 +0000 (03:31 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Sun, 1 May 2005 03:31:29 +0000 (03:31 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@1575 cb58f699-b61c-0410-a6fe-9272a202ed29

xmlproviders/Makefile.am
xmlproviders/ScopedAttribute.cpp [deleted file]
xmlproviders/TargetedID.cpp [new file with mode: 0644]
xmlproviders/XMLProviders.cpp
xmlproviders/internal.h
xmlproviders/xmlproviders.dsp

index 2ee471d..1b5ff77 100644 (file)
@@ -12,7 +12,7 @@ xmlproviders_la_LIBADD = \
 
 xmlproviders_la_SOURCES = \
        CredResolvers.cpp \
-       ScopedAttribute.cpp \
+       TargetedID.cpp \
        XML.cpp \
        XMLAAP.cpp \
        XMLCredentials.cpp \
diff --git a/xmlproviders/ScopedAttribute.cpp b/xmlproviders/ScopedAttribute.cpp
deleted file mode 100644 (file)
index 8546ffc..0000000
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * The Shibboleth License, Version 1.
- * Copyright (c) 2002
- * University Corporation for Advanced Internet Development, Inc.
- * All rights reserved
- *
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution, if any, must include
- * the following acknowledgment: "This product includes software developed by
- * the University Corporation for Advanced Internet Development
- * <http://www.ucaid.edu>Internet2 Project. Alternately, this acknowledegement
- * may appear in the software itself, if and wherever such third-party
- * acknowledgments normally appear.
- *
- * Neither the name of Shibboleth nor the names of its contributors, nor
- * Internet2, nor the University Corporation for Advanced Internet Development,
- * Inc., nor UCAID may be used to endorse or promote products derived from this
- * software without specific prior written permission. For written permission,
- * please contact shibboleth@shibboleth.org
- *
- * Products derived from this software may not be called Shibboleth, Internet2,
- * UCAID, or the University Corporation for Advanced Internet Development, nor
- * may Shibboleth appear in their name, without prior written permission of the
- * University Corporation for Advanced Internet Development.
- *
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK
- * OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE.
- * IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY
- * CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-/* ScopedAttribute.cpp - eduPerson scoped attribute base class
-
-   Scott Cantor
-   6/4/02
-
-   $History:$
-*/
-
-#include "internal.h"
-#include <xercesc/util/regx/RegularExpression.hpp>
-#include <log4cpp/Category.hh>
-
-using namespace shibboleth;
-using namespace saml;
-using namespace log4cpp;
-using namespace std;
-
-void ScopedAttribute::valueToDOM(unsigned int index, DOMElement* e) const
-{
-    SAMLAttribute::valueToDOM(index,e);
-    e->setAttributeNS(NULL,SHIB_L(Scope),m_scopes[index]);
-}
-
-ScopedAttribute::ScopedAttribute(const XMLCh* name, const XMLCh* ns, const saml::QName* type, long lifetime,
-                                 const saml::Iterator<const XMLCh*>& scopes,
-                                 const saml::Iterator<const XMLCh*>& values)
-    : SAMLAttribute(name,ns,type,lifetime,values)
-{
-    if (scopes.size()!=values.size())
-        throw MalformedException(SAMLException::RESPONDER,"ScopedAttribute() requires the number of scopes to equal the number of values");
-
-    while (scopes.hasNext())
-        m_scopes.push_back(XMLString::replicate(scopes.next()));
-}
-
-ScopedAttribute::ScopedAttribute(DOMElement* e) : SAMLAttribute(e)
-{
-    // Default scope comes from subject.
-    DOMNodeList* nlist=
-        static_cast<DOMElement*>(e->getParentNode())->getElementsByTagNameNS(saml::XML::SAML_NS,L(NameIdentifier));
-    if (!nlist || nlist->getLength() != 1)
-        throw MalformedException(SAMLException::RESPONDER,"ScopedAttribute() can't find saml:NameIdentifier in enclosing statement");
-    m_originSite=static_cast<DOMElement*>(nlist->item(0))->getAttributeNS(NULL,L(NameQualifier));
-
-    e=saml::XML::getFirstChildElement(e,saml::XML::SAML_NS,L(AttributeValue));
-    while (e)
-    {
-        DOMAttr* scope=e->getAttributeNodeNS(NULL,SHIB_L(Scope));
-        m_scopes.push_back(scope ? scope->getNodeValue() : &chNull);
-        e=saml::XML::getNextSiblingElement(e,saml::XML::SAML_NS,L(AttributeValue));
-    }
-}
-
-ScopedAttribute::~ScopedAttribute()
-{
-    if (m_bOwnStrings)
-    {
-        for (vector<const XMLCh*>::iterator i=m_scopes.begin(); i!=m_scopes.end(); i++)
-        {
-            XMLCh* p = const_cast<XMLCh*>(*i);
-            XMLString::release(&p);
-        }
-    }
-
-    // We always own any scoped values we've built.
-    for (vector<const XMLCh*>::iterator i=m_scopedValues.begin(); i!=m_scopedValues.end(); i++)
-    {
-        XMLCh* p = const_cast<XMLCh*>(*i);
-        XMLString::release(&p);
-    }
-}
-
-Iterator<const XMLCh*> ScopedAttribute::getValues() const
-{
-    static XMLCh at[]={chAt, chNull};
-
-    if (m_scopedValues.empty())
-    {
-        vector<const XMLCh*>::const_iterator j=m_scopes.begin();
-        for (vector<const XMLCh*>::const_iterator i=m_values.begin(); i!=m_values.end(); i++, j++)
-        {
-            const XMLCh* scope=((*j) ? (*j) : m_originSite);
-            XMLCh* temp=new XMLCh[XMLString::stringLen(*i) + XMLString::stringLen(scope) + 2];
-            temp[0]=chNull;
-            XMLString::catString(temp,*i);
-            XMLString::catString(temp,at);
-            XMLString::catString(temp,scope);
-            m_scopedValues.push_back(temp);
-        }
-    }
-    return m_scopedValues;
-}
-
-Iterator<string> ScopedAttribute::getSingleByteValues() const
-{
-    getValues();
-    if (m_sbValues.empty())
-    {
-        for (vector<const XMLCh*>::const_iterator i=m_scopedValues.begin(); i!=m_scopedValues.end(); i++)
-        {
-            auto_ptr<char> temp(toUTF8(*i));
-            if (temp.get())
-                m_sbValues.push_back(temp.get());
-        }
-    }
-    return Iterator<string>(m_sbValues);
-}
-
-void ScopedAttribute::setValues(const Iterator<const XMLCh*>& values)
-{
-    throw SAMLException("unsupported operation");
-}
-
-void ScopedAttribute::addValue(const XMLCh* value)
-{
-    throw SAMLException("unsupported operation");
-}
-
-void ScopedAttribute::removeValue(unsigned int index)
-{
-    SAMLAttribute::removeValue(index);
-    
-    if (m_bOwnStrings) {
-        XMLCh* p=const_cast<XMLCh*>(m_scopes[index]);
-        XMLString::release(&p);
-    }
-    m_scopes.erase(m_scopes.begin()+index);
-}
-
-SAMLObject* ScopedAttribute::clone() const
-{
-    return new ScopedAttribute(m_name,m_namespace,m_type,m_lifetime,m_scopes,m_values);
-}
diff --git a/xmlproviders/TargetedID.cpp b/xmlproviders/TargetedID.cpp
new file mode 100644 (file)
index 0000000..bb730ab
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+ * The Shibboleth License, Version 1.
+ * Copyright (c) 2002
+ * University Corporation for Advanced Internet Development, Inc.
+ * All rights reserved
+ *
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution, if any, must include
+ * the following acknowledgment: "This product includes software developed by
+ * the University Corporation for Advanced Internet Development
+ * <http://www.ucaid.edu>Internet2 Project. Alternately, this acknowledegement
+ * may appear in the software itself, if and wherever such third-party
+ * acknowledgments normally appear.
+ *
+ * Neither the name of Shibboleth nor the names of its contributors, nor
+ * Internet2, nor the University Corporation for Advanced Internet Development,
+ * Inc., nor UCAID may be used to endorse or promote products derived from this
+ * software without specific prior written permission. For written permission,
+ * please contact shibboleth@shibboleth.org
+ *
+ * Products derived from this software may not be called Shibboleth, Internet2,
+ * UCAID, or the University Corporation for Advanced Internet Development, nor
+ * may Shibboleth appear in their name, without prior written permission of the
+ * University Corporation for Advanced Internet Development.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND WITH ALL FAULTS. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, AND NON-INFRINGEMENT ARE DISCLAIMED AND THE ENTIRE RISK
+ * OF SATISFACTORY QUALITY, PERFORMANCE, ACCURACY, AND EFFORT IS WITH LICENSEE.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER, CONTRIBUTORS OR THE UNIVERSITY
+ * CORPORATION FOR ADVANCED INTERNET DEVELOPMENT, INC. BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/* TargetedID.cpp - eduPersonTargetedID custom attribute handling
+
+   Scott Cantor
+   4/30/05
+
+   $History:$
+*/
+
+#include "internal.h"
+#include <xercesc/util/Base64.hpp>
+
+using namespace shibboleth;
+using namespace saml;
+using namespace std;
+
+namespace {
+    class TargetedID : public SAMLAttribute
+    {
+    public:
+        TargetedID(
+            const XMLCh* name=NULL,
+            const XMLCh* ns=NULL,
+            const saml::QName* type=NULL,
+            long lifetime=0,
+            const Iterator<const XMLCh*>& values=EMPTY(const XMLCh*),
+            const Iterator<const XMLCh*>& nameQualifiers=EMPTY(const XMLCh*),
+            const Iterator<const XMLCh*>& spNameQualifiers=EMPTY(const XMLCh*)
+            );
+        TargetedID(DOMElement* e);
+        TargetedID(istream& in);
+        ~TargetedID();
+    
+        saml::SAMLObject* clone() const;
+        
+        saml::Iterator<const XMLCh*> getValues() const;
+        saml::Iterator<std::string> getSingleByteValues() const;
+
+        void setValues(const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*)) {
+            throw SAMLException("unsupported operation");
+        }
+        void addValue(const XMLCh* value) {
+            throw SAMLException("unsupported operation");
+        }
+        void removeValue(unsigned int index);
+        
+        static const XMLCh NameID[];
+        static const XMLCh SPNameQualifier[];
+        static const XMLCh FORMAT_PERSISTENT[];
+    protected:
+        void valueToDOM(unsigned int index, DOMElement* e) const;
+        void valueFromDOM(DOMElement* e);
+        void ownStrings();
+    
+    private:
+        vector<const XMLCh*> m_nameQualifiers;
+        vector<const XMLCh*> m_spNameQualifiers;
+        mutable vector<const XMLCh*> m_encodedValues;
+    };
+
+    struct TargetedIDBuilder : public virtual IAttributeFactory
+    {
+        TargetedIDBuilder(const DOMElement* e) {}
+        SAMLAttribute* build(DOMElement* e) const {
+            return new TargetedID(e);
+        }
+    };
+}
+
+IPlugIn* TargetedIDFactory(const DOMElement* e)
+{
+    return new TargetedIDBuilder(e);
+}
+
+TargetedID::TargetedID(
+    const XMLCh* name,
+    const XMLCh* ns,
+    const saml::QName* type,
+    long lifetime,
+    const Iterator<const XMLCh*>& values,
+    const Iterator<const XMLCh*>& nameQualifiers,
+    const Iterator<const XMLCh*>& spNameQualifiers
+    ) : SAMLAttribute(name,ns,NULL,lifetime,values)
+{
+    RTTI(TargetedID);
+    if (values.size()!=nameQualifiers.size() || values.size()!=spNameQualifiers.size())
+        throw MalformedException("TargetedID() requires the number of qualifiers to equal the number of values");
+
+    while (nameQualifiers.hasNext())
+        m_nameQualifiers.push_back(saml::XML::assign(nameQualifiers.next()));
+    while (spNameQualifiers.hasNext())
+        m_spNameQualifiers.push_back(saml::XML::assign(spNameQualifiers.next()));
+}
+
+TargetedID::TargetedID(DOMElement* e) : SAMLAttribute(e,false)
+{
+    RTTI(TargetedID);
+    fromDOM(e);
+}
+
+TargetedID::TargetedID(istream& in) : SAMLAttribute(in,false)
+{
+    RTTI(TargetedID);
+    fromDOM(m_document->getDocumentElement());
+}
+
+TargetedID::~TargetedID()
+{
+    if (m_bOwnStrings) {
+        for (vector<const XMLCh*>::iterator i=m_nameQualifiers.begin(); i!=m_nameQualifiers.end(); i++) {
+            XMLCh* p = const_cast<XMLCh*>(*i);
+            XMLString::release(&p);
+        }
+        for (vector<const XMLCh*>::iterator j=m_spNameQualifiers.begin(); j!=m_spNameQualifiers.end(); j++) {
+            XMLCh* p = const_cast<XMLCh*>(*j);
+            XMLString::release(&p);
+        }
+    }
+
+    // We always own any encoded values we've built.
+    for (vector<const XMLCh*>::iterator i=m_encodedValues.begin(); i!=m_encodedValues.end(); i++) {
+        XMLCh* p = const_cast<XMLCh*>(*i);
+        XMLString::release(&p);
+    }
+}
+
+void TargetedID::ownStrings()
+{
+    if (!m_bOwnStrings) {
+        for (vector<const XMLCh*>::iterator i=m_nameQualifiers.begin(); i!=m_nameQualifiers.end(); i++)
+            (*i)=saml::XML::assign(*i);
+        for (vector<const XMLCh*>::iterator j=m_spNameQualifiers.begin(); j!=m_spNameQualifiers.end(); j++)
+            (*j)=saml::XML::assign(*j);
+        SAMLAttribute::ownStrings();
+    }
+}
+
+Iterator<const XMLCh*> TargetedID::getValues() const
+{
+    if (m_encodedValues.empty()) {
+        getSingleByteValues();
+        for (vector<string>::const_iterator i=m_sbValues.begin(); i!=m_sbValues.end(); i++)
+            m_encodedValues.push_back(XMLString::transcode(i->c_str()));
+    }
+    return m_encodedValues;
+}
+
+Iterator<string> TargetedID::getSingleByteValues() const
+{
+    if (m_sbValues.empty()) {
+        for (unsigned long i=0; i<m_values.size(); i++) {
+            auto_ptr_char a(m_nameQualifiers[i]);
+            auto_ptr_char b(m_spNameQualifiers[i]);
+            auto_ptr_char c(m_values[i]);
+            if (a.get() && *(a.get()) && b.get() && *(b.get()) && c.get() && *(c.get())) {
+                string cat(a.get()); cat+="!!"; cat+=b.get(); cat+="!!"; cat+=c.get();
+                unsigned int outlen;
+                XMLByte* encoded = Base64::encode(reinterpret_cast<XMLByte*>((char*)cat.c_str()), cat.length(), &outlen);
+                XMLByte *pos, *pos2;
+                for (pos=encoded, pos2=encoded; *pos2; pos2++)
+                    if (isgraph(*pos2))
+                        *pos++=*pos2;
+                *pos=0;
+                m_sbValues.push_back(reinterpret_cast<char*>(encoded));
+                XMLString::release(&encoded);
+            }
+            else
+                m_sbValues.push_back("");
+        }
+    }
+    return m_sbValues;
+}
+
+void TargetedID::removeValue(unsigned int index)
+{
+    if (m_bOwnStrings) {
+        XMLCh* p=const_cast<XMLCh*>(m_nameQualifiers[index]);
+        XMLString::release(&p);
+        p=const_cast<XMLCh*>(m_spNameQualifiers[index]);
+        XMLString::release(&p);
+    }
+    m_nameQualifiers.erase(m_nameQualifiers.begin()+index);
+    m_spNameQualifiers.erase(m_spNameQualifiers.begin()+index);
+
+    if (!m_encodedValues.empty()) {
+        XMLCh* p=const_cast<XMLCh*>(m_encodedValues[index]);
+        XMLString::release(&p);
+        m_encodedValues.erase(m_encodedValues.begin()+index);
+    }
+    
+    SAMLAttribute::removeValue(index);
+}
+
+void TargetedID::valueFromDOM(DOMElement* e)
+{
+    // Look for a SAML2 NameID.
+    e=saml::XML::getFirstChildElement(e,::XML::SAML2ASSERT_NS,NameID);
+    if (e && !XMLString::compareString(FORMAT_PERSISTENT,e->getAttributeNS(NULL,L(Format)))) {
+        m_nameQualifiers.push_back(e->getAttributeNS(NULL,L(NameQualifier)));
+        m_spNameQualifiers.push_back(e->getAttributeNS(NULL,SPNameQualifier));
+        if (e->hasChildNodes() && e->getFirstChild()->getNodeType()==DOMNode::TEXT_NODE)
+            m_values.push_back(e->getFirstChild()->getNodeValue());
+        else
+            m_values.push_back(&chNull);
+        return;
+    }
+
+    // Insert a null value placeholder.
+    m_nameQualifiers.push_back(&chNull);    
+    m_spNameQualifiers.push_back(&chNull);    
+    m_values.push_back(&chNull);
+}
+
+void TargetedID::valueToDOM(unsigned int index, DOMElement* e) const
+{
+    const XMLCh* nq=m_nameQualifiers[index];
+    const XMLCh* spnq=m_spNameQualifiers[index];
+    const XMLCh* val=m_values[index];
+    if (!saml::XML::isEmpty(nq) && !saml::XML::isEmpty(spnq) && !saml::XML::isEmpty(val)) {
+        // Build a SAML2 NameID.
+        DOMElement* nameid=e->getOwnerDocument()->createElementNS(::XML::SAML2ASSERT_NS,NameID);
+        nameid->setAttributeNS(NULL,L(Format),FORMAT_PERSISTENT);    
+        nameid->setAttributeNS(NULL,L(NameQualifier),nq);
+        nameid->setAttributeNS(NULL,SPNameQualifier,spnq);
+        nameid->appendChild(e->getOwnerDocument()->createTextNode(val));
+        e->appendChild(nameid);
+    }
+}
+
+SAMLObject* TargetedID::clone() const
+{
+    return new TargetedID(m_name,m_namespace,m_type,m_lifetime,m_values,m_nameQualifiers,m_spNameQualifiers);
+}
+
+const XMLCh TargetedID::NameID[] =
+{ chLatin_N, chLatin_a, chLatin_m, chLatin_e, chLatin_I, chLatin_D, chNull };
+
+const XMLCh TargetedID::SPNameQualifier[] =
+{ chLatin_S, chLatin_P, chLatin_N, chLatin_a, chLatin_m, chLatin_e,
+  chLatin_Q, chLatin_u, chLatin_a, chLatin_l, chLatin_i, chLatin_f, chLatin_i, chLatin_e, chLatin_r, chNull
+};
+
+const XMLCh TargetedID::FORMAT_PERSISTENT[] =
+{
+    chLatin_u, chLatin_r, chLatin_n, chColon, chLatin_o, chLatin_a, chLatin_s, chLatin_i, chLatin_s, chColon,
+    chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_s, chColon, chLatin_t, chLatin_c, chColon,
+    chLatin_S, chLatin_A, chLatin_M, chLatin_L, chColon, chDigit_2, chPeriod, chDigit_0, chColon,
+    chLatin_n, chLatin_a, chLatin_m, chLatin_e, chLatin_i, chLatin_d, chDash,
+    chLatin_f, chLatin_o, chLatin_r, chLatin_m, chLatin_a, chLatin_t, chColon,
+    chLatin_p, chLatin_e, chLatin_r, chLatin_s, chLatin_i, chLatin_s, chLatin_t, chLatin_e, chLatin_n, chLatin_t, chNull
+};
index f8e79b3..45159c8 100644 (file)
 using namespace saml;
 using namespace shibboleth;
 using namespace log4cpp;
+using namespace std;
 
 // Metadata Factories
 
+PlugManager::Factory TargetedIDFactory;
 PlugManager::Factory XMLMetadataFactory;
 PlugManager::Factory XMLTrustFactory;
 PlugManager::Factory XMLCredentialsFactory;
 PlugManager::Factory XMLAAPFactory;
 PlugManager::Factory FileCredResolverFactory;
 
+extern "C" int XML_EXPORTS saml_extension_init(void*)
+{
+    // Register extension schemas.
+    saml::XML::registerSchema(::XML::SHIB_NS,::XML::SHIB_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::SHIBMETA_NS,::XML::SHIBMETA_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::TRUST_NS,::XML::TRUST_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::CREDS_NS,::XML::CREDS_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::SAML2META_NS,::XML::SAML2META_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::SAML2ASSERT_NS,::XML::SAML2ASSERT_SCHEMA_ID);
+    saml::XML::registerSchema(::XML::XMLENC_NS,::XML::XMLENC_SCHEMA_ID);
+
+    // Register metadata factories (some are legacy aliases)
+    SAMLConfig& conf=SAMLConfig::getConfig();
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.provider.TargetedIDFactory",&TargetedIDFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata",&XMLMetadataFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata",&XMLMetadataFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.trust.provider.XMLTrust",&XMLTrustFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust",&XMLTrustFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.Credentials",&XMLCredentialsFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.Credentials.FileCredentialResolver",&FileCredResolverFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.aap.provider.XMLAAP",&XMLAAPFactory);
+    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.target.provider.XMLAAP",&XMLAAPFactory);
+
+    return 0;
+}
 
-extern "C" SAMLAttribute* ShibAttributeFactory(DOMElement* e)
+extern "C" void XML_EXPORTS saml_extension_term()
 {
-    DOMNode* n=e->getFirstChild();
-    while (n && n->getNodeType()!=DOMNode::ELEMENT_NODE)
-        n=n->getNextSibling();
-    if (n && static_cast<DOMElement*>(n)->hasAttributeNS(NULL,SHIB_L(Scope)))
-        return new ScopedAttribute(e);
-    return new SAMLAttribute(e);
+    // Unregister metadata factories
+    SAMLConfig& conf=SAMLConfig::getConfig();
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.provider.TargetedIDFactory");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.trust.provider.XMLTrust");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.Credentials");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.Credentials.FileCredentialResolver");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.aap.provider.XMLAAP");
+    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.target.provider.XMLAAP");
 }
 
 void log_openssl()
@@ -130,46 +162,3 @@ X509_CRL* B64_to_CRL(const char* buf)
     BIO_free_all(b64);
     return x;
 }
-
-extern "C" int XML_EXPORTS saml_extension_init(void*)
-{
-    // Register extension schemas.
-    saml::XML::registerSchema(::XML::SHIB_NS,::XML::SHIB_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::SHIBMETA_NS,::XML::SHIBMETA_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::TRUST_NS,::XML::TRUST_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::CREDS_NS,::XML::CREDS_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::SAML2META_NS,::XML::SAML2META_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::SAML2ASSERT_NS,::XML::SAML2ASSERT_SCHEMA_ID);
-    saml::XML::registerSchema(::XML::XMLENC_NS,::XML::XMLENC_SCHEMA_ID);
-
-    // Register metadata factories (some are legacy aliases)
-    SAMLConfig& conf=SAMLConfig::getConfig();
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata",&XMLMetadataFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata",&XMLMetadataFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.trust.provider.XMLTrust",&XMLTrustFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust",&XMLTrustFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.Credentials",&XMLCredentialsFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.common.Credentials.FileCredentialResolver",&FileCredResolverFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.aap.provider.XMLAAP",&XMLAAPFactory);
-    conf.getPlugMgr().regFactory("edu.internet2.middleware.shibboleth.target.provider.XMLAAP",&XMLAAPFactory);
-
-    SAMLAttribute::setFactory(&ShibAttributeFactory);
-
-    return 0;
-}
-
-extern "C" void XML_EXPORTS saml_extension_term()
-{
-    // Unregister metadata factories
-    SAMLConfig& conf=SAMLConfig::getConfig();
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.metadata.provider.XMLMetadata");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLMetadata");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.trust.provider.XMLTrust");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.provider.XMLTrust");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.Credentials");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.common.Credentials.FileCredentialResolver");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.aap.provider.XMLAAP");
-    conf.getPlugMgr().unregFactory("edu.internet2.middleware.shibboleth.target.provider.XMLAAP");
-
-    SAMLAttribute::setFactory(NULL);
-}
index ccabe8e..7503584 100644 (file)
@@ -76,31 +76,6 @@ void log_openssl();
 X509_CRL* B64_to_CRL(const char* buf);
 X509* B64_to_X509(const char* buf);
    
-class ScopedAttribute : public saml::SAMLAttribute
-{
-public:
-    ScopedAttribute(const XMLCh* name, const XMLCh* ns, const saml::QName* type=NULL, long lifetime=0,
-                    const saml::Iterator<const XMLCh*>& scopes=EMPTY(const XMLCh*),
-                    const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*));
-    ScopedAttribute(DOMElement* e);
-    virtual ~ScopedAttribute();
-
-    virtual saml::SAMLObject* clone() const;
-    
-    virtual saml::Iterator<const XMLCh*> getValues() const;
-    virtual saml::Iterator<std::string> getSingleByteValues() const;
-    virtual void setValues(const saml::Iterator<const XMLCh*>& values=EMPTY(const XMLCh*));
-    virtual void addValue(const XMLCh* value);
-    virtual void removeValue(unsigned int index);
-    
-protected:
-    virtual void valueToDOM(unsigned int index, DOMElement* e) const;
-    
-    const XMLCh* m_originSite;
-    std::vector<const XMLCh*> m_scopes;
-    mutable std::vector<const XMLCh*> m_scopedValues;
-};
-    
 class XML
 {
 public:
index b50c91d..2677001 100644 (file)
@@ -101,7 +101,7 @@ SOURCE=.\resource.h
 # End Source File
 # Begin Source File
 
-SOURCE=.\ScopedAttribute.cpp
+SOURCE=.\TargetedID.cpp
 # End Source File
 # Begin Source File