Add legacy option for fallback to OrgDisplayName, use UTF-8 for names.
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / DiscoverableMetadataProvider.h
1 /*
2  *  Copyright 2010 Internet2
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file saml/saml2/metadata/DiscoverableMetadataProvider.h
19  * 
20  * A metadata provider that provides a JSON feed of IdP discovery information.
21  */
22
23 #ifndef __saml2_discometadataprov_h__
24 #define __saml2_discometadataprov_h__
25
26 #include <saml/saml2/metadata/MetadataProvider.h>
27
28 namespace opensaml {
29     
30     namespace saml2md {
31         
32 #if defined (_MSC_VER)
33         #pragma warning( push )
34         #pragma warning( disable : 4251 )
35 #endif
36         /**
37          * A metadata provider that provides a JSON feed of IdP discovery information.
38          */
39         class SAML_API DiscoverableMetadataProvider : public virtual MetadataProvider
40         {
41         protected:
42             /**
43              * Constructor.
44              *
45              * If a DOM is supplied, the following XML content is supported:
46              *
47              * <dl>
48              *   <dt>legacyOrgNames</dt>
49              *   <dd>true iff IdPs without a UIInfo extension should
50              *      be identified using &lt;md:OrganizationDisplayName&gt;</dd>
51              * </dl>
52              *
53              * @param e DOM to supply configuration for provider
54              */
55             DiscoverableMetadataProvider(const xercesc::DOMElement* e=nullptr);
56             
57             /**
58              * Generates a JSON feed of IdP discovery information for the current metadata.
59              * <p>The provider <strong>MUST</strong> be write-locked.
60              */
61             virtual void generateFeed();
62
63         public:
64             virtual ~DiscoverableMetadataProvider();
65
66             /**
67              * Returns the ETag associated with the cached feed.
68              * <p>The provider <strong>MUST</strong> be locked.
69              *
70              * @return the ETag value for the current feed state
71              */
72             virtual std::string getCacheTag() const;
73
74             /**
75              * Outputs the cached feed.
76              * <p>The provider <strong>MUST</strong> be locked.
77              *
78              * @param os    stream to output feed into
79              * @return a reference to the output stream
80              */
81             virtual std::ostream& outputFeed(std::ostream& os) const;
82
83         protected:
84             /** Storage for feed. */
85             std::string m_feed;
86
87             /** ETag for feed. */
88             mutable std::string m_feedTag;
89
90         private:
91             void disco(std::string& s, const EntityDescriptor* entity, bool& first) const;
92             void disco(std::string& s, const EntitiesDescriptor* group, bool& first) const;
93
94             bool m_legacyOrgNames;
95         };
96
97 #if defined (_MSC_VER)
98         #pragma warning( pop )
99 #endif
100
101     };
102 };
103
104 #endif /* __saml2_discometadataprov_h__ */