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