Clean up catalogs, metadata endpoint mgmt template.
authorScott Cantor <cantor.2@osu.edu>
Tue, 2 Jan 2007 03:03:31 +0000 (03:03 +0000)
committerScott Cantor <cantor.2@osu.edu>
Tue, 2 Jan 2007 03:03:31 +0000 (03:03 +0000)
saml/Makefile.am
saml/saml.vcproj
saml/saml2/metadata/EndpointManager.h [new file with mode: 0644]
saml/util/SAMLConstants.cpp
saml/util/SAMLConstants.h
schemas/saml10-catalog.xml.in
schemas/saml11-catalog.xml.in
schemas/saml20-catalog.xml.in

index 8dcd88e..81322b2 100644 (file)
@@ -99,6 +99,7 @@ saml2bindinclude_HEADERS = \
 saml2mdinclude_HEADERS = \
        saml2/metadata/AbstractMetadataProvider.h \
        saml2/metadata/ChainingMetadataProvider.h \
+       saml2/metadata/EndpointManager.h \
        saml2/metadata/Metadata.h \
        saml2/metadata/MetadataFilter.h \
        saml2/metadata/MetadataKeyInfoIterator.h \
index 2d13c5a..864a6e2 100644 (file)
                                                >\r
                                        </File>\r
                                        <File\r
+                                               RelativePath=".\saml2\metadata\EndpointManager.h"\r
+                                               >\r
+                                       </File>\r
+                                       <File\r
                                                RelativePath=".\saml2\metadata\Metadata.h"\r
                                                >\r
                                        </File>\r
diff --git a/saml/saml2/metadata/EndpointManager.h b/saml/saml2/metadata/EndpointManager.h
new file mode 100644 (file)
index 0000000..d8b0b8b
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ *  Copyright 2001-2006 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file saml/saml2/metadata/EndpointManager.h
+ * 
+ * Templates for processing endpoint information.
+ */
+
+#ifndef __saml_epmgr_h__
+#define __saml_epmgr_h__
+
+#include <saml/base.h>
+
+namespace opensaml {
+    namespace saml2md {
+        
+        /**
+         * Template for processing unindexed endpoint information.
+         * 
+         * @param _Tx   the endpoint type being managed
+         */
+        template <class _Tx>
+        class EndpointManager
+        {
+        protected:
+            typename const std::vector<_Tx*>& m_endpoints;
+            
+        public:
+            /**
+             * Constructor.
+             *
+             * @param endpoints array of endpoints to manage
+             */
+            EndpointManager(typename const std::vector<_Tx*>& endpoints) : m_endpoints(endpoints) {
+            }
+            
+            /**
+             * Returns endpoint that supports a particular binding.
+             * 
+             * @param binding   binding to locate
+             * @return a supporting endpoint, favoring the default, or NULL
+             */
+            const _Tx* getByBinding(const XMLCh* binding) const {
+                for (std::vector<_Tx*>::const_iterator i = m_endpoints.begin(); i!=m_endpoints.end(); ++i) {
+                    if (xercesc::XMLString::equals(binding,(*i)->getBinding()))
+                        return *i;
+                }
+                return NULL;
+            }
+        };
+
+        /**
+         * Template for processing indexed endpoint information.
+         * 
+         * @param _Tx   the endpoint type being managed
+         */
+        template <class _Tx>
+        class IndexedEndpointManager : public EndpointManager<_Tx>
+        {
+            typename const _Tx* m_default;
+            
+        public:
+            /**
+             * Constructor.
+             *
+             * @param endpoints array of endpoints to manage
+             */
+            IndexedEndpointManager(typename const std::vector<_Tx*>& endpoints) : EndpointManager(endpoints), m_default(NULL) {
+            }
+            
+            /**
+             * Returns the default endpoint in the set.
+             * 
+             * @return the default endpoint 
+             */
+            const _Tx* getDefault() const {
+                if (m_default)
+                    return m_default;
+                for (std::vector<_Tx*>::const_iterator i = m_endpoints.begin(); i!=m_endpoints.end(); ++i) {
+                    if ((*i)->isDefault())
+                        return m_default=*i;
+                }
+                return (m_endpoints.empty()) ? m_default=NULL : m_default=m_endpoints.front();
+            }
+            
+            /**
+             * Returns indexed endpoint.
+             * 
+             * @param index index to locate
+             * @return matching endpoint, or NULL
+             */
+            const _Tx* getByIndex(unsigned short index) const {
+                for (std::vector<_Tx*>::const_iterator i = m_endpoints.begin(); i!=m_endpoints.end(); ++i) {
+                    std::pair<bool,int> comp = (*i)->getIndex();
+                    if (comp.first && index == comp.second)
+                        return *i;
+                }
+                return NULL;
+            }
+            
+            /**
+             * Returns endpoint that supports a particular binding.
+             * 
+             * @param binding   binding to locate
+             * @return a supporting endpoint, favoring the default, or NULL
+             */
+            const _Tx* getByBinding(const XMLCh* binding) const {
+                if (getDefault() && xercesc::XMLString::equals(binding,m_default->getBinding()))
+                    return m_default;
+                return EndpointManager::getByBinding(binding);
+            }
+        };
+    };
+};
+
+#endif /* __saml_epmgr_h__ */
index 1069ea4..304b048 100644 (file)
@@ -149,6 +149,13 @@ const XMLCh samlconstants::SAML1MD_NS[] = // urn:oasis:names:tc:SAML:profiles:v1
 const XMLCh samlconstants::SAML1MD_PREFIX[] =
 { chLatin_s, chLatin_a, chLatin_m, chLatin_l, chDigit_1, chLatin_m, chLatin_d, chNull };
 
+const XMLCh samlconstants::SAML10_PROTOCOL_ENUM[] = // urn:oasis:names:tc:SAML:1.0:protocol
+{ 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_1, chPeriod, chDigit_0, chColon,
+  chLatin_p, chLatin_r, chLatin_o, chLatin_t, chLatin_o, chLatin_c, chLatin_o, chLatin_l, chNull
+};
+
 const XMLCh samlconstants::SAML11_PROTOCOL_ENUM[] = // urn:oasis:names:tc:SAML:1.1:protocol
 { 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,
index 8f9a9c5..40953bf 100644 (file)
@@ -105,10 +105,8 @@ namespace samlconstants {
     /** SAML 1.x Metadata Profile QName prefix ("saml1md") */
     extern SAML_API const XMLCh SAML1MD_PREFIX[];
 
-#ifndef SAML10_PROTOCOL_ENUM
     /** SAML 1.0 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.0:protocol") */
-    #define SAML10_PROTOCOL_ENUM samlconstants::SAML1P_NS
-#endif
+    extern SAML_API const XMLCh SAML10_PROTOCOL_ENUM[];
     
     /** SAML 1.1 Protocol Enumeration constant ("urn:oasis:names:tc:SAML:1.1:protocol") */
     extern SAML_API const XMLCh SAML11_PROTOCOL_ENUM[];
index e861335..24c8b71 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
 <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <uri name="http://schemas.xmlsoap.org/soap/envelope/" uri="@-PKGXMLDIR-@/soap-envelope.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:1.0:assertion" uri="@-PKGXMLDIR-@/cs-sstc-schema-assertion-01.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:1.0:protocol" uri="@-PKGXMLDIR-@/cs-sstc-schema-protocol-01.xsd"/>
 </catalog>
index 5f484d9..090084a 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
 <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <uri name="http://schemas.xmlsoap.org/soap/envelope/" uri="@-PKGXMLDIR-@/soap-envelope.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:1.0:assertion" uri="@-PKGXMLDIR-@/cs-sstc-schema-assertion-1.1.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:1.0:protocol" uri="@-PKGXMLDIR-@/cs-sstc-schema-protocol-1.1.xsd"/>
 </catalog>
index 9fb17d7..fa4fcf5 100644 (file)
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
 <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
-    <uri name="http://schemas.xmlsoap.org/soap/envelope/" uri="@-PKGXMLDIR-@/soap-envelope.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:2.0:assertion" uri="@-PKGXMLDIR-@/saml-schema-assertion-2.0.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:2.0:protocol" uri="@-PKGXMLDIR-@/saml-schema-protocol-2.0.xsd"/>
     <uri name="urn:oasis:names:tc:SAML:2.0:metadata" uri="@-PKGXMLDIR-@/saml-schema-metadata-2.0.xsd"/>