Copied over mapping and filtering schemas.
[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
28 #include <saml/saml2/metadata/Metadata.h>
29 #include <xmltooling/Lockable.h>
30
31 namespace shibsp {
32
33     class SHIBSP_API Application;
34     class SHIBSP_API Attribute;
35
36     /**
37      * A service that extracts and decodes attributes from XML objects.
38      */
39     class SHIBSP_API AttributeExtractor : public virtual xmltooling::Lockable
40     {
41         MAKE_NONCOPYABLE(AttributeExtractor);
42     protected:
43         AttributeExtractor() {}
44     public:
45         virtual ~AttributeExtractor() {}
46
47         /**
48          * Extracts the attributes found in an XMLObject.
49          * 
50          * @param application   Application performing the extraction
51          * @param issuer        source of object, if known
52          * @param xmlObject     object to extract
53          * @param attributes    a map to populate with the extracted attributes, keyed by id
54          * 
55          * @throws AttributeExtractionException thrown if there is a problem extracting attributes
56          */
57         virtual void extractAttributes(
58             const Application& application,
59             const opensaml::saml2md::RoleDescriptor* issuer,
60             const xmltooling::XMLObject& xmlObject,
61             std::multimap<std::string,Attribute*>& attributes
62             ) const=0;
63     };
64
65     /**
66      * Registers AttributeExtractor classes into the runtime.
67      */
68     void SHIBSP_API registerAttributeExtractors();
69
70     /** AttributeExtractor based on an XML mapping schema. */
71     #define XML_ATTRIBUTE_EXTRACTOR "XML"
72 };
73
74 #endif /* __shibsp_extractor_h__ */