Add ability to generate additional metadata content based on config.
[shibboleth/sp.git] / shibsp / attribute / resolver / AttributeExtractor.h
1 /*
2  *  Copyright 2001-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 shibsp/attribute/resolver/AttributeExtractor.h
19  *
20  * A service that extracts and decodes attributes from XML objects.
21  */
22
23 #ifndef __shibsp_extractor_h__
24 #define __shibsp_extractor_h__
25
26 #include <shibsp/base.h>
27
28 #include <string>
29 #include <vector>
30 #include <xmltooling/Lockable.h>
31
32 namespace xmltooling {
33     class XMLTOOL_API XMLObject;
34 };
35
36 namespace opensaml {
37     namespace saml2md {
38         class SAML_API RoleDescriptor;
39         class SAML_API SPSSODescriptor;
40     };
41 };
42
43 namespace shibsp {
44
45     class SHIBSP_API Application;
46     class SHIBSP_API Attribute;
47
48     /**
49      * A service that extracts and decodes attributes from XML objects.
50      */
51     class SHIBSP_API AttributeExtractor : public virtual xmltooling::Lockable
52     {
53         MAKE_NONCOPYABLE(AttributeExtractor);
54     protected:
55         AttributeExtractor();
56     public:
57         virtual ~AttributeExtractor();
58
59         /**
60          * Extracts the attributes found in an XMLObject.
61          *
62          * @param application   Application performing the extraction
63          * @param issuer        source of object, if known
64          * @param xmlObject     object to extract
65          * @param attributes    an array to populate with the extracted attributes
66          *
67          * @throws AttributeExtractionException thrown if there is a problem extracting attributes
68          */
69         virtual void extractAttributes(
70             const Application& application,
71             const opensaml::saml2md::RoleDescriptor* issuer,
72             const xmltooling::XMLObject& xmlObject,
73             std::vector<Attribute*>& attributes
74             ) const=0;
75
76         /**
77          * Populates an array with the set of Attribute IDs that might be generated.
78          *
79          * @param attributes    array to populate
80          */
81         virtual void getAttributeIds(std::vector<std::string>& attributes) const=0;
82
83         /**
84          * Generates and/or modifies metadata reflecting the extractor,
85          * typically attribute-related requirements.
86          *
87          * <p>The default implementation does nothing.
88          *
89          * @param role          metadata role to decorate
90          */
91         virtual void generateMetadata(opensaml::saml2md::SPSSODescriptor& role) const;
92     };
93
94     /**
95      * Registers AttributeExtractor classes into the runtime.
96      */
97     void SHIBSP_API registerAttributeExtractors();
98
99     /** AttributeExtractor based on an XML mapping schema. */
100     #define XML_ATTRIBUTE_EXTRACTOR "XML"
101
102     /** AttributeExtractor for DelegationRestriction information. */
103     #define DELEGATION_ATTRIBUTE_EXTRACTOR "Delegation"
104
105     /** AttributeExtractor for KeyInfo information. */
106     #define KEYDESCRIPTOR_ATTRIBUTE_EXTRACTOR "KeyDescriptor"
107
108     /** AttributeExtractor based on chaining together other extractors. */
109     #define CHAINING_ATTRIBUTE_EXTRACTOR "Chaining"
110 };
111
112 #endif /* __shibsp_extractor_h__ */