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