980824a1863251c54f18bc686f749c2b2c7f4b7f
[shibboleth/sp.git] / shibsp / attribute / resolver / ResolutionContext.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/ResolutionContext.h
19  * 
20  * A context for a resolution request.
21  */
22
23 #ifndef __shibsp_resctx_h__
24 #define __shibsp_resctx_h__
25
26 #include <shibsp/base.h>
27
28 #include <saml/Assertion.h>
29 #include <saml/saml2/metadata/Metadata.h>
30
31 namespace shibsp {
32
33     class SHIBSP_API Application;
34     class SHIBSP_API Session;
35     class SHIBSP_API Attribute;
36
37     /**
38      * A context for a resolution request.
39      */
40     class SHIBSP_API ResolutionContext
41     {
42         MAKE_NONCOPYABLE(ResolutionContext);
43     protected:
44         ResolutionContext() {}
45     public:
46         virtual ~ResolutionContext() {}
47
48         /**
49          * Returns the application resolving the attributes.
50          * 
51          * @return  the resolving application
52          */
53         virtual const Application& getApplication() const=0;
54         
55         /**
56          * Returns the address of the client associated with the subject.
57          * 
58          * @return  the client's network address
59          */
60         virtual const char* getClientAddress() const=0;
61
62         /**
63          * Returns the metadata for the IdP associated with the subject, if any.
64          * 
65          * @return the IdP's metadata, or NULL
66          */
67         virtual const opensaml::saml2md::EntityDescriptor* getEntityDescriptor() const=0;
68
69         /**
70          * Returns the NameID associated with the subject
71          * 
72          * <p>SAML 1.x identifiers will be promoted to the 2.0 type.
73          * 
74          * @return a SAML 2.0 NameID associated with the subject, if any
75          */
76         virtual const opensaml::saml2::NameID* getNameID() const=0;
77
78         /**
79          * Returns unresolved tokens associated with the subject, if any.
80          * 
81          * @return pointer to an array of tokens, or NULL
82          */
83         virtual const std::vector<const opensaml::Assertion*>* getTokens() const=0;
84         
85         /**
86          * Returns the active session associated with the subject, if any.
87          * 
88          * @return the active, locked session, or NULL
89          */
90         virtual const Session* getSession() const=0;
91         
92         /**
93          * Returns the set of Attributes resolved and added to the context.
94          * 
95          * <p>Any Attributes left in the returned container will be freed by the
96          * context, so the caller should modify/clear the container after copying
97          * objects for its own use.
98          * 
99          * @return  a mutable array of Attributes.
100          */
101         virtual std::vector<Attribute*>& getResolvedAttributes()=0;
102
103         /**
104          * Returns the set of assertions resolved and added to the context.
105          * 
106          * <p>Any assertions left in the returned container will be freed by the
107          * context, so the caller should modify/clear the container after copying
108          * objects for its own use.
109          * 
110          * @return  a mutable array of Assertions
111          */
112         virtual std::vector<opensaml::Assertion*>& getResolvedAssertions()=0;
113     };
114 };
115
116 #endif /* __shibsp_resctx_h__ */