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/DiscoverableMetadataProvider.h
24 * A metadata provider that provides a JSON feed of IdP discovery information.
27 #ifndef __saml2_discometadataprov_h__
28 #define __saml2_discometadataprov_h__
30 #include <saml/saml2/metadata/MetadataProvider.h>
32 #include <boost/shared_ptr.hpp>
37 class SAML_API Attribute;
42 class SAML_API EntityAttributes;
43 class SAML_API EntityMatcher;
45 #if defined (_MSC_VER)
46 #pragma warning( push )
47 #pragma warning( disable : 4251 )
50 * A metadata provider that provides a JSON feed of IdP discovery information.
52 class SAML_API DiscoverableMetadataProvider : public virtual MetadataProvider
58 * If a DOM is supplied, the following XML content is supported:
61 * <dt>legacyOrgNames</dt>
62 * <dd>true iff IdPs without a UIInfo extension should
63 * be identified using <md:OrganizationDisplayName></dd>
64 * <dt>entityAttributes</dt>
65 * <dd>true iff tags found in <mdattr:EntityAttributes>
66 * extensions should be included in the feed</dd>
67 * <dt><DiscoveryFilter type="..." matcher="..." ></dt>
68 * <dd>Zero or more filters of type "Whitelist" or "Blacklist" that
69 * affect which entities get exposed by the feed. The actual matching
70 * is driven by an EntityMatcher plugin identified by the matcher
71 * attribute. Other element content will be present to configure
75 * @param e DOM to supply configuration for provider
77 DiscoverableMetadataProvider(const xercesc::DOMElement* e=nullptr);
80 * Generates a JSON feed of IdP discovery information for the current metadata.
81 * <p>The provider <strong>MUST</strong> be write-locked.
83 virtual void generateFeed();
86 virtual ~DiscoverableMetadataProvider();
89 * Returns the ETag associated with the cached feed.
90 * <p>The provider <strong>MUST</strong> be locked.
92 * @return the ETag value for the current feed state
94 virtual std::string getCacheTag() const;
97 * Outputs the cached feed.
98 * <p>The provider <strong>MUST</strong> be locked.
100 * @param os stream to output feed into
101 * @param first on input, indicates if the feed is first in position,
102 * on output will be false if the feed was non-empty
103 * @param wrapArray true iff the feed array should be opened/closed by this provider
105 virtual void outputFeed(std::ostream& os, bool& first, bool wrapArray=true) const;
108 /** Storage for feed. */
111 /** ETag for feed. */
112 mutable std::string m_feedTag;
115 void discoEntity(std::string& s, const EntityDescriptor* entity, bool& first) const;
116 void discoGroup(std::string& s, const EntitiesDescriptor* group, bool& first) const;
117 void discoEntityAttributes(std::string& s, const EntityAttributes& ea, bool& first) const;
118 void discoAttributes(std::string& s, const std::vector<saml2::Attribute*>& attrs, bool& first) const;
120 bool m_legacyOrgNames, m_entityAttributes;
121 std::vector< std::pair< bool, boost::shared_ptr<EntityMatcher> > > m_discoFilters;
124 #if defined (_MSC_VER)
125 #pragma warning( pop )
131 #endif /* __saml2_discometadataprov_h__ */