Boost changes
[shibboleth/cpp-opensaml.git] / saml / saml2 / metadata / DiscoverableMetadataProvider.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/DiscoverableMetadataProvider.h
23  * 
24  * A metadata provider that provides a JSON feed of IdP discovery information.
25  */
26
27 #ifndef __saml2_discometadataprov_h__
28 #define __saml2_discometadataprov_h__
29
30 #include <saml/saml2/metadata/MetadataProvider.h>
31
32 namespace opensaml {
33     
34     namespace saml2md {
35         
36 #if defined (_MSC_VER)
37         #pragma warning( push )
38         #pragma warning( disable : 4251 )
39 #endif
40         /**
41          * A metadata provider that provides a JSON feed of IdP discovery information.
42          */
43         class SAML_API DiscoverableMetadataProvider : public virtual MetadataProvider
44         {
45         protected:
46             /**
47              * Constructor.
48              *
49              * If a DOM is supplied, the following XML content is supported:
50              *
51              * <dl>
52              *   <dt>legacyOrgNames</dt>
53              *   <dd>true iff IdPs without a UIInfo extension should
54              *      be identified using &lt;md:OrganizationDisplayName&gt;</dd>
55              * </dl>
56              *
57              * @param e DOM to supply configuration for provider
58              */
59             DiscoverableMetadataProvider(const xercesc::DOMElement* e=nullptr);
60             
61             /**
62              * Generates a JSON feed of IdP discovery information for the current metadata.
63              * <p>The provider <strong>MUST</strong> be write-locked.
64              */
65             virtual void generateFeed();
66
67         public:
68             virtual ~DiscoverableMetadataProvider();
69
70             /**
71              * Returns the ETag associated with the cached feed.
72              * <p>The provider <strong>MUST</strong> be locked.
73              *
74              * @return the ETag value for the current feed state
75              */
76             virtual std::string getCacheTag() const;
77
78             /**
79              * Outputs the cached feed.
80              * <p>The provider <strong>MUST</strong> be locked.
81              *
82              * @param os        stream to output feed into
83              * @param first     on input, indicates if the feed is first in position,
84              *                  on output will be false if the feed was non-empty
85              * @param wrapArray true iff the feed array should be opened/closed by this provider
86              */
87             virtual void outputFeed(std::ostream& os, bool& first, bool wrapArray=true) const;
88
89         protected:
90             /** Storage for feed. */
91             std::string m_feed;
92
93             /** ETag for feed. */
94             mutable std::string m_feedTag;
95
96         private:
97             void discoEntity(std::string& s, const EntityDescriptor* entity, bool& first) const;
98             void discoGroup(std::string& s, const EntitiesDescriptor* group, bool& first) const;
99
100             bool m_legacyOrgNames;
101         };
102
103 #if defined (_MSC_VER)
104         #pragma warning( pop )
105 #endif
106
107     };
108 };
109
110 #endif /* __saml2_discometadataprov_h__ */