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