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