Add chaining extractor.
[shibboleth/sp.git] / shibsp / attribute / resolver / AttributeExtractor.h
1 /*
2  *  Copyright 2001-2007 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 #include <xmltooling/Lockable.h>
28 #include <saml/saml2/metadata/Metadata.h>
29
30 namespace shibsp {
31
32     class SHIBSP_API Application;
33     class SHIBSP_API Attribute;
34
35     /**
36      * A service that extracts and decodes attributes from XML objects.
37      */
38     class SHIBSP_API AttributeExtractor : public virtual xmltooling::Lockable
39     {
40         MAKE_NONCOPYABLE(AttributeExtractor);
41     protected:
42         AttributeExtractor() {}
43     public:
44         virtual ~AttributeExtractor() {}
45
46         /**
47          * Extracts the attributes found in an XMLObject.
48          * 
49          * @param application   Application performing the extraction
50          * @param issuer        source of object, if known
51          * @param xmlObject     object to extract
52          * @param attributes    an array to populate with the extracted attributes
53          * 
54          * @throws AttributeExtractionException thrown if there is a problem extracting attributes
55          */
56         virtual void extractAttributes(
57             const Application& application,
58             const opensaml::saml2md::RoleDescriptor* issuer,
59             const xmltooling::XMLObject& xmlObject,
60             std::vector<Attribute*>& attributes
61             ) const=0;
62
63         /**
64          * Populates an array with the set of Attribute IDs that might be generated.
65          *
66          * @param attributes    array to populate
67          */
68         virtual void getAttributeIds(std::vector<std::string>& attributes) const=0;
69     };
70
71     /**
72      * Registers AttributeExtractor classes into the runtime.
73      */
74     void SHIBSP_API registerAttributeExtractors();
75
76     /** AttributeExtractor based on an XML mapping schema. */
77     #define XML_ATTRIBUTE_EXTRACTOR "XML"
78
79     /** AttributeExtractor based on chaining together other extractors. */
80     #define CHAINING_ATTRIBUTE_EXTRACTOR "Chaining"
81 };
82
83 #endif /* __shibsp_extractor_h__ */