New -lite library and elimination of SAML libraries from modules.
[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
28 #include <set>
29 #ifndef SHIBSP_LITE
30 # include <saml/saml2/metadata/MetadataProvider.h>
31 # include <xmltooling/security/CredentialResolver.h>
32 # include <xmltooling/security/TrustEngine.h>
33 #endif
34
35 namespace shibsp {
36     
37 #ifndef SHIBSP_LITE
38     class SHIBSP_API AttributeExtractor;
39     class SHIBSP_API AttributeFilter;
40     class SHIBSP_API AttributeResolver;
41 #endif
42     class SHIBSP_API Handler;
43     class SHIBSP_API ServiceProvider;
44     class SHIBSP_API SessionInitiator;
45
46     /**
47      * Interface to a Shibboleth Application instance.
48      * 
49      * <p>An Application is a logical set of resources that act as a unit
50      * of session management and policy.
51      */
52     class SHIBSP_API Application : public virtual PropertySet
53     {
54         MAKE_NONCOPYABLE(Application);
55     protected:
56         Application() {}
57     public:
58         virtual ~Application() {}
59
60         /**
61          * Returns the owning ServiceProvider instance.
62          *
63          * @return a locked ServiceProvider
64          */
65         virtual const ServiceProvider& getServiceProvider() const=0;
66
67         /**
68          * Returns the Application's ID.
69          * 
70          * @return  the ID
71          */        
72         virtual const char* getId() const=0;
73
74         /**
75          * Returns a unique hash for the Application.
76          * 
77          * @return a value resulting from a computation over the Application's configuration
78          */
79         virtual const char* getHash() const=0;
80
81         /**
82          * Returns the name and cookie properties to use for this Application.
83          * 
84          * @param prefix    a value to prepend to the base cookie name
85          * @return  a pair containing the cookie name and the string to append to the cookie value
86          */
87         virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix) const;
88
89 #ifndef SHIBSP_LITE
90         /**
91          * Returns a MetadataProvider for use with this Application.
92          * 
93          * @param required  true iff an exception should be thrown if no MetadataProvider is available
94          * @return  a MetadataProvider instance, or NULL
95          */
96         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider(bool required=true) const=0;
97         
98         /**
99          * Returns a TrustEngine for use with this Application.
100          * 
101          * @param required  true iff an exception should be thrown if no TrustEngine is available
102          * @return  a TrustEngine instance, or NULL
103          */
104         virtual xmltooling::TrustEngine* getTrustEngine(bool required=true) const=0;
105
106         /**
107          * Returns an AttributeExtractor for use with this Application.
108          * 
109          * @return  an AttributeExtractor, or NULL
110          */
111         virtual AttributeExtractor* getAttributeExtractor() const=0;
112
113         /**
114          * Returns an AttributeFilter for use with this Application.
115          * 
116          * @return  an AttributeFilter, or NULL
117          */
118         virtual AttributeFilter* getAttributeFilter() const=0;
119
120         /**
121          * Returns an AttributeResolver for use with this Application.
122          * 
123          * @return  an AttributeResolver, or NULL
124          */
125         virtual AttributeResolver* getAttributeResolver() const=0;
126
127         /**
128          * Returns the CredentialResolver instance associated with this Application.
129          * 
130          * @return  a CredentialResolver, or NULL
131          */
132         virtual xmltooling::CredentialResolver* getCredentialResolver() const=0;
133
134         /**
135          * Returns configuration properties governing security interactions with a peer.
136          * 
137          * @param provider  a peer entity's metadata
138          * @return  the applicable PropertySet
139          */
140         virtual const PropertySet* getRelyingParty(const opensaml::saml2md::EntityDescriptor* provider) const=0;
141
142         /**
143          * Returns the set of audience values associated with this Application.
144          * 
145          * @return set of audience values associated with the Application
146          */
147         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
148 #endif
149
150         /**
151          * Returns a set of attribute IDs to use as a REMOTE_USER value.
152          * <p>The first attribute with a value (and only a single value) will be used.
153          *
154          * @return  a set of attribute IDs, or an empty set
155          */
156         virtual const std::set<std::string>& getRemoteUserAttributeIds() const=0;
157
158         /**
159          * Returns the default SessionInitiator when automatically requesting a session.
160          * 
161          * @return the default SessionInitiator, or NULL
162          */
163         virtual const SessionInitiator* getDefaultSessionInitiator() const=0;
164         
165         /**
166          * Returns a SessionInitiator with a particular ID when automatically requesting a session.
167          * 
168          * @param id    an identifier unique to the Application
169          * @return the designated SessionInitiator, or NULL
170          */
171         virtual const SessionInitiator* getSessionInitiatorById(const char* id) const=0;
172         
173         /**
174          * Returns the default AssertionConsumerService Handler
175          * for use in AuthnRequest messages.
176          * 
177          * @return the default AssertionConsumerService, or NULL
178          */
179         virtual const Handler* getDefaultAssertionConsumerService() const=0;
180
181         /**
182          * Returns an AssertionConsumerService Handler with a particular index
183          * for use in AuthnRequest messages.
184          * 
185          * @param index an index unique to an application
186          * @return the designated AssertionConsumerService, or NULL
187          */
188         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
189
190         /**
191          * Returns one or more AssertionConsumerService Handlers that support
192          * a particular protocol binding.
193          * 
194          * @param binding   a protocol binding identifier
195          * @return a set of qualifying AssertionConsumerServices
196          */
197         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
198         
199         /**
200          * Returns the Handler associated with a particular path/location.
201          * 
202          * @param path  the PATH_INFO appended to the end of a base Handler location
203          *              that invokes the Handler
204          * @return the mapped Handler, or NULL 
205          */
206         virtual const Handler* getHandler(const char* path) const=0;
207     };
208 };
209
210 #endif /* __shibsp_app_h__ */