ed89cbb394f3caba8c93755b735647651203c92c
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / MetadataFilter.h
1 /**
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.
6  *
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
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 /**
22  * @file saml/saml2/metadata/MetadataFilter.h
23  *
24  * Processes metadata after it's been unmarshalled.
25  */
26
27 #include <saml/saml2/metadata/MetadataProvider.h>
28
29 #ifndef __saml2_metadatafilt_h__
30 #define __saml2_metadatafilt_h__
31
32 namespace opensaml {
33     namespace saml2md {
34
35         /**
36          * A metadata filter is used to process metadata after resolution and unmarshalling.
37          *
38          * Some filters might remove everything but identity provider roles, decreasing the data a service provider
39          * needs to work with, or a filter could be used to perform integrity checking on the retrieved metadata by
40          * verifying a digital signature.
41          */
42         class SAML_API MetadataFilter
43         {
44             MAKE_NONCOPYABLE(MetadataFilter);
45         protected:
46             MetadataFilter();
47         public:
48             virtual ~MetadataFilter();
49
50             /**
51              * Returns an identifying string for the filter.
52              *
53              * @return the ID string
54              */
55             virtual const char* getId() const=0;
56
57             /**
58              * Filters the given metadata. Exceptions should generally not be thrown to
59              * signal the removal of information, only for systemic processing failure.
60              *
61              * @param xmlObject the metadata to be filtered.
62              */
63             virtual void doFilter(xmltooling::XMLObject& xmlObject) const=0;
64         };
65
66         /**
67          * Registers MetadataFilter classes into the runtime.
68          */
69         void SAML_API registerMetadataFilters();
70
71         /** MetadataFilter that deletes blacklisted entities. */
72         #define BLACKLIST_METADATA_FILTER  "Blacklist"
73
74         /** MetadataFilter that deletes all but whitelisted entities. */
75         #define WHITELIST_METADATA_FILTER  "Whitelist"
76
77         /** MetadataFilter that verifies signatures and filters out any that don't pass. */
78         #define SIGNATURE_METADATA_FILTER  "Signature"
79
80         /** MetadataFilter that enforces expiration requirements. */
81         #define REQUIREVALIDUNTIL_METADATA_FILTER  "RequireValidUntil"
82
83         /** MetadataFilter that removes non-retained roles. */
84         #define ENTITYROLE_METADATA_FILTER  "EntityRoleWhiteList"
85
86         /** MetadataFilter that adds EntityAttributes extension. */
87         #define ENTITYATTR_METADATA_FILTER "EntityAttributes"
88
89         DECL_XMLTOOLING_EXCEPTION(MetadataFilterException,SAML_EXCEPTIONAPI(SAML_API),opensaml::saml2md,MetadataException,Exceptions related to metadata filtering);
90     };
91 };
92
93 #endif /* __saml2_metadatafilt_h__ */