2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file saml/saml2/metadata/MetadataFilter.h
24 * Processes metadata after it's been unmarshalled.
27 #include <saml/saml2/metadata/MetadataProvider.h>
29 #ifndef __saml2_metadatafilt_h__
30 #define __saml2_metadatafilt_h__
36 * Marker interface for supplying environmental context to filters.
38 class SAML_API MetadataFilterContext
40 MAKE_NONCOPYABLE(MetadataFilterContext);
42 MetadataFilterContext();
44 virtual ~MetadataFilterContext();
48 * A metadata filter is used to process metadata after resolution and unmarshalling.
50 * Some filters might remove everything but identity provider roles, decreasing the data a service provider
51 * needs to work with, or a filter could be used to perform integrity checking on the retrieved metadata by
52 * verifying a digital signature.
54 class SAML_API MetadataFilter
56 MAKE_NONCOPYABLE(MetadataFilter);
60 virtual ~MetadataFilter();
63 * Returns an identifying string for the filter.
65 * @return the ID string
67 virtual const char* getId() const=0;
71 * Filters the given metadata. Exceptions should generally not be thrown to
72 * signal the removal of information, only for systemic processing failure.
74 * @param xmlObject the metadata to be filtered
76 virtual void doFilter(xmltooling::XMLObject& xmlObject) const;
79 * Filters the given metadata. Exceptions should generally not be thrown to
80 * signal the removal of information, only for systemic processing failure.
82 * @param ctx context interface, or nullptr
83 * @param xmlObject the metadata to be filtered
85 virtual void doFilter(MetadataFilterContext* ctx, xmltooling::XMLObject& xmlObject) const;
89 * Registers MetadataFilter classes into the runtime.
91 void SAML_API registerMetadataFilters();
93 /** MetadataFilter that deletes blacklisted entities. */
94 #define BLACKLIST_METADATA_FILTER "Blacklist"
96 /** MetadataFilter that deletes all but whitelisted entities. */
97 #define WHITELIST_METADATA_FILTER "Whitelist"
99 /** MetadataFilter that verifies signatures and filters out any that don't pass. */
100 #define SIGNATURE_METADATA_FILTER "Signature"
102 /** MetadataFilter that enforces expiration requirements. */
103 #define REQUIREVALIDUNTIL_METADATA_FILTER "RequireValidUntil"
105 /** MetadataFilter that removes non-retained roles. */
106 #define ENTITYROLE_METADATA_FILTER "EntityRoleWhiteList"
108 /** MetadataFilter that adds EntityAttributes extension. */
109 #define ENTITYATTR_METADATA_FILTER "EntityAttributes"
111 DECL_XMLTOOLING_EXCEPTION(MetadataFilterException,SAML_EXCEPTIONAPI(SAML_API),opensaml::saml2md,MetadataException,Exceptions related to metadata filtering);
115 #endif /* __saml2_metadatafilt_h__ */