Factor entityID into SessionInitiator subinterface, move WAYF logic out of Shib handler.
[shibboleth/sp.git] / shibsp / Application.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/Application.h
19  * 
20  * Interface to a Shibboleth Application instance.
21  */
22
23 #ifndef __shibsp_app_h__
24 #define __shibsp_app_h__
25
26 #include <shibsp/util/PropertySet.h>
27 #include <saml/saml2/metadata/MetadataProvider.h>
28 #include <xmltooling/security/CredentialResolver.h>
29 #include <xmltooling/security/TrustEngine.h>
30
31 namespace shibsp {
32     
33     class SHIBSP_API AttributeResolver;
34     class SHIBSP_API Handler;
35     class SHIBSP_API ServiceProvider;
36     class SHIBSP_API SessionInitiator;
37
38     /**
39      * Interface to a Shibboleth Application instance.
40      * 
41      * <p>An Application is a logical set of resources that act as a unit
42      * of session management and policy.
43      */
44     class SHIBSP_API Application : public virtual PropertySet
45     {
46         MAKE_NONCOPYABLE(Application);
47     protected:
48         Application() {}
49     public:
50         virtual ~Application() {}
51
52         /**
53          * Returns the owning ServiceProvider instance.
54          *
55          * @return a locked ServiceProvider
56          */
57         virtual const ServiceProvider& getServiceProvider() const=0;
58
59         /**
60          * Returns the Application's ID.
61          * 
62          * @return  the ID
63          */        
64         virtual const char* getId() const=0;
65
66         /**
67          * Returns a unique hash for the Application.
68          * 
69          * @return a value resulting from a hash of the Application's ID  
70          */
71         virtual const char* getHash() const=0;
72
73         /**
74          * Returns the name and cookie properties to use for this Application.
75          * 
76          * @param prefix    a value to prepend to the base cookie name
77          * @return  a pair containing the cookie name and the string to append to the cookie value
78          */
79         virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix) const;
80
81         /**
82          * Returns a MetadataProvider for use with this Application.
83          * 
84          * @return  a MetadataProvider instance, or NULL
85          */
86         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider() const=0;
87         
88         /**
89          * Returns a TrustEngine for use with this Application.
90          * 
91          * @return  a TrustEngine instance, or NULL
92          */
93         virtual xmltooling::TrustEngine* getTrustEngine() const=0;
94
95         /**
96          * Returns an AttributeResolver for use with this Application.
97          * 
98          * @return  an AttributeResolver, or NULL
99          */
100         virtual AttributeResolver* getAttributeResolver() const=0;
101
102         /**
103          * Returns a set of attribute IDs to resolve for the Application.
104          *
105          * @return  a set of attribute IDs, or an empty set
106          */
107         virtual const std::set<std::string>* getAttributeIds() const=0;
108
109         /**
110          * Returns the CredentialResolver instance associated with this Application.
111          * 
112          * @return  a CredentialResolver, or NULL
113          */
114         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
115
116         /**
117          * Returns configuration properties governing security interactions with a peer.
118          * 
119          * @param provider  a peer entity's metadata
120          * @return  the applicable PropertySet
121          */
122         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
123
124         /**
125          * Returns the default SessionInitiator when automatically requesting a session.
126          * 
127          * @return the default SessionInitiator, or NULL
128          */
129         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
130         
131         /**
132          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
133          * 
134          * @param id    an identifier unique to the Application
135          * @return the designated SessionInitiator, or NULL
136          */
137         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
138         
139         /**
140          * Returns the default AssertionConsumerService Handler
141          * for use in AuthnRequest messages.
142          * 
143          * @return the default AssertionConsumerService, or NULL
144          */
145         virtual const Handler* getDefaultAssertionConsumerService() const=0;
146
147         /**
148          * Returns an AssertionConsumerService Handler with a particular index
149          * for use in AuthnRequest messages.
150          * 
151          * @param index an index unique to an application
152          * @return the designated AssertionConsumerService, or NULL
153          */
154         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
155
156         /**
157          * Returns one or more AssertionConsumerService Handlers that support
158          * a particular protocol binding.
159          * 
160          * @param binding   a protocol binding identifier
161          * @return a set of qualifying AssertionConsumerServices
162          */
163         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
164         
165         /**
166          * Returns the Handler associated with a particular path/location.
167          * 
168          * @param path  the PATH_INFO appended to the end of a base Handler location
169          *              that invokes the Handler
170          * @return the mapped Handler, or NULL 
171          */
172         virtual const Handler* getHandler(const char* path) const=0;
173
174         /**
175          * Returns the set of audience values associated with this Application.
176          * 
177          * @return set of audience values associated with the Application
178          */
179         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
180     };
181 };
182
183 #endif /* __shibsp_app_h__ */