VS10 solution files, convert from NULL macro to nullptr.
[shibboleth/cpp-sp.git] / shibsp / attribute / resolver / AttributeResolver.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/AttributeResolver.h
19  *
20  * A service that transforms or resolves additional attributes for a
21  * particular subject.
22  */
23
24 #ifndef __shibsp_resolver_h__
25 #define __shibsp_resolver_h__
26
27 #include <shibsp/base.h>
28
29 #include <string>
30 #include <vector>
31 #include <xmltooling/Lockable.h>
32
33 namespace opensaml {
34     class SAML_API Assertion;
35     namespace saml2 {
36         class SAML_API NameID;
37     };
38     namespace saml2md {
39         class SAML_API EntityDescriptor;
40     };
41 };
42
43 namespace shibsp {
44
45     class SHIBSP_API Application;
46     class SHIBSP_API Attribute;
47     class SHIBSP_API Session;
48     class SHIBSP_API ResolutionContext;
49
50 #if defined (_MSC_VER)
51     #pragma warning( push )
52     #pragma warning( disable : 4250 4251 )
53 #endif
54
55     /**
56      * The service that resolves the attributes for a particular subject.
57      */
58     class SHIBSP_API AttributeResolver : public virtual xmltooling::Lockable
59     {
60         MAKE_NONCOPYABLE(AttributeResolver);
61     protected:
62         AttributeResolver();
63     public:
64         virtual ~AttributeResolver();
65
66         /**
67          * Creates a ResolutionContext based on session bootstrap material.
68          *
69          * <p>This enables resolution to occur ahead of session creation so that
70          * Attributes can be supplied while creating the session.
71          *
72          * @param application       reference to Application that owns the eventual Session
73          * @param issuer            issuing metadata of assertion issuer, if known
74          * @param protocol          protocol used to establish Session
75          * @param nameid            principal identifier, normalized to SAML 2, if any
76          * @param authncontext_class    method/category of authentication event, if known
77          * @param authncontext_decl specifics of authentication event, if known
78          * @param tokens            assertions initiating the Session, if any
79          * @param attributes        array of previously resolved attributes, if any
80          * @return  newly created ResolutionContext, owned by caller
81          */
82         virtual ResolutionContext* createResolutionContext(
83             const Application& application,
84             const opensaml::saml2md::EntityDescriptor* issuer,
85             const XMLCh* protocol,
86             const opensaml::saml2::NameID* nameid=nullptr,
87             const XMLCh* authncontext_class=nullptr,
88             const XMLCh* authncontext_decl=nullptr,
89             const std::vector<const opensaml::Assertion*>* tokens=nullptr,
90             const std::vector<Attribute*>* attributes=nullptr
91             ) const=0;
92
93         /**
94          * Creates a ResolutionContext for an existing Session.
95          *
96          * @param application   reference to Application that owns the Session
97          * @param session       reference to Session
98          * @return  newly created ResolutionContext, owned by caller
99          */
100         virtual ResolutionContext* createResolutionContext(const Application& application, const Session& session) const=0;
101
102
103         /**
104          * Resolves attributes for a given subject and returns them in the supplied context.
105          *
106          * @param ctx           resolution context to use to resolve attributes
107          *
108          * @throws AttributeResolutionException thrown if there is a problem resolving the attributes for the subject
109          */
110         virtual void resolveAttributes(ResolutionContext& ctx) const=0;
111
112         /**
113          * Populates an array with the set of Attribute IDs that might be generated.
114          *
115          * @param attributes    array to populate
116          */
117         virtual void getAttributeIds(std::vector<std::string>& attributes) const=0;
118     };
119
120 #if defined (_MSC_VER)
121     #pragma warning( pop )
122 #endif
123
124     /**
125      * Registers AttributeResolver classes into the runtime.
126      */
127     void SHIBSP_API registerAttributeResolvers();
128
129     /** AttributeResolver based on SAML queries to an IdP during SSO. */
130     #define QUERY_ATTRIBUTE_RESOLVER "Query"
131
132     /** AttributeResolver based on free-standing SAML queries to additional AAs. */
133     #define SIMPLEAGGREGATION_ATTRIBUTE_RESOLVER "SimpleAggregation"
134
135     /** AttributeResolver based on chaining together other resolvers. */
136     #define CHAINING_ATTRIBUTE_RESOLVER "Chaining"
137 };
138
139 #endif /* __shibsp_resolver_h__ */