Shell of new SP object interface to replace old IConfig layer.
[shibboleth/sp.git] / shibsp / ServiceProvider.h
1 /*
2  *  Copyright 2001-2006 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/ServiceProvider.h
19  * 
20  * Interface to a Shibboleth ServiceProvider instance.
21  */
22
23 #ifndef __shibsp_sp_h__
24 #define __shibsp_sp_h__
25
26 #include <shibsp/PropertySet.h>
27 #include <xmltooling/signature/CredentialResolver.h>
28
29 namespace shibsp {
30
31     class ListenerService;
32
33     /**
34      * Interface to a Shibboleth ServiceProvider instance.
35      * 
36      * <p>A ServiceProvider exposes configuration and infrastructure services required
37      * by the SP implementation, allowing a flexible configuration format.
38      */
39     class SHIBSP_API ServiceProvider : public virtual xmltooling::Lockable, public virtual PropertySet
40     {
41         MAKE_NONCOPYABLE(ServiceProvider);
42     protected:
43         ServiceProvider() {}
44     public:
45         virtual ~ServiceProvider() {}
46         
47         /**
48          * Loads a configuration and prepares the instance for use.
49          * 
50          * <p>Implemented as a separate method so that services can rely on
51          * other services while they initialize by accessing the ServiceProvider
52          * from the SPConfig singleton.
53          */
54         virtual void init()=0;
55         
56         /**
57          * Returns a ListenerService instance.
58          * 
59          * @param required  true iff an exception should be thrown if no ListenerService is available
60          * @return  a ListenerService if available, or NULL
61          */
62         virtual ListenerService* getListenerService(bool required=true) const=0;
63         
64         /**
65          * Returns a CredentialResolver instance mapped to a key.
66          * 
67          * @param id    a NULL-terminated key identifying the CredentialResolver to the configuration 
68          * @return  a CredentialResolver if available, or NULL
69          */
70         virtual xmlsignature::CredentialResolver* getCredentialResolver(const char* id) const=0;
71
72         //virtual ISessionCache* getSessionCache() const=0;
73         
74         //virtual IRequestMapper* getRequestMapper() const=0;
75         
76         //virtual const IApplication* getApplication(const char* applicationId) const=0;
77     };
78
79     /**
80      * Registers ServiceProvider classes into the runtime.
81      */
82     void SHIBSP_API registerServiceProviders();
83
84     /** SP based on integrated XML and native server configuration. */
85     #define XML_SERVICE_PROVIDER "edu.internet2.middleware.shibboleth.sp.provider.XMLServiceProvider"
86 };
87
88 #endif /* __shibsp_sp_h__ */