boost changes and header fixes
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / impl / EntityRoleMetadataFilter.cpp
index 3497706..1017788 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2009-2010 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * 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
+ * UCAID licenses this file to you 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
+ * 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.
+ * 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.
  */
 
 /**
 #include "saml2/metadata/Metadata.h"
 #include "saml2/metadata/MetadataFilter.h"
 
+#include <boost/ptr_container/ptr_set.hpp>
 #include <xmltooling/logging.h>
 #include <xmltooling/util/NDC.h>
 
 using namespace opensaml::saml2md;
 using namespace xmltooling::logging;
 using namespace xmltooling;
+using namespace boost;
 using namespace std;
 
 namespace opensaml {
@@ -49,7 +55,7 @@ namespace opensaml {
             void doFilter(EntitiesDescriptor& entities) const;
 
             bool m_removeRolelessEntityDescriptors, m_removeEmptyEntitiesDescriptors;
-            set<xmltooling::QName> m_roles;
+            ptr_set<xmltooling::QName> m_roles;
             bool m_idp, m_sp, m_authn, m_attr, m_pdp, m_authnq, m_attrq, m_authzq;
         };
 
@@ -91,7 +97,7 @@ EntityRoleMetadataFilter::EntityRoleMetadataFilter(const DOMElement* e)
             else if (*q == AuthzDecisionQueryDescriptorType::TYPE_QNAME)
                 m_authzq = true;
             else
-                m_roles.insert(*q.get());
+                m_roles.insert(q);
         }
         e = XMLHelper::getNextSiblingElement(e, RetainedRole);
     }
@@ -107,14 +113,14 @@ void EntityRoleMetadataFilter::doFilter(XMLObject& xmlObject) const
         doFilter(dynamic_cast<EntitiesDescriptor&>(xmlObject));
         return;
     }
-    catch (bad_cast) {
+    catch (bad_cast&) {
     }
 
     try {
         doFilter(dynamic_cast<EntityDescriptor&>(xmlObject));
         return;
     }
-    catch (bad_cast) {
+    catch (bad_cast&) {
     }
 
     throw MetadataFilterException("EntityRoleWhiteList MetadataFilter was given an improper metadata instance to filter.");
@@ -124,8 +130,8 @@ void EntityRoleMetadataFilter::doFilter(EntitiesDescriptor& entities) const
 {
     Category& log=Category::getInstance(SAML_LOGCAT".MetadataFilter.EntityRoleWhiteList");
 
-    VectorOf(EntityDescriptor) v=entities.getEntityDescriptors();
-    for (VectorOf(EntityDescriptor)::size_type i=0; i<v.size(); ) {
+    VectorOf(EntityDescriptor) v = entities.getEntityDescriptors();
+    for (VectorOf(EntityDescriptor)::size_type i = 0; i < v.size(); ) {
         doFilter(*v[i]);
         if (m_removeRolelessEntityDescriptors) {
             const EntityDescriptor& e = const_cast<const EntityDescriptor&>(*v[i]);
@@ -147,8 +153,8 @@ void EntityRoleMetadataFilter::doFilter(EntitiesDescriptor& entities) const
         i++;
     }
 
-    VectorOf(EntitiesDescriptor) groups=entities.getEntitiesDescriptors();
-    for (VectorOf(EntitiesDescriptor)::size_type j=0; j<groups.size(); ) {
+    VectorOf(EntitiesDescriptor) groups = entities.getEntitiesDescriptors();
+    for (VectorOf(EntitiesDescriptor)::size_type j = 0; j < groups.size(); ) {
         EntitiesDescriptor* group = groups[j];
         doFilter(*group);
         if (m_removeEmptyEntitiesDescriptors && group->getEntitiesDescriptors().empty() && group->getEntityDescriptors().empty()) {
@@ -187,7 +193,7 @@ void EntityRoleMetadataFilter::doFilter(EntityDescriptor& entity) const
         entity.getAuthzDecisionQueryDescriptorTypes().clear();
 
     VectorOf(RoleDescriptor) v = entity.getRoleDescriptors();
-    for (VectorOf(RoleDescriptor)::size_type i=0; i<v.size(); ) {
+    for (VectorOf(RoleDescriptor)::size_type i = 0; i < v.size(); ) {
         const xmltooling::QName* type = v[i]->getSchemaType();
         if (!type || m_roles.find(*type) != m_roles.end())
             v.erase(v.begin() + i);