Rework decoder handling in simple resolver, add IdP/SP names to decoder API, hook...
[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/TrustEngine.h>
29 #include <xmltooling/validation/Validator.h>
30
31 namespace shibsp {
32     
33     class SHIBSP_API AttributeResolver;
34     class SHIBSP_API Handler;
35     class SHIBSP_API ServiceProvider;
36
37     /**
38      * Interface to a Shibboleth Application instance.
39      * 
40      * <p>An Application is a logical set of resources that act as a unit
41      * of session management and policy.
42      */
43     class SHIBSP_API Application : public virtual PropertySet
44     {
45         MAKE_NONCOPYABLE(Application);
46     protected:
47         Application() {}
48     public:
49         virtual ~Application() {}
50
51         /**
52          * Returns the owning ServiceProvider instance.
53          *
54          * @return a locked ServiceProvider
55          */
56         virtual const ServiceProvider& getServiceProvider() const=0;
57
58         /**
59          * Returns the Application's ID.
60          * 
61          * @return  the ID
62          */        
63         virtual const char* getId() const=0;
64
65         /**
66          * Returns a unique hash for the Application.
67          * 
68          * @return a value resulting from a hash of the Application's ID  
69          */
70         virtual const char* getHash() const=0;
71
72         /**
73          * Returns the name and cookie properties to use for this Application.
74          * 
75          * @param prefix    a value to prepend to the base cookie name
76          * @return  a pair containing the cookie name and the string to append to the cookie value
77          */
78         virtual std::pair<std::string,const char*> getCookieNameProps(const char* prefix) const;
79
80         /**
81          * Returns a MetadataProvider for use with this Application.
82          * 
83          * @return  a MetadataProvider instance, or NULL
84          */
85         virtual opensaml::saml2md::MetadataProvider* getMetadataProvider() const=0;
86         
87         /**
88          * Returns a TrustEngine for use with this Application.
89          * 
90          * @return  a TrustEngine instance, or NULL
91          */
92         virtual xmltooling::TrustEngine* getTrustEngine() const=0;
93
94         /**
95          * Returns an AttributeResolver for use with this Application.
96          * 
97          * @return  an AttributeResolver, or NULL
98          */
99         virtual AttributeResolver* getAttributeResolver() const=0;
100
101         /**
102          * Returns configuration properties governing security interactions with a peer entity.
103          * 
104          * @param provider  a peer entity's metadata
105          * @return  the applicable PropertySet
106          */
107         virtual const PropertySet* getCredentialUse(const opensaml::saml2md::EntityDescriptor* provider) const=0;
108
109         /**
110          * Returns the default SessionInitiator Handler when automatically
111          * requesting a session.
112          * 
113          * @return the default SessionInitiator, or NULL
114          */
115         virtual const Handler* getDefaultSessionInitiator() const=0;
116         
117         /**
118          * Returns a SessionInitiator Handler with a particular ID when automatically
119          * requesting a session.
120          * 
121          * @param id    an identifier unique to the Application
122          * @return the designated SessionInitiator, or NULL
123          */
124         virtual const Handler* getSessionInitiatorById(const char* id) const=0;
125         
126         /**
127          * Returns the default AssertionConsumerService Handler
128          * for use in AuthnRequest messages.
129          * 
130          * @return the default AssertionConsumerService, or NULL
131          */
132         virtual const Handler* getDefaultAssertionConsumerService() const=0;
133
134         /**
135          * Returns an AssertionConsumerService Handler with a particular index
136          * for use in AuthnRequest messages.
137          * 
138          * @param index an index unique to an application
139          * @return the designated AssertionConsumerService, or NULL
140          */
141         virtual const Handler* getAssertionConsumerServiceByIndex(unsigned short index) const=0;
142
143         /**
144          * Returns one or more AssertionConsumerService Handlers that support
145          * a particular protocol binding.
146          * 
147          * @param binding   a protocol binding identifier
148          * @return a set of qualifying AssertionConsumerServices
149          */
150         virtual const std::vector<const Handler*>& getAssertionConsumerServicesByBinding(const XMLCh* binding) const=0;
151         
152         /**
153          * Returns the Handler associated with a particular path/location.
154          * 
155          * @param path  the PATH_INFO appended to the end of a base Handler location
156          *              that invokes the Handler
157          * @return the mapped Handler, or NULL 
158          */
159         virtual const Handler* getHandler(const char* path) const=0;
160
161         /**
162          * Returns the set of audience values associated with this Application.
163          * 
164          * @return set of audience values associated with the Application
165          */
166         virtual const std::vector<const XMLCh*>& getAudiences() const=0;
167
168         /**
169          * Returns a validator for applying verification rules to incoming SAML tokens.
170          *
171          * <p>The validator must be freed by the caller.
172          * 
173          * @param ts    timestamp against which to evaluate the token's validity, or 0 to ignore
174          * @param role  metadata role of token issuer, if known
175          * @return a validator
176          */
177         virtual xmltooling::Validator* getTokenValidator(time_t ts=0, const opensaml::saml2md::RoleDescriptor* role=NULL) const=0;
178     };
179 };
180
181 #endif /* __shibsp_app_h__ */